use of com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser in project druid by alibaba.
the class PGSelectTest37 method test_0.
public void test_0() throws Exception {
String sql = "select date '2001-09-28'";
PGSQLStatementParser parser = new PGSQLStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
Assert.assertEquals("SELECT DATE '2001-09-28'", SQLUtils.toPGString(stmt));
Assert.assertEquals("select date '2001-09-28'", SQLUtils.toPGString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
Assert.assertEquals(1, statementList.size());
PGSchemaStatVisitor visitor = new PGSchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getTables().size());
}
use of com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser in project druid by alibaba.
the class PGSelectTest38 method test_0.
public void test_0() throws Exception {
String sql = "select '{1,2,3}'::int[] && '{1,2,3}'::int[]";
PGSQLStatementParser parser = new PGSQLStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
Assert.assertEquals("SELECT '{1,2,3}'::int[] && '{1,2,3}'::int[]", SQLUtils.toPGString(stmt));
Assert.assertEquals("select '{1,2,3}'::int[] && '{1,2,3}'::int[]", SQLUtils.toPGString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
Assert.assertEquals(1, statementList.size());
PGSchemaStatVisitor visitor = new PGSchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getTables().size());
}
use of com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser in project druid by alibaba.
the class PGSelectTest39 method test_0.
public void test_0() throws Exception {
String sql = "select '{1,2,3}'::int[] @> '{1,2,3}'::int[]";
PGSQLStatementParser parser = new PGSQLStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
Assert.assertEquals("SELECT '{1,2,3}'::int[] @> '{1,2,3}'::int[]", SQLUtils.toPGString(stmt));
Assert.assertEquals("select '{1,2,3}'::int[] @> '{1,2,3}'::int[]", SQLUtils.toPGString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
Assert.assertEquals(1, statementList.size());
PGSchemaStatVisitor visitor = new PGSchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getTables().size());
}
use of com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser in project druid by alibaba.
the class PGSelectTest4 method test_0.
public void test_0() throws Exception {
String sql = "select offerId, offerIds " + //
"from cnres.function_select_get_p4p_offer_by_sps('\\'1160160508\\',\\'1085432755\\',\\'971765217\\'') " + //
" as a( offerId character varying(256), offerIds character varying(4000) )";
PGSQLStatementParser parser = new PGSQLStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
// print(statementList);
Assert.assertEquals(1, statementList.size());
PGSchemaStatVisitor visitor = new PGSchemaStatVisitor();
statemen.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
Assert.assertEquals(2, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getTables().size());
}
use of com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser in project druid by alibaba.
the class PGSelectTest40 method test_0.
public void test_0() throws Exception {
String sql = "select '{1,2,3}'::int[] <@ '{1,2,3}'::int[]";
PGSQLStatementParser parser = new PGSQLStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
Assert.assertEquals("SELECT '{1,2,3}'::int[] <@ '{1,2,3}'::int[]", SQLUtils.toPGString(stmt));
Assert.assertEquals("select '{1,2,3}'::int[] <@ '{1,2,3}'::int[]", SQLUtils.toPGString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
Assert.assertEquals(1, statementList.size());
PGSchemaStatVisitor visitor = new PGSchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getTables().size());
}
Aggregations