Skip to content

Commit

Permalink
improved postgresql parser, fix #4221
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 2, 2021
1 parent 2b48f09 commit 24eb08e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,9 @@ protected SQLExpr methodRest(SQLExpr expr, boolean acceptLPAREN) {
aggregateExpr.setOption(SQLAggregateOption.DISTINCT);
}

if (lexer.token == Token.COLONCOLON) {
return primaryRest(aggregateExpr);
}

return aggregateExpr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public void test_10() throws Exception {
exec_test("bvt/parser/postgresql-10.txt");
}

public void test_11() throws Exception {
exec_test("bvt/parser/postgresql-11.txt");
}

public void exec_test(String resource) throws Exception {
System.out.println(resource);
InputStream is = null;
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/bvt/parser/postgresql-11.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
select v_date_desc::date - max(access_time)::date from table1;
---------------------------
SELECT v_date_desc::date - max(access_time)::date
FROM table1;

0 comments on commit 24eb08e

Please # to comment.