bug fixed sql parser aggregate distinct output

This commit is contained in:
wenshao
2012-07-18 07:29:47 +08:00
parent 5a3237cd1f
commit 4b64b07e38
12 changed files with 82 additions and 23 deletions
@@ -20,7 +20,7 @@ public class PGAggregateExpr extends SQLAggregateExpr implements PGSQLObject {
private static final long serialVersionUID = 1L;
public PGAggregateExpr(String methodName, int option) {
public PGAggregateExpr(String methodName, Option option) {
super(methodName, option);
}
@@ -19,16 +19,18 @@ public class PGExprParser extends SQLExprParser{
super(lexer);
}
protected SQLAggregateExpr parseAggregateExpr(String method_name) throws ParserException {
protected SQLAggregateExpr parseAggregateExpr(String methodName) throws ParserException {
methodName = methodName.toUpperCase();
PGAggregateExpr aggregateExpr;
if (lexer.token() == Token.ALL) {
aggregateExpr = new PGAggregateExpr(method_name, 1);
aggregateExpr = new PGAggregateExpr(methodName, SQLAggregateExpr.Option.ALL);
lexer.nextToken();
} else if (lexer.token() == Token.DISTINCT) {
aggregateExpr = new PGAggregateExpr(method_name, 0);
aggregateExpr = new PGAggregateExpr(methodName, SQLAggregateExpr.Option.DISTINCT);
lexer.nextToken();
} else {
aggregateExpr = new PGAggregateExpr(method_name, 1);
aggregateExpr = new PGAggregateExpr(methodName);
}
exprList(aggregateExpr.getArguments());
@@ -433,12 +433,21 @@ public class PGOutputVisitor extends SQLASTOutputVisitor implements PGASTVisitor
@Override
public boolean visit(PGAggregateExpr x) {
print(x.getMethodName());
print("(");
if (x.getOption() != null) {
print(x.getOption().toString());
print(' ');
}
printAndAccept(x.getArguments(), ", ");
print(")");
if (x.getOver() != null) {
x.getOver().accept(this);
}
return false;
}