Skip to content

Commit

Permalink
supportnut parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Yako authored and Yako committed Jan 8, 2015
1 parent 732258a commit e0f9048
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class SQLAggregateExpr extends SQLExprImpl implements Serializable {

private static final long serialVersionUID = 1L;
protected String methodName;
protected Option option;
protected SQLAggregateOption option;
protected final List<SQLExpr> arguments = new ArrayList<SQLExpr>();
protected SQLOver over;
protected SQLOrderBy withinGroup;
Expand All @@ -39,7 +39,7 @@ public SQLAggregateExpr(String methodName){
this.methodName = methodName;
}

public SQLAggregateExpr(String methodName, Option option){
public SQLAggregateExpr(String methodName, SQLAggregateOption option){
this.methodName = methodName;
this.option = option;
}
Expand All @@ -64,11 +64,11 @@ public void setWithinGroup(SQLOrderBy withinGroup) {
this.withinGroup = withinGroup;
}

public Option getOption() {
public SQLAggregateOption getOption() {
return this.option;
}

public void setOption(Option option) {
public void setOption(SQLAggregateOption option) {
this.option = option;
}

Expand Down Expand Up @@ -153,7 +153,4 @@ public boolean equals(Object obj) {
return true;
}

public static enum Option {
DISTINCT, ALL, UNIQUE
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2015 Alibaba.com All right reserved. This software is the
* confidential and proprietary information of Alibaba.com ("Confidential
* Information"). You shall not disclose such Confidential Information and shall
* use it only in accordance with the terms of the license agreement you entered
* into with Alibaba.com.
*/
package com.alibaba.druid.sql.ast.expr;

public enum SQLAggregateOption {

DISTINCT, ALL, UNIQUE

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.alibaba.druid.sql.ast.SQLOrderBy;
import com.alibaba.druid.sql.ast.SQLOrderingSpecification;
import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr;
import com.alibaba.druid.sql.ast.expr.SQLAggregateOption;
import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr;
import com.alibaba.druid.sql.ast.expr.SQLBinaryOperator;
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
Expand Down Expand Up @@ -754,13 +755,13 @@ protected SQLAggregateExpr parseAggregateExpr(String methodName) {

SQLAggregateExpr aggregateExpr;
if (lexer.token() == Token.UNIQUE) {
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateExpr.Option.UNIQUE);
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateOption.UNIQUE);
lexer.nextToken();
} else if (lexer.token() == (Token.ALL)) {
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateExpr.Option.ALL);
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateOption.ALL);
lexer.nextToken();
} else if (lexer.token() == (Token.DISTINCT)) {
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateExpr.Option.DISTINCT);
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateOption.DISTINCT);
lexer.nextToken();
} else {
aggregateExpr = new SQLAggregateExpr(methodName);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.alibaba.druid.sql.ast.SQLOrderingSpecification;
import com.alibaba.druid.sql.ast.SQLOver;
import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr;
import com.alibaba.druid.sql.ast.expr.SQLAggregateOption;
import com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr;
import com.alibaba.druid.sql.ast.expr.SQLAllExpr;
import com.alibaba.druid.sql.ast.expr.SQLAnyExpr;
Expand Down Expand Up @@ -905,10 +906,10 @@ protected SQLAggregateExpr parseAggregateExpr(String methodName) {

SQLAggregateExpr aggregateExpr;
if (lexer.token() == Token.ALL) {
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateExpr.Option.ALL);
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateOption.ALL);
lexer.nextToken();
} else if (lexer.token() == Token.DISTINCT) {
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateExpr.Option.DISTINCT);
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateOption.DISTINCT);
lexer.nextToken();
} else {
aggregateExpr = new SQLAggregateExpr(methodName);
Expand Down

0 comments on commit e0f9048

Please sign in to comment.