mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -183,7 +183,6 @@ public class SQLSelect extends SQLObjectImpl {
|
||||
|
||||
public boolean isSimple() {
|
||||
return withSubQuery == null
|
||||
&& orderBy == null
|
||||
&& (hints == null || hints.size() == 0)
|
||||
&& restriction == null
|
||||
&& (!forBrowse)
|
||||
|
||||
@@ -272,6 +272,9 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
acceptChild(visitor, this.startWith);
|
||||
acceptChild(visitor, this.connectBy);
|
||||
acceptChild(visitor, this.groupBy);
|
||||
acceptChild(visitor, this.orderBy);
|
||||
acceptChild(visitor, this.waitTime);
|
||||
acceptChild(visitor, this.limit);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
@@ -386,4 +389,30 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
public void setBracket(boolean bracket) {
|
||||
this.bracket = bracket;
|
||||
}
|
||||
|
||||
public SQLTableSource findTableSource(String alias) {
|
||||
return findTableSource(from, alias);
|
||||
}
|
||||
|
||||
private static SQLTableSource findTableSource(SQLTableSource from, String alias) {
|
||||
if (from == null || alias == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (alias.equalsIgnoreCase(from.computeAlias())) {
|
||||
return from;
|
||||
}
|
||||
|
||||
if (from instanceof SQLJoinTableSource) {
|
||||
SQLJoinTableSource join = (SQLJoinTableSource) from;
|
||||
SQLTableSource result = findTableSource(join.getLeft(), alias);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return findTableSource(join.getRight(), alias);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user