mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser. support show columns.
This commit is contained in:
@@ -417,4 +417,16 @@ public class SQLBinaryOpExpr extends SQLExprImpl implements SQLReplaceable, Seri
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean contains(SQLExpr item) {
|
||||
if (item instanceof SQLBinaryOpExpr) {
|
||||
if (this.equalsIgoreOrder((SQLBinaryOpExpr) item)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return left.equals(item) || right.equals(item);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.alibaba.druid.sql.ast.expr;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
|
||||
@@ -27,6 +28,8 @@ public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
|
||||
private transient String lowerName;
|
||||
private transient Boolean parameter;
|
||||
|
||||
private transient SQLColumnDefinition resolvedColumn;
|
||||
|
||||
public SQLIdentifierExpr(){
|
||||
|
||||
}
|
||||
@@ -136,4 +139,12 @@ public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
|
||||
public String normalizedName() {
|
||||
return SQLUtils.normalize(name);
|
||||
}
|
||||
|
||||
public SQLColumnDefinition getResolvedColumn() {
|
||||
return resolvedColumn;
|
||||
}
|
||||
|
||||
public void setResolvedColumn(SQLColumnDefinition resolvedColumn) {
|
||||
this.resolvedColumn = resolvedColumn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
@@ -27,6 +28,8 @@ public class SQLPropertyExpr extends SQLExprImpl implements SQLName {
|
||||
private SQLExpr owner;
|
||||
private String name;
|
||||
|
||||
private transient SQLColumnDefinition resolvedColumn;
|
||||
|
||||
public SQLPropertyExpr(String owner, String name){
|
||||
this(new SQLIdentifierExpr(owner), name);
|
||||
}
|
||||
@@ -153,4 +156,12 @@ public class SQLPropertyExpr extends SQLExprImpl implements SQLName {
|
||||
|
||||
return ownerName + '.' + SQLUtils.normalize(name);
|
||||
}
|
||||
|
||||
public SQLColumnDefinition getResolvedColumn() {
|
||||
return resolvedColumn;
|
||||
}
|
||||
|
||||
public void setResolvedColumn(SQLColumnDefinition resolvedColumn) {
|
||||
this.resolvedColumn = resolvedColumn;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user