Comments section in Cypher

Hi,

Today I faced a strange problem.
At Neo4j Desktop browser I ran below code expecting that code will initialize two parameter variables. But it threw error to me
:param x => "value 1";
//
//
//

:param y => "value 2";

Error
:param x => "value 1"
// // // :param y => "value 2"
Neo.ClientError.Statement.SyntaxError: Invalid input ':': expected (line 4, column 1 (offset: 9))
":param y => "value 2""
^

Then I tried to run comment section of differently
1 :param x => "value 1";
//a
//b
//c

:param y => "value 2";
Output

Note that :param (and anything starting with a :) isn't actually Cypher, but instead will be interpreted as a command for the application (in this case, the Neo4j Browser).

As such, don't expect the browser commands to interpret comments the way Cypher does, since they will never be interpreted by the Cypher engine.

In most cases, since commands are usually short, there shouldn't be many cases where you would need to have comments.

Hi Andrew,

This is not about :. this problem is posted by Roy too Syntax error around Cypher comments - #3 by rmasrani.

Somehow for me it is only reproducible with param.
In any language if some symbol is used as comment then ideally engine should skip those line as Cypher also did in the browser at several instances.

I have not tried the same to reproduce the issue out of browser, however I am still feel that throwing an error is issue irrespective or cypher/browser.

I am not sure looks like by mistake I marked it as Solution.

You likely would not be able to reproduce this out of the browser with :param, excepting cypher-shell, as it would error out as invalid syntax. As mentioned, the : commands, including :param are not cypher. They are not interpreted as Cypher, nor executed as Cypher. They are intercepted and interpreted by the application (the Neo4j Browser or Cypher-shell) and cannot be otherwise used by the Neo4j drivers, because these commands are not Cypher, so the Neo4j server itself doesn't know what to do with it.

That said, it does make sense to have the browser recognize comment characters when it interprets commands, and even between statements and/or commands when the multi-statement query editor is being used. I'll see if I can add that as a backlog item for the browser.

1 Like

I do not know how to execute multiple statements in one shot using Cypher shell. However I completely rely on you that this is Neo4j browser issue, which needs to be fixed.

Reasons

  1. It behave differently. Please see examples I shared with you
  2. In the attached post Roy faced this issue without : too.

Please check if you have multiple statement query editor is enabled in your neo4j browser settings.

I can do this without any error in browser.

:param x => "value 1";
:param y => "value 2";

I already have enabled multiple statement query editor. That is working good. This problem comes with some combination of comments symbol

You are correct about comments. It seems the comments and the multi-statement are not compatible in browser.

You can use the comments with cyphershell without any issues.

1 Like