-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix property parsing when a property contains a struct (#210)
Properties are parsed lazily by deserializing the data into an `IgnoredAny` and then returning the bytes that have been read. We do parse structs as an enum in order to emit the struct tag as enum tag. The `IgnoredAny` then deserializes a newtype enum variant, expecting a single item. The `VariantAccess` impl for the packstream deserializer would then only emit the next field in the struct, introducing the bug. The fix is to emit all fields when the list of items is from a struct and we are parsing properties.
- Loading branch information
1 parent
a56e2d2
commit d719bd1
Showing
3 changed files
with
80 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use chrono::{DateTime, FixedOffset}; | ||
use neo4rs::{query, Node}; | ||
|
||
mod container; | ||
|
||
#[tokio::test] | ||
async fn node_property_parsing() { | ||
let neo4j = container::Neo4jContainer::new().await; | ||
let graph = neo4j.graph(); | ||
|
||
graph | ||
.run(query("CREATE (:A {p1:DATETIME('2024-12-31T08:10:35')})")) | ||
.await | ||
.unwrap(); | ||
|
||
let mut result = graph.execute(query("MATCH (p:A) RETURN p")).await.unwrap(); | ||
|
||
while let Ok(Some(row)) = result.next().await { | ||
let node: Node = row.get("p").unwrap(); | ||
let p1 = node.get::<DateTime<FixedOffset>>("p1").unwrap(); | ||
assert_eq!(p1.timestamp(), 1735632635); | ||
} | ||
} |