openCypher
openCypher copied to clipboard
User defined function in custom namespace parsed as property lookup if function name is a keyword
We've encountered an issue where we name a user defined function to a keyword.
For example
myns.all()
Is parsed as a property lookup of property all on object myns. It seems this is related to ALL being a keyword. It parses correctly for all function names except when using keywords as function names.
Just wanted to check if there is a rule that you cannot name any functions within user defined namespaces to keywords or if there is a bug somewhere?
We are using antlr4 for JavaScript to do the parsing.
I think it is related to this part of the grammar:
oC_Atom
: oC_Literal
| oC_Parameter
| oC_CaseExpression
| ( COUNT SP? '(' SP? '*' SP? ')' )
| oC_ListComprehension
| oC_PatternComprehension
| oC_Quantifier
| oC_PatternPredicate
| oC_ParenthesizedExpression
| oC_FunctionInvocation
| oC_ExistentialSubquery
| oC_Variable
;
For myns.all() it will select oC_Variable but for myns.notAKeyword() it will select oC_FunctionInvocation.
I am also seeing a flavor of this issue for
RETURN apoc.create.uuid()
with 'CREATE' being a reserved word.
From what I can see in the 'User-defined functions' section of the specification v9, there is no restriction on function names or namespaces containing reserved words.
This does seem like an issue with the grammar.