-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deserialize missing properties as none (#159)
* Deserialize missing properties as none fixed #147 * Don't use let..else
- Loading branch information
1 parent
0660928
commit 79200fa
Showing
4 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use neo4rs::{query, Node}; | ||
use serde::Deserialize; | ||
|
||
mod container; | ||
|
||
#[tokio::test] | ||
async fn missing_properties() { | ||
let neo4j = container::Neo4jContainer::new().await; | ||
let graph = neo4j.graph(); | ||
|
||
let a_val = None::<String>; | ||
let mut result = graph | ||
.execute(query("CREATE (ts:TestStruct {a: $a}) RETURN ts").param("a", a_val)) | ||
.await | ||
.unwrap(); | ||
let row = result.next().await.unwrap().unwrap(); | ||
let expected = StructWithOption { a: None, b: None }; | ||
|
||
let test_struct: StructWithOption = row.to().unwrap(); | ||
assert_eq!(test_struct, expected); | ||
|
||
let node = row.get::<Node>("ts").unwrap(); | ||
let test_struct: StructWithOption = node.to().unwrap(); | ||
assert_eq!(test_struct, expected); | ||
} | ||
|
||
#[derive(Deserialize, PartialEq, Eq, Debug)] | ||
struct StructWithOption { | ||
a: Option<String>, | ||
b: Option<String>, | ||
} |