mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for sql parser.
This commit is contained in:
@@ -36,12 +36,22 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
||||
* Created by wenshao on 03/06/2017.
|
||||
*/
|
||||
public class SchemaRepository {
|
||||
private String name;
|
||||
|
||||
private final Map<String, SchemaObject> objects = new ConcurrentSkipListMap<String, SchemaObject>();
|
||||
|
||||
private final Map<String, SchemaObject> functions = new ConcurrentSkipListMap<String, SchemaObject>();
|
||||
|
||||
private final SchemaVisitor visitor = new SchemaVisitor();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public SchemaObject findTable(String tableName) {
|
||||
String lowerName = tableName.toLowerCase();
|
||||
SchemaObject object = objects.get(lowerName);
|
||||
@@ -144,6 +154,16 @@ public class SchemaRepository {
|
||||
}
|
||||
return tableObject;
|
||||
}
|
||||
|
||||
if (expr instanceof SQLPropertyExpr) {
|
||||
String tableName = ((SQLPropertyExpr) expr).getName();
|
||||
|
||||
tableObject = findTable(tableName);
|
||||
if (tableObject != null) {
|
||||
exprTableSource.setSchemaObject(tableObject);
|
||||
}
|
||||
return tableObject;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -222,6 +242,16 @@ public class SchemaRepository {
|
||||
if (tableSource instanceof SQLExprTableSource) {
|
||||
return findTable(tableSource, tableSource.computeAlias());
|
||||
}
|
||||
|
||||
if (tableSource instanceof SQLJoinTableSource) {
|
||||
SQLJoinTableSource join = (SQLJoinTableSource) tableSource;
|
||||
|
||||
SchemaObject table = findTable(join.getLeft(), expr);
|
||||
if (table == null) {
|
||||
table = findTable(join.getRight(), expr);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user