Coder Social home page Coder Social logo

neo4j-labs / neo4rs Goto Github PK

View Code? Open in Web Editor NEW
172.0 5.0 56.0 656 KB

Neo4j driver for rust

Home Page: https://docs.rs/neo4rs

Rust 99.83% Just 0.11% Shell 0.06%
rust neo4j bolt cypher cypher-query-language neo4j-driver neo4j-database rust-lang rust-crate hacktoberfest

neo4rs's People

Contributors

0xdjole avatar caamartin35 avatar elimirks avatar github-actions[bot] avatar jifalops avatar knutwalker avatar peikos avatar s1ck avatar solidtux avatar titanous avatar urhengulas avatar yehohanan7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

neo4rs's Issues

bool value in param not allowed

execute(query(&query_string).param("a", true))

This doesnt work because

the trait From<bool> is not implemented for neo4rs::types::BoltType

Can this be added or is there a reason its not allowed?

Appear Error "IO driver has terminated" ,How to solve

Recently, I try "neo4rs"," Deadpool-bolt", "b88-bolt" to create connection pool with neo4j. My program appears

"error:UnexpectedMessage("unexpected response for RUN: Err(IOError { detail: "IO driver has terminated" })")"driver has terminated"

when many query appears in a short time. How to solve it ?

I have google the error , but I did not found any useful information.

allow 'impl Into<BoltType> for "CustomType"'

i want bind json object by Query.param(). but Into<BoltType> just implemented for some basic type.

can bind whole properties for label by Query.param()? like this:

struct CustomType<T:  Into<BoltType>> {
  p1: T,
  p2: T,
  p3: T,
}

let properties = CustomType::new();

// case 1
query("CREATE (SomeLabel $properties)").param("properties", properties);

// case 2
query("CREATE (SomeLabel {data: $data})").param("data", properties);

Is this repository abandoned?

It looks like this repository is abandoned, but quite some people seem to be happy to provide pull requests and have forks.

Would you be happy to transfer ownership of the crate to someone in case you don't plan to continue working on it?

APIs could be a bit friendlier to users

Hey, all.

Sorry about the title but that's the clearest way I could think to say it. There are a few areas, such as Query, where it would be nice to either be able to access struct fields as public or have accessor methods for the private fields. I can't really think of a reason the fields would need to be private, as the data belongs to the user of the library anyway.

Also, it would be nice to be able to perform comparison operations on some of the data structs, such as PartialEq. I'm willing to help out in this area. Do you all accept pull requests? Thanks.

llegal struct size: Expected struct to be 3 fields but got 1

use anyhow::bail;
use neo4rs::Graph;

use crate::{NEO4J_PASS, NEO4J_URL, NEO4J_USER};

pub struct AppState {
    pub graph: Graph,
}

impl AppState {
    pub async fn new() -> anyhow::Result<Self> {
        let this = match Graph::new(NEO4J_URL, NEO4J_USER, NEO4J_PASS).await {
            Ok(graph) => Self { graph },
            Err(err) => {
                return bail!("Error creating graph instance in app state {err:?}");
            }
        };

        let mut result = this
            .graph
            .execute(neo4rs::query("MATCH (p:Person {name: $name}) RETURN p").param("name", "Mark"))
            .await
            .unwrap();
        Ok(this)
    }
}
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UnexpectedMessage("unexpected response for RUN: Ok(FailureMessage(Failure { metadata: BoltMap { value: {BoltString { value: \"code\" }: String(BoltString { value: \"Neo.ClientError.Request.InvalidFormat\" }), BoltString { value: \"message\" }: String(BoltString { value: \"Illegal struct size: Expected struct to be 3 fields but got 1\" })} } }))")', src\api\app_state.rs:23:14
docker run --name global_graph_neo -p 7474:7474 -p 7687:7687 -e "NEO4J_AUTH=neo4j/password" neo4j

OS: windows 11

Latest tagged version is from 2021, newest crate available from crates.io is 0.5.9

Hey, all. I apologize if this is the wrong place for this.

It took a while to confirm, but I was having problems with the driver establishing connection with a recent 5.4.0 server. When I realized the newest available crate on crates.io might be rather old, I built this from source and tested it. It works.

Does anyone know who updates the tagged releases here? Anyone know who updates crates.io? I'm willing to help out, but I'm not entirely sure where to start. Is there any official build instructions? My local build is a bit of a mess at the moment. Using a locally-built crate to resolve issues is not ideal. Thanks.

Use (Serde) `Serialize` instead of or additionally to `Into<BoltType>`

https://serde.rs/

This would solve #7 and add a lot of flexibility, marcos, ...
I guess Deserialize would also be handy.

If you like, I would create a PR for it
I just realised that BoltType is deeply rooted into your crate and also conflicts with an into implementation from any type that is Serialize so this is probably a lot...

What I actually try to archive is converting a JSON Map (with different Value Types) to BoltType.
But currently there seems to be no way of getting to a BoltMap so adding a
impl<T> From<Box<T>> for BoltType where T: Into<BoltType>
for the dynamic types would not by itself help me

However converting from JSON would be easy:

impl From<serde_json::Value> for BoltType {
    fn from(json: serde_json::Value) -> BoltType {
        match json {
            serde_json::Value::Null => BoltType::Null(BoltNull),
            serde_json::Value::Bool(bool) => BoltType::Boolean(BoltBoolean::new(bool)),
            serde_json::Value::Number(nr) => {
                if nr.is_f64() {
                    BoltType::Float(BoltFloat::new(nr.as_f64().unwrap()))
                }else{
                    BoltType::Integer(BoltInteger::new(nr.as_i64().unwrap()))
                }
            },
            serde_json::Value::String(str) => BoltType::String(BoltString::new(&str)),
            serde_json::Value::Array(arr) => {
                let mut l = BoltList::with_capacity(arr.len());
                for v in arr {
                    l.push(v.into());
                }
                BoltType::List(l)
            },
            serde_json::Value::Object(map) => {
                let mut m = BoltMap::with_capacity(map.len());
                for (k,v) in map {
                    m.put(k.into(),v.into());
                }
                BoltType::Map(m)
            },
        }
    }
}

Would you be interested in a conversion from JSON? Probably behind a Feature flag, as I guess that serde_json adds a bit of weight

Row is empty?

This is a query from the server
image
It have 1 result, created is int

The code below, do the same exact query

    let mut result = provider
        .graph
        .execute(query("MATCH(p:Post) RETURN p"))
        .await
        .unwrap();
    
    let row = result.next().await.unwrap().unwrap();
    let t = row.get::<i64>("created");
    info!("{}", t.is_some());
    result.next().await.unwrap().unwrap(); //panic

output

false
thread 'actix-rt|system:0|arbiter:7' panicked at 'called `Option::unwrap()` on a `None` value', src/main.rs:64:34

observable behaviour: it did return 1 row, however, created is None
expected behaviour: t.is_some()==true

Enviroment: Arch Host, docker 23.0.1, image: neo4j:4.1
Cargo.toml

neo4rs = { git = "https://github.com/neo4j-labs/neo4rs" }

The same result happen up to neo4j:4.4.18

Null values are not supported

Trying to get a null value from a row results in the following error:

Error: UnexpectedMessage("unexpected response for PULL: Err(UnknownType("b\"\\xc0\""))")

Add serde support

Implement de/serializing bolt results to user types. Users can use their Serialize/Deserialize types to send/receive data without having to go bolt -> rust -> user

Cannot get Lists from Rows

When running a query like MATCH (a)-[r]-(b) RETURN a, collect(b.name) as mylist The node a is accessible but the collection mylist is not. It show's up in the Row response as a

Row { attributes: BoltMap { value: {BoltString { value: "mylist" }: List(BoltList { value: [String(BoltString { value: "somevalue" }), String(BoltString { value: "anothervalue" })] }), BoltString { value: "a" }...

But when calling row.get("mylist") you always get None

Decide on an MSRV

around 1.59 makes sense, set it in Cargo.toml. Update CI to use a Cargo.msrv.lock. Update dependencies accordingly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.