improved sql parser.

This commit is contained in:
wenshao
2017-07-17 10:10:25 +08:00
parent 9e105a68f2
commit 5dac70deb0
20 changed files with 1510 additions and 69 deletions
@@ -23,6 +23,7 @@ import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
@@ -77,6 +78,10 @@ public class SQLCreateViewStatement extends SQLStatementImpl implements SQLDDLSt
this.setTableSource(new SQLExprTableSource(name));
}
public void setName(String name) {
this.setName(new SQLIdentifierExpr(name));
}
public SQLExprTableSource getTableSource() {
return tableSource;
}
@@ -20,6 +20,7 @@ import java.util.List;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLReplaceable;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLJoinTableSource extends SQLTableSourceImpl implements SQLReplaceable {
@@ -78,6 +79,26 @@ public class SQLJoinTableSource extends SQLTableSourceImpl implements SQLReplace
this.left = left;
}
public void setLeft(String tableName) {
SQLExprTableSource tableSource;
if (tableName == null || tableName.length() == 0) {
tableSource = null;
} else {
tableSource = new SQLExprTableSource(new SQLIdentifierExpr(tableName));
}
this.setLeft(tableSource);
}
public void setRight(String tableName) {
SQLExprTableSource tableSource;
if (tableName == null || tableName.length() == 0) {
tableSource = null;
} else {
tableSource = new SQLExprTableSource(new SQLIdentifierExpr(tableName));
}
this.setRight(tableSource);
}
public SQLTableSource getRight() {
return this.right;
}
@@ -162,6 +162,16 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
this.from = from;
}
public void setFrom(String tableName) {
SQLExprTableSource from;
if (tableName == null || tableName.length() == 0) {
from = null;
} else {
from = new SQLExprTableSource(new SQLIdentifierExpr(tableName));
}
this.setFrom(from);
}
public boolean isParenthesized() {
return parenthesized;
}