openCypher icon indicating copy to clipboard operation
openCypher copied to clipboard

User defined function in custom namespace parsed as property lookup if function name is a keyword

Open jonaskello opened this issue 2 years ago • 3 comments
trafficstars

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.

jonaskello avatar Feb 01 '23 08:02 jonaskello

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.

jonaskello avatar Feb 01 '23 09:02 jonaskello

I am also seeing a flavor of this issue for

RETURN apoc.create.uuid()

with 'CREATE' being a reserved word.

rvrooman-codelogic avatar Jun 21 '23 18:06 rvrooman-codelogic

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.

rvrooman-codelogic avatar Jun 21 '23 19:06 rvrooman-codelogic