mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sql parser improve sql server support
This commit is contained in:
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLListExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCallStatement;
|
||||
@@ -565,23 +566,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
udpateStatement.setTableSource(tableSource);
|
||||
}
|
||||
|
||||
accept(Token.SET);
|
||||
|
||||
for (;;) {
|
||||
SQLUpdateSetItem item = new SQLUpdateSetItem();
|
||||
item.setColumn(this.exprParser.name());
|
||||
accept(Token.EQ);
|
||||
item.setValue(this.exprParser.expr());
|
||||
|
||||
udpateStatement.getItems().add(item);
|
||||
|
||||
if (lexer.token() == (Token.COMMA)) {
|
||||
lexer.nextToken();
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
parseUpdateSet(udpateStatement);
|
||||
|
||||
if (lexer.token() == (Token.WHERE)) {
|
||||
lexer.nextToken();
|
||||
@@ -590,6 +575,33 @@ public class SQLStatementParser extends SQLParser {
|
||||
|
||||
return udpateStatement;
|
||||
}
|
||||
|
||||
protected void parseUpdateSet(SQLUpdateStatement update) {
|
||||
accept(Token.SET);
|
||||
|
||||
for (;;) {
|
||||
SQLUpdateSetItem item = new SQLUpdateSetItem();
|
||||
|
||||
if (lexer.token() == (Token.LPAREN)) {
|
||||
lexer.nextToken();
|
||||
SQLListExpr list = new SQLListExpr();
|
||||
this.exprParser.exprList(list.getItems());
|
||||
accept(Token.RPAREN);
|
||||
item.setColumn(list);
|
||||
} else {
|
||||
item.setColumn(this.exprParser.primary());
|
||||
}
|
||||
accept(Token.EQ);
|
||||
item.setValue(this.exprParser.expr());
|
||||
update.getItems().add(item);
|
||||
|
||||
if (lexer.token() != Token.COMMA) {
|
||||
break;
|
||||
}
|
||||
|
||||
lexer.nextToken();
|
||||
}
|
||||
}
|
||||
|
||||
protected SQLUpdateStatement createUpdateStatement() {
|
||||
return new SQLUpdateStatement();
|
||||
|
||||
Reference in New Issue
Block a user