mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
@@ -189,9 +189,11 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
|
||||
public SQLStatement parseInsert() {
|
||||
accept(Token.INSERT);
|
||||
|
||||
SQLInsertStatement insertStatement = new SQLInsertStatement();
|
||||
|
||||
if (lexer.token() == Token.INSERT) {
|
||||
accept(Token.INSERT);
|
||||
}
|
||||
|
||||
parseInsert0(insertStatement);
|
||||
return insertStatement;
|
||||
@@ -206,20 +208,22 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
|
||||
protected void parseInsert0(SQLInsertInto insertStatement, boolean acceptSubQuery) {
|
||||
accept(Token.INTO);
|
||||
|
||||
SQLName tableName = this.exprParser.name();
|
||||
insertStatement.setTableName(tableName);
|
||||
|
||||
if (lexer.token() == Token.LITERAL_ALIAS) {
|
||||
insertStatement.setAlias(as());
|
||||
}
|
||||
|
||||
parseInsert0_hinits(insertStatement);
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
insertStatement.setAlias(lexer.stringVal());
|
||||
if (lexer.token() == Token.INTO) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLName tableName = this.exprParser.name();
|
||||
insertStatement.setTableName(tableName);
|
||||
|
||||
if (lexer.token() == Token.LITERAL_ALIAS) {
|
||||
insertStatement.setAlias(as());
|
||||
}
|
||||
|
||||
parseInsert0_hinits(insertStatement);
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
insertStatement.setAlias(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.LPAREN)) {
|
||||
@@ -347,14 +351,14 @@ public class SQLStatementParser extends SQLParser {
|
||||
|
||||
public SQLUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
SQLUpdateStatement udpateStatement = new SQLUpdateStatement();
|
||||
|
||||
|
||||
if (lexer.token() == Token.UPDATE) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLTableSource tableSource = this.exprParser.createSelectParser().parseTableSource();
|
||||
udpateStatement.setTableSource(tableSource);
|
||||
}
|
||||
|
||||
|
||||
accept(Token.SET);
|
||||
|
||||
for (;;) {
|
||||
@@ -382,15 +386,18 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
|
||||
public SQLDeleteStatement parseDeleteStatement() throws ParserException {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == (Token.FROM)) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
SQLName tableName = exprParser.name();
|
||||
|
||||
SQLDeleteStatement deleteStatement = new SQLDeleteStatement();
|
||||
deleteStatement.setTableName(tableName);
|
||||
|
||||
if (lexer.token() == Token.DELETE) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == (Token.FROM)) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
SQLName tableName = exprParser.name();
|
||||
|
||||
deleteStatement.setTableName(tableName);
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.WHERE)) {
|
||||
lexer.nextToken();
|
||||
|
||||
Reference in New Issue
Block a user