use of io.mycat.route.parser.druid.MycatSchemaStatVisitor in project Mycat-Server by MyCATApache.
the class MycatSchemaStatVisitorTest method getConditionList.
private List<List<Condition>> getConditionList(String sql) {
SQLStatementParser parser = null;
parser = new MySqlStatementParser(sql);
MycatSchemaStatVisitor visitor = null;
SQLStatement statement = null;
//解析出现问题统一抛SQL语法错误
try {
statement = parser.parseStatement();
visitor = new MycatSchemaStatVisitor();
} catch (Exception e) {
e.printStackTrace();
}
statement.accept(visitor);
List<List<Condition>> mergedConditionList = new ArrayList<List<Condition>>();
if (visitor.hasOrCondition()) {
//包含or语句
//TODO
//根据or拆分
mergedConditionList = visitor.splitConditions();
} else {
//不包含OR语句
mergedConditionList.add(visitor.getConditions());
}
return mergedConditionList;
}
Aggregations