mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sql parser refactor
This commit is contained in:
@@ -449,7 +449,7 @@ public class SQLExprParser extends SQLParser {
|
||||
}
|
||||
|
||||
public SQLSelectParser createSelectParser() {
|
||||
return new SQLSelectParser(lexer);
|
||||
return new SQLSelectParser(this);
|
||||
}
|
||||
|
||||
public SQLExpr primaryRest(SQLExpr expr) throws ParserException {
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.alibaba.druid.sql.ast.statement.SQLUnionOperator;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLUnionQuery;
|
||||
|
||||
public class SQLSelectParser extends SQLParser {
|
||||
protected SQLExprParser exprParser;
|
||||
|
||||
public SQLSelectParser(String sql){
|
||||
super(sql);
|
||||
@@ -39,6 +40,11 @@ public class SQLSelectParser extends SQLParser {
|
||||
public SQLSelectParser(Lexer lexer){
|
||||
super(lexer);
|
||||
}
|
||||
|
||||
public SQLSelectParser(SQLExprParser exprParser){
|
||||
super(exprParser.getLexer());
|
||||
this.exprParser = exprParser;
|
||||
}
|
||||
|
||||
public SQLSelect select() throws ParserException {
|
||||
SQLSelect select = new SQLSelect();
|
||||
|
||||
@@ -484,7 +484,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
|
||||
public SQLSelectParser createSQLSelectParser() {
|
||||
return new SQLSelectParser(this.lexer);
|
||||
return new SQLSelectParser(this.exprParser);
|
||||
}
|
||||
|
||||
public SQLUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
@@ -573,7 +573,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
|
||||
this.accept(Token.AS);
|
||||
|
||||
createView.setSubQuery(new SQLSelectParser(this.lexer).select());
|
||||
createView.setSubQuery(new SQLSelectParser(this.exprParser).select());
|
||||
return createView;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user