mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved pg parser, fix #4266
This commit is contained in:
+11
-4
@@ -109,11 +109,18 @@ public class PGOutputVisitor extends SQLASTOutputVisitor implements PGASTVisitor
|
||||
} else if (SQLSetQuantifier.DISTINCT == x.getDistionOption()) {
|
||||
print0(ucase ? "DISTINCT " : "distinct ");
|
||||
|
||||
if (x.getDistinctOn() != null && x.getDistinctOn().size() > 0) {
|
||||
List<SQLExpr> distinctOn = x.getDistinctOn();
|
||||
if (distinctOn != null && distinctOn.size() > 0) {
|
||||
print0(ucase ? "ON " : "on ");
|
||||
print0("(");
|
||||
printAndAccept(x.getDistinctOn(), ", ");
|
||||
print0(") ");
|
||||
|
||||
if (distinctOn.size() == 1 && distinctOn.get(0) instanceof SQLListExpr) {
|
||||
printExpr(distinctOn.get(0));
|
||||
print(' ');
|
||||
} else {
|
||||
print0("(");
|
||||
printAndAccept(distinctOn, ", ");
|
||||
print0(") ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,10 @@ public class PostgresqlResourceTest extends PGTest {
|
||||
exec_test("bvt/parser/postgresql-12.txt");
|
||||
}
|
||||
|
||||
public void test_13() throws Exception {
|
||||
exec_test("bvt/parser/postgresql-13.txt");
|
||||
}
|
||||
|
||||
public void exec_test(String resource) throws Exception {
|
||||
System.out.println(resource);
|
||||
InputStream is = null;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
select distinct on (a,b) a,b from table order by a,b
|
||||
---------------------------
|
||||
SELECT DISTINCT ON (a, b) a, b
|
||||
FROM table
|
||||
ORDER BY a, b
|
||||
Reference in New Issue
Block a user