Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Deserialization of Duration returns BoltList instead of Duration #231

Open
MikuSugar opened this issue Feb 20, 2025 · 0 comments
Open

Comments

@MikuSugar
Copy link

MikuSugar commented Feb 20, 2025

Thanks for the great work on neo4rs! I’ve encountered an issue when executing a query with a std::time::Duration parameter. The result cannot be automatically deserialized into a BoltDuration as expected. Instead, it returns a BoltList. This causes an issue where the Duration cannot be properly deserialized into the desired type.

It would be helpful if the library could support automatic deserialization of std::time::Duration into BoltDuration, or if there’s an alternative approach to handle this correctly.
code:

use neo4rs::*;

#[tokio::main]
async fn main() {
    let uri = "127.0.0.1:7687";
    let user = "neo4j";
    let pass = "neo";
    let graph = Graph::new(uri, user, pass).await.unwrap();

    let duration = std::time::Duration::new(5259600, 7);
    let mut result = graph
        .execute(query("RETURN $d as output").param("d", duration))
        .await
        .unwrap();
    let row = result.next().await.unwrap().unwrap();
    let d: std::time::Duration = row.get("output").unwrap();
    println!("{:?}", d);
    
    let mut result = graph
        .execute(query("RETURN $d as output").param("d", duration))
        .await
        .unwrap();
    let row = result.next().await.unwrap().unwrap();
    let d= row.get::<BoltType>("output").unwrap();
    println!("{:?}", d);
}

output:

5259600.000000007s
List(BoltList { value: [Integer(BoltInteger { value: 5259600 }), Integer(BoltInteger { value: 7 })] })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant