Search in sources :

Example 1 with PGOutputVisitor

use of com.alibaba.druid.sql.dialect.postgresql.visitor.PGOutputVisitor in project druid by alibaba.

the class PostgresqlResourceTest method mergValidate.

void mergValidate(String sql, String expect) {
    PGSQLStatementParser parser = new PGSQLStatementParser(sql);
    List<SQLStatement> statementList = parser.parseStatementList();
    SQLStatement statemen = statementList.get(0);
    Assert.assertEquals(1, statementList.size());
    StringBuilder out = new StringBuilder();
    PGOutputVisitor visitor = new PGOutputVisitor(out);
    statemen.accept(visitor);
    System.out.println(out.toString());
    Assert.assertEquals(expect, out.toString());
}
Also used : PGOutputVisitor(com.alibaba.druid.sql.dialect.postgresql.visitor.PGOutputVisitor) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement) PGSQLStatementParser(com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser)

Example 2 with PGOutputVisitor

use of com.alibaba.druid.sql.dialect.postgresql.visitor.PGOutputVisitor in project druid by alibaba.

the class PGTest method output.

protected String output(List<SQLStatement> stmtList) {
    StringBuilder out = new StringBuilder();
    PGOutputVisitor visitor = new PGOutputVisitor(out);
    for (SQLStatement stmt : stmtList) {
        stmt.accept(visitor);
    }
    return out.toString();
}
Also used : PGOutputVisitor(com.alibaba.druid.sql.dialect.postgresql.visitor.PGOutputVisitor) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Aggregations

SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)2 PGOutputVisitor (com.alibaba.druid.sql.dialect.postgresql.visitor.PGOutputVisitor)2 PGSQLStatementParser (com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser)1