florinpatrascu / bolt_sips

Neo4j driver for Elixir
Apache License 2.0
258 stars 49 forks source link

errors on semicolon #23

Closed sergey-ivlev closed 7 years ago

sergey-ivlev commented 7 years ago

Hello! a little example whith semicolon in text, which raise exeption

Bolt.Sips.query!(Bolt.Sips.conn, "MERGE (:Test {text: \"test with semicolon;\"})")

21:58:18.753 [debug] [{:sock_ref, "", #PID<0.624.0>, #PID<0.625.0>, #PID<0.626.0>}] cypher: "MERGE (:Test {text: \"test with semicolon" - params: %{} - bolt: {:error, %Boltex.Error{code: "Neo.ClientError.Statement.SyntaxError", connection_id: nil, function: :run_statement, message: "Unexpected end of input: expected '\', ANY or '\"' (line 1, column 41 (offset: 40))\n\"MERGE (:Test {text: \"test with semicolon\"\n ^", type: :cypher_error}} (elixir) lib/exception.ex:494: RuntimeError.exception(%Boltex.Error{code: "Neo.ClientError.Statement.SyntaxError", connection_id: nil, function: :run_statement, message: "Unexpected end of input: expected '\', ANY or '\"' (line 1, column 41 (offset: 40))\n\"MERGE (:Test {text: \"test with semicolon\"\n ^", type: :cypher_error}) (bolt_sips) lib/bolt_sips/query.ex:100: Bolt.Sips.Query.send!/4 (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3 (bolt_sips) lib/bolt_sips/query.ex:86: Bolt.Sips.Query.tx/3 (bolt_sips) lib/bolt_sips/query.ex:55: Bolt.Sips.Query.query!/3

In web editor this request process correctly.

florinpatrascu commented 7 years ago

Hi there - yep, you caught a bug, thank you! Please try the master branch (is 0.2.5).

BTW, you should escape the " character. For example:

iex(2)> Bolt.Sips.query!(Bolt.Sips.conn, "MERGE (:AnotherTest {text: \"test with semicolon;\"})")
%{stats: %{"labels-added" => 1, "nodes-created" => 1, "properties-set" => 1}, type: "w"}

or use single quote:

iex(4)> Bolt.Sips.query!(Bolt.Sips.conn, "MERGE (:YetAnotherTest {text: 'test with semicolon;'})")
%{stats: %{"labels-added" => 1, "nodes-created" => 1, "properties-set" => 1}, type: "w"}

The web editor is not a close comparison, unfortunately, but I understood how to replicate your finding.

Thanks again and please let me know if the new version works for you. Also, it will be awesome if you can confirm it's working on Windows as well, just in case you're using Windows?!

🍻

sergey-ivlev commented 7 years ago

Thanks a lot, it works! tested on nix* and i haven't Windows, sorry Thanks again

florinpatrascu commented 7 years ago

Cool, thank you too!

florinpatrascu commented 7 years ago

Package published to https://hex.pm/packages/bolt_sips/0.2.5