Ejemplo n.º 1
0
  @Override
  public boolean visit(PGSelectStatement x) {
    if (x.getWith() != null) {
      x.getWith().accept(this);
      println();
    }

    return visit((SQLSelectStatement) x);
  }
Ejemplo n.º 2
0
  public void test_1() throws Exception {
    String sql = "(select * from a) union select * from b";
    PGSQLStatementParser parser = new PGSQLStatementParser(sql);
    List<SQLStatement> statementList = parser.parseStatementList();
    SQLStatement statemen = statementList.get(0);
    //         print(statementList);

    Assert.assertEquals(1, statementList.size());
    assertTrue(statemen instanceof PGSelectStatement);
    PGSelectStatement select = (PGSelectStatement) statemen;
    assertTrue(select.getSelect().getQuery() instanceof SQLUnionQuery);
    SQLUnionQuery unionQuery = (SQLUnionQuery) select.getSelect().getQuery();
    assertTrue(unionQuery.getLeft() instanceof SQLSelectQueryBlock);
    assertTrue(unionQuery.getRight() instanceof SQLSelectQueryBlock);
    SQLSelectQueryBlock leftQueryBlock = (SQLSelectQueryBlock) unionQuery.getLeft();
    assertTrue(leftQueryBlock.isParenthesized());
  }