Skip to content

Commit

Permalink
Partial support construct tuple as simple expression (#1107)
Browse files Browse the repository at this point in the history
SELECT (1,2)
  • Loading branch information
tvar authored Jan 31, 2021
1 parent f2e74f1 commit 2065fed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -3281,6 +3281,7 @@ Expression PrimaryExpression() #PrimaryExpression:
boolean exclamationMarkNot = false;
boolean dateExpressionAllowed = true;
Expression idxExpr;
ExpressionList list;
}
{
[ <K_NOT> { not=true; } | "!" { not=true; exclamationMarkNot=true; } ]
Expand Down Expand Up @@ -3341,7 +3342,14 @@ Expression PrimaryExpression() #PrimaryExpression:

| LOOKAHEAD("(" retval=SubSelect() ")") "(" retval=SubSelect() ")"

| "(" retval=SimpleExpression() ")" {retval = new Parenthesis(retval); }
| "(" list = SimpleExpressionList() ")"
{
if (list.getExpressions().size() == 1) {
retval = new Parenthesis(list.getExpressions().get(0));
} else {
retval = new RowConstructor().withExprList(list);
}
}
)

[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4441,4 +4441,9 @@ public void testSignedKeywordIssue1100() throws JSQLParserException {
public void testSignedKeywordIssue995() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("SELECT leading FROM prd_reprint");
}

@Test
public void testSelectTuple() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("SELECT hyperloglog_distinct((1, 2)) FROM t");
}
}

0 comments on commit 2065fed

Please sign in to comment.