nicolewhite / cycli

A Command Line Interface for Neo4j's Cypher.
MIT License
272 stars 25 forks source link

Semicolon in quoted property seems to be incorrectly interpreted as end of cypher statement #50

Closed eyz closed 7 years ago

eyz commented 8 years ago

When creating a node with a semicolon in the property value, the following error was produced. Perhaps the semicolon parsing isn't always being skipped inside quotes?

Please note that the troublesome code is rendered as a left arrow in this Github issue, as that is the HTML entity where the problematic semicolon parsing occurs. View source below to see the semicolon in context, or the attached screenshot of the code here -

screenshot_20161208-231228-02


MATCH (mno:ghi) where mno.id = "mno" CREATE (def:ghi{id:"jkl",stu:"xyz ⇐ Unexpected end of input: expected '\', ANY or '"' (line 4, column 131 (offset: 287)) "CREATE (def:ghi{id:"jkl",stu:"xyz ⇐" ^

abc",pqr:"xyz ⇐ Invalid input '1': expected (line 1, column 1 (offset: 0)) "abc",pqr:"xyz ⇐" ^

I tried to redact the actual cypher, and hopefully that doesn't obfuscate it too much. I can add another case where this also happened in a where clause as well if that helps.

nicolewhite commented 7 years ago

Can you paste the exact query? You have a semicolon after xyz?

eyz commented 7 years ago

Nicole, please see the updated error. If that doesn't help identify the parser issue then I can try to isolate an example for you. This was only the output error I posted so far.

nicolewhite commented 7 years ago

Are you executing these queries from a file? Using cycli --filename queries.txt or something?

nicodemus commented 7 years ago

My guess is that is the case. From main.py:

if self.filename: queries = self.filename.read() queries = queries.split(";")[:-1]

As it doesn't pay any attention to context (eg, quoted string), it looks like a semi-colon anywhere other than the end of a statement will break things.

nicolewhite commented 7 years ago

That's why I asked if he was using the --filename param. That code is only executed if you're reading queries from a file. That should be fixed regardless, but I'm trying to figure out if it's another bug.

eyz commented 7 years ago

Yes, @nicolewhite, I have just confirmed that we use the -f flag to read cypher from a file.

cycli -h neo4j -f "${CYPHER_TEMP}"

nicolewhite commented 7 years ago

Okay cool. I will fix this soon.