Search in sources :

Example 1 with OrParser

use of com.dangdang.ddframe.rdb.sharding.parser.visitor.or.OrParser in project sharding-jdbc by dangdangdotcom.

the class SQLParseEngine method parse.

/**
     *  解析SQL.
     * 
     * @return SQL解析结果
     */
public SQLParsedResult parse() {
    Preconditions.checkArgument(visitor instanceof SQLVisitor);
    SQLVisitor sqlVisitor = (SQLVisitor) visitor;
    visitor.setParameters(parameters);
    sqlVisitor.getParseContext().setShardingRule(shardingRule);
    sqlStatement.accept(visitor);
    SQLParsedResult result = sqlVisitor.getParseContext().getParsedResult();
    if (sqlVisitor.getParseContext().isHasOrCondition()) {
        new OrParser(sqlStatement, visitor).fillConditionContext(result);
    }
    sqlVisitor.getParseContext().mergeCurrentConditionContext();
    log.debug("Parsed SQL result: {}", result);
    log.debug("Parsed SQL: {}", sqlVisitor.getSQLBuilder());
    result.getRouteContext().setSqlBuilder(sqlVisitor.getSQLBuilder());
    result.getRouteContext().setSqlStatementType(getType());
    return result;
}
Also used : SQLParsedResult(com.dangdang.ddframe.rdb.sharding.parser.result.SQLParsedResult) OrParser(com.dangdang.ddframe.rdb.sharding.parser.visitor.or.OrParser) SQLVisitor(com.dangdang.ddframe.rdb.sharding.parser.visitor.SQLVisitor)

Aggregations

SQLParsedResult (com.dangdang.ddframe.rdb.sharding.parser.result.SQLParsedResult)1 SQLVisitor (com.dangdang.ddframe.rdb.sharding.parser.visitor.SQLVisitor)1 OrParser (com.dangdang.ddframe.rdb.sharding.parser.visitor.or.OrParser)1