improved pg parser, fix #4266

This commit is contained in:
高铁
2021-05-04 13:56:56 +08:00
parent ea174f36e1
commit dfdb95691e
3 changed files with 20 additions and 4 deletions
@@ -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(") ");
}
}
}