コード例 #1
0
  public void testDeparser() throws JSQLParserException {
    String statement =
        "SELECT a.OWNERLASTNAME, a.OWNERFIRSTNAME "
            + "FROM ANTIQUEOWNERS AS a, ANTIQUES AS b "
            + "WHERE b.BUYERID = a.OWNERID AND b.ITEM = 'Chair'";
    Statement parsed = parserManager.parse(new StringReader(statement));
    StatementDeParser deParser = new StatementDeParser(new StringBuffer());
    parsed.accept(deParser);

    assertEquals(statement, deParser.getBuffer().toString());

    statement = "SELECT count(DISTINCT f + 4) FROM a";
    parsed = parserManager.parse(new StringReader(statement));
    deParser = new StatementDeParser(new StringBuffer());
    parsed.accept(deParser);
    assertEquals(statement, parsed.toString());
    assertEquals(statement, deParser.getBuffer().toString());

    statement = "SELECT count(DISTINCT f, g, h) FROM a";
    parsed = parserManager.parse(new StringReader(statement));
    deParser = new StatementDeParser(new StringBuffer());
    parsed.accept(deParser);
    assertEquals(statement, parsed.toString());
    assertEquals(statement, deParser.getBuffer().toString());
  }
コード例 #2
0
  public void testConcat() throws JSQLParserException {
    String statement = "SELECT a || b || c + 4 FROM t";
    Statement parsed = parserManager.parse(new StringReader(statement));
    StatementDeParser deParser = new StatementDeParser(new StringBuffer());
    parsed.accept(deParser);

    assertEquals(statement, parsed.toString());
    assertEquals(statement, deParser.getBuffer().toString());
  }
コード例 #3
0
  public void testMysqlQuote() throws JSQLParserException {
    String statement =
        "SELECT `a.OWNERLASTNAME`, `OWNERFIRSTNAME` "
            + "FROM `ANTIQUEOWNERS` AS a, ANTIQUES AS b "
            + "WHERE b.BUYERID = a.OWNERID AND b.ITEM = 'Chair'";
    Statement parsed = parserManager.parse(new StringReader(statement));
    StatementDeParser deParser = new StatementDeParser(new StringBuffer());
    parsed.accept(deParser);

    assertEquals(statement, parsed.toString());
    assertEquals(statement, deParser.getBuffer().toString());
  }