[BUG] NxTranslator.to_cypher_queries doesn't escape apostrophes. #249
Labels
bug
bug
community
community
Effort - Low
Effort - Low
Frequency - EveryTime
Frequency - EveryTime
Priority - Next
Priority - Next
Reach - VeryFew
Reach - VeryFew
Severity - S3
Severity - S3
Memgraph version
Memgraph 2.8.0
Gqlalchemy 1.4.1
Environment
I am running Memgraph in Docker on a MacBook Pro Apple M1 Max chipset.
Bug description, reproduction and expected behaviour
The method
translator.to_cypher_queries
[1] is not escaping apostrophes.Node in NetworkX graph:
(15981, { 'labels': 'Word', 'Token': "Ain't", 'IPA': 'ʔ aɪ n t' })
Generated query using the aforementioned method:
CREATE (:Word {Token: 'Ain't', IPA: 'ʔ aɪ n t', id: 15981});
[2]When trying to execute the query [2] in Memgraph, I get the following:
Query failed: Invalid query.
Which is expected because the apostrophe wasn't escaped.The method [1] should instead return the query as follows:
CREATE (:Word {Token: 'Ain\'t', IPA: 'ʔ aɪ n t', id: 15981});
Potential solution
Simple solution for the time being:
escape_apostrophes = lambda x: re.compile(r"(['])").sub(r"\\'", x)
The text was updated successfully, but these errors were encountered: