grammars-v4 icon indicating copy to clipboard operation
grammars-v4 copied to clipboard

[sql/mysql/Positive-Technologies] `subqueryComparisonPredicate` Problem

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

predicate
    : predicate NOT? IN '(' (selectStatement | expressions) ')'     #inPredicate
    | predicate IS nullNotnull                                      #isNullPredicate
    | left=predicate comparisonOperator right=predicate             #binaryComparisonPredicate
    | predicate comparisonOperator
      quantifier=(ALL | ANY | SOME) '(' selectStatement ')'         #subqueryComparisonPredicate
    | predicate NOT? BETWEEN predicate AND predicate                #betweenPredicate
    | predicate SOUNDS LIKE predicate                               #soundsLikePredicate
    | predicate NOT? LIKE predicate (ESCAPE STRING_LITERAL)?        #likePredicate
    | predicate NOT? regex=(REGEXP | RLIKE) predicate               #regexpPredicate
    | (LOCAL_ID VAR_ASSIGN)? expressionAtom                         #expressionAtomPredicate
    | predicate MEMBER OF '(' predicate ')'                         #jsonMemberOfPredicate
    ;

[Description]

Simple test

SELECT * FROM T WHERE X > ALL (SELECT 1);
SELECT * FROM T WHERE X > ANY (SELECT 1);
SELECT * FROM T WHERE X > SOME (SELECT 1);

The ALL is fine, but the SOME ANY is recognized as fullColumnName.

The full Parse Tree below

antlr4_parse_tree

partoneplay avatar May 09 '22 03:05 partoneplay

Have you tried to swap left=predicate comparisonOperator right=predicate and predicate comparisonOperator quantifier=(ALL | ANY | SOME) '(' selectStatement ')' ?

KvanTTT avatar May 09 '22 12:05 KvanTTT

Have you tried to swap left=predicate comparisonOperator right=predicate and predicate comparisonOperator quantifier=(ALL | ANY | SOME) '(' selectStatement ')' ?

The problem persists after I tried.

partoneplay avatar May 10 '22 01:05 partoneplay