FalkorDB / FalkorDB

A super fast Graph Database uses GraphBLAS under the hood for its sparse adjacency matrix graph representation. Our goal is to provide the best Knowledge Graph for LLM (GraphRAG).
https://www.falkordb.com/
Other
723 stars 31 forks source link

Escaping ` in symbolic name does not work (node label, relationship type, property key, variable, parameter) #154

Open gkorland opened 1 year ago

gkorland commented 1 year ago

Created by: @kdojeteri Source: https://github.com/RedisGraph/RedisGraph/issues/1187 I was trying to figure out a universal way to safely pass arbitrary node labels to a query. I read this bit in OpenCypher's antlr4 grammar, which lead me to think I could just use backticks:

/**
 * Any character except "`", enclosed within `backticks`. Backticks are escaped with double backticks.
 */
EscapedSymbolicName
                   :  ( '`' ( EscapedSymbolicName_0 )* '`' )+ ;

Unfortunately, the backticks are escaped with double backticks bit doesn't work in redis-graph. This query creates a node with the label Foobar`123, but redis-graph throws an error:

>> GRAPH.QUERY portal-graph "MERGE (:`Foobar``123`)"
(error) errMsg: Invalid input '`': expected a label, '{', a parameter or ')' line: 1, column: 17, offset: 16 errCtx: MERGE (:`Foobar``123`) errCtxOffset: 16
gkorland commented 1 year ago

Origin comment by: @DvirDukhan @kdojeteri This is our libcypher-parser error of invalid query. I tried your query also in Neo4J and it didn't work. image There is a note that a backtick should be escaped with double backticks but I couldn't get this variant to work either in neo4j or RedisGraph can you specify a working query that fails on RedisGraph?

gkorland commented 1 year ago

Origin comment by: @kdojeteri I hate to do a "works on my machine", but here's a video as proof that the original query works: https://ctrlv.tv/6VDS

Neo4j Browser version: 4.0.10

Neo4j Server version: 3.5.19 (community)

gkorland commented 1 year ago

Origin comment by: @DvirDukhan @kdojeteri It is confirmed to work on neo4j 3.5.19 but not working on the latest version. I will query with neo4j for this regression. If this feature is still valid I'll contact Chris Leishman, who maintains the libcypher-parser and open an issue/PR.