RedisGraph / redisgraph-py

RedisGraph python client
https://redisgraph.io
BSD 3-Clause "New" or "Revised" License
189 stars 49 forks source link

Feature Request: Support double dot param names #66

Open B-Stefan opened 4 years ago

B-Stefan commented 4 years ago

Thanks for all the work on this project!

I tried to integrate RedisGraph into an existing project(prov-db-connector) and got an unexpected error:

The following command with params will cause an exception because the param name contains and :

Example to reproduce

 params = {'prefix:purpose': "pleasure"}
 query = """MATCH (p:person)-[v:visited {purpose:$purpose}]->(c:country)
                   RETURN p.name, p.age, v.purpose, c.name"""
result = graph.query(query, params)

The code above produces the following query and exception

Exception

social CYPHER prefix:purpose="pleasure" MATCH (p:person)-[v:visited {purpose:$purpose}]->(c:country)
                   RETURN p.name, p.age, v.purpose, c.name
redis.exceptions.ResponseError: errMsg: Invalid input ':': expected '=' line: 1, column: 14, offset: 13 errCtx: CYPHER prefix:purpose="pleasure" MATCH (p:person)-[v:visited {purpose:$purpos... errCtxOffset: 13

Expected behavior

The example above should be saved successfully to Redis

Potential solution

The library should escape/encode params and queries.

What do you think about this issue? If you need any help to reproduce or investigate this issue, please let me know!

swilly22 commented 4 years ago

Generally speaking including : within the parameter name is a bit confusing as a parameter is defined as a key : value pair. Assuming setting the parameter works, how would you refer to it? RETURN $prefix:purpose probably won't work, This is what I'm getting from Neo4j:

RETURN $prefix:purpose
Neo.ClientError.Statement.ParameterMissing
Expected parameter(s): prefix
B-Stefan commented 4 years ago

Yeah, I agree, it is not best-practice but still allowed to address via ``. Example query I wrote 2 years ago:

MATCH (x {`meta:identifier`: 'some'})-[r *1]-(y)
B-Stefan commented 3 years ago

Just want to ask if this issue is still open or do you think a new evaluation would be promising due to a complete rewrite/improvement of the library during the last year?

swilly22 commented 3 years ago

Sorry @B-Stefan this issue is still open, I'm able to create an attribute with : in its name but was unable to define a parameter with : in its name.

B-Stefan commented 2 years ago

Happy new year to everybody. I just revisited an open issue on the prov-db-connector, and I want to ask if this issue is still open or resolved in a release of redisgraph-py?

swilly22 commented 2 years ago

Hi, I believe the issue is still open, @jeffreylovitz would you mind taking a look ?

jeffreylovitz commented 2 years ago

Hi @B-Stefan,

This is a parser-level issue, rather than being scoped to redisgraph-py.

I've written a fix, and we should be able to merge it into the master branch within a few days!