Merge remote-tracking branch 'upstream/master'

This commit is contained in:
wenshao
2013-06-06 12:28:45 +08:00
28 changed files with 676 additions and 169 deletions
@@ -34,18 +34,14 @@ public class SQLBetweenExpr extends SQLExprImpl implements Serializable {
}
public SQLBetweenExpr(SQLExpr testExpr, SQLExpr beginExpr, SQLExpr endExpr){
this.testExpr = testExpr;
this.beginExpr = beginExpr;
this.endExpr = endExpr;
setTestExpr(testExpr);
setBeginExpr(beginExpr);
setEndExpr(endExpr);
}
public SQLBetweenExpr(SQLExpr testExpr, boolean not, SQLExpr beginExpr, SQLExpr endExpr){
this.testExpr = testExpr;
this(testExpr, beginExpr, endExpr);
this.not = not;
this.beginExpr = beginExpr;
this.endExpr = endExpr;
}
public void output(StringBuffer buf) {
@@ -74,6 +70,9 @@ public class SQLBetweenExpr extends SQLExprImpl implements Serializable {
}
public void setTestExpr(SQLExpr testExpr) {
if (testExpr != null) {
testExpr.setParent(this);
}
this.testExpr = testExpr;
}
@@ -90,6 +89,9 @@ public class SQLBetweenExpr extends SQLExprImpl implements Serializable {
}
public void setBeginExpr(SQLExpr beginExpr) {
if (beginExpr != null) {
beginExpr.setParent(this);
}
this.beginExpr = beginExpr;
}
@@ -98,6 +100,9 @@ public class SQLBetweenExpr extends SQLExprImpl implements Serializable {
}
public void setEndExpr(SQLExpr endExpr) {
if (endExpr != null) {
endExpr.setParent(this);
}
this.endExpr = endExpr;
}
@@ -42,7 +42,7 @@ public class SQLMethodInvokeExpr extends SQLExprImpl implements Serializable {
public SQLMethodInvokeExpr(String methodName, SQLExpr owner){
this.methodName = methodName;
this.owner = owner;
setOwner(owner);
}
public String getMethodName() {
@@ -58,6 +58,9 @@ public class SQLMethodInvokeExpr extends SQLExprImpl implements Serializable {
}
public void setOwner(SQLExpr owner) {
if (owner != null) {
owner.setParent(this);
}
this.owner = owner;
}
@@ -31,8 +31,7 @@ public class SQLQueryExpr extends SQLExprImpl implements Serializable {
}
public SQLQueryExpr(SQLSelect select){
this.subQuery = select;
setSubQuery(select);
}
public SQLSelect getSubQuery() {
@@ -40,6 +39,9 @@ public class SQLQueryExpr extends SQLExprImpl implements Serializable {
}
public void setSubQuery(SQLSelect subQuery) {
if (subQuery != null) {
subQuery.setParent(this);
}
this.subQuery = subQuery;
}
@@ -430,7 +430,7 @@ public class MySqlExprParser extends SQLExprParser {
SQLMethodInvokeExpr methodInvokeExpr = new SQLMethodInvokeExpr(ident);
if (lexer.token() != Token.RPAREN) {
exprList(methodInvokeExpr.getParameters());
exprList(methodInvokeExpr.getParameters(), methodInvokeExpr);
}
if (identifierEquals("USING")) {
@@ -454,11 +454,11 @@ public class MySqlExprParser extends SQLExprParser {
accept(Token.IN);
SQLExpr str = this.expr();
accept(Token.RPAREN);
SQLMethodInvokeExpr locate = new SQLMethodInvokeExpr("LOCATE");
locate.getParameters().add(subStr);
locate.getParameters().add(str);
expr = locate;
return primaryRest(expr);
}
@@ -536,7 +536,7 @@ public class MySqlExprParser extends SQLExprParser {
SQLExpr expr = this.expr();
((MySqlSQLColumnDefinition) column).setOnUpdate(expr);
}
if (identifierEquals("AUTO_INCREMENT")) {
lexer.nextToken();
if (column instanceof MySqlSQLColumnDefinition) {
@@ -552,13 +552,13 @@ public class MySqlExprParser extends SQLExprParser {
if (identifierEquals("PARTITION")) {
throw new ParserException("syntax error " + lexer.token() + " " + lexer.stringVal());
}
if (identifierEquals("COMMENT")) {
lexer.nextToken();
column.setComment(lexer.stringVal());
accept(Token.LITERAL_CHARS);
}
if (identifierEquals("STORAGE")) {
lexer.nextToken();
SQLExpr expr = expr();
@@ -566,15 +566,15 @@ public class MySqlExprParser extends SQLExprParser {
((MySqlSQLColumnDefinition) column).setStorage(expr);
}
}
super.parseColumnRest(column);
return column;
}
protected SQLDataType parseDataTypeRest(SQLDataType dataType) {
super.parseDataTypeRest(dataType);
if (identifierEquals("UNSIGNED")) {
lexer.nextToken();
dataType.getAttributes().put("unsigned", true);
@@ -718,9 +718,9 @@ public class MySqlExprParser extends SQLExprParser {
public MySqlUnique parseUnique() {
accept(Token.UNIQUE);
if (lexer.token() == Token.KEY) {
lexer.nextToken();
lexer.nextToken();
}
MySqlUnique unique = new MySqlUnique();
@@ -730,12 +730,12 @@ public class MySqlExprParser extends SQLExprParser {
unique.setIndexType(lexer.stringVal());
lexer.nextToken();
}
if (lexer.token() != Token.LPAREN) {
SQLName name = name();
unique.setName(name);
SQLName name = name();
unique.setName(name);
}
accept(Token.LPAREN);
for (;;) {
unique.getColumns().add(this.expr());
@@ -749,21 +749,21 @@ public class MySqlExprParser extends SQLExprParser {
return unique;
}
public MySqlForeignKey parseForeignKey() {
accept(Token.FOREIGN);
accept(Token.KEY);
MySqlForeignKey fk = new MySqlForeignKey();
accept(Token.LPAREN);
this.names(fk.getReferencingColumns());
accept(Token.RPAREN);
accept(Token.REFERENCES);
fk.setReferencedTableName(this.name());
accept(Token.LPAREN);
this.names(fk.getReferencedColumns());
accept(Token.RPAREN);
@@ -578,7 +578,7 @@ public class SQLExprParser extends SQLParser {
methodInvokeExpr.getParameters().add(new SQLIdentifierExpr("+"));
lexer.nextToken();
} else {
exprList(methodInvokeExpr.getParameters());
exprList(methodInvokeExpr.getParameters(), methodInvokeExpr);
}
accept(Token.RPAREN);
}
@@ -612,7 +612,7 @@ public class SQLExprParser extends SQLParser {
exprCol.add(name());
}
}
public final void exprList(Collection<SQLExpr> exprCol) {
exprList(exprCol, null);
}
@@ -1264,7 +1264,7 @@ public class SQLExprParser extends SQLParser {
column.getConstaints().add(new SQLColumnPrimaryKey());
return parseColumnRest(column);
}
if (lexer.token == Token.CHECK) {
lexer.nextToken();
SQLExpr expr = this.expr();
@@ -796,7 +796,7 @@ public class SQLEvalVisitorUtils {
if (wallConditionContext != null) {
wallConditionContext.setConstArithmetic(true);
}
if (leftValue == null || rightValue == null) {
return false;
}
@@ -1290,7 +1290,7 @@ public class SQLEvalVisitorUtils {
}
if (a instanceof String || b instanceof String) {
return ((String) a).compareTo((String) b) < 0;
return (castToString(a)).compareTo(castToString(b)) < 0;
}
if (a instanceof BigDecimal || b instanceof BigDecimal) {