use of com.alibaba.druid.sql.dialect.db2.parser.DB2StatementParser in project druid by alibaba.
the class DB2TruncateTest method test_0.
public void test_0() throws Exception {
String sql = "TRUNCATE TASK_AICSFSM_QUERY_BATCH_TEMP IMMEDIATE";
DB2StatementParser parser = new DB2StatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
DB2SchemaStatVisitor visitor = new DB2SchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("TASK_AICSFSM_QUERY_BATCH_TEMP")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("A", "F_0201")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "first_name")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "full_name")));
//
Assert.assertEquals(//
"TRUNCATE TABLE TASK_AICSFSM_QUERY_BATCH_TEMP IMMEDIATE", SQLUtils.toSQLString(stmt, JdbcConstants.DB2));
//
Assert.assertEquals(//
"truncate table TASK_AICSFSM_QUERY_BATCH_TEMP immediate", SQLUtils.toSQLString(stmt, JdbcConstants.DB2, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
}
use of com.alibaba.druid.sql.dialect.db2.parser.DB2StatementParser in project druid by alibaba.
the class DB2TruncateTest2 method test_0.
public void test_0() throws Exception {
String sql = "TRUNCATE TABLE INVENTORY IGNORE DELETE TRIGGERS DROP STORAGE IMMEDIATE";
DB2StatementParser parser = new DB2StatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
DB2SchemaStatVisitor visitor = new DB2SchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("INVENTORY")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("A", "F_0201")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "first_name")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "full_name")));
//
Assert.assertEquals(//
"TRUNCATE TABLE INVENTORY DROP STORAGE IGNORE DELETE TRIGGERS IMMEDIATE", SQLUtils.toSQLString(stmt, JdbcConstants.DB2));
//
Assert.assertEquals(//
"truncate table INVENTORY drop storage ignore delete triggers immediate", SQLUtils.toSQLString(stmt, JdbcConstants.DB2, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
}
use of com.alibaba.druid.sql.dialect.db2.parser.DB2StatementParser in project druid by alibaba.
the class DB2TruncateTest3 method test_0.
public void test_0() throws Exception {
String sql = "TRUNCATE TABLE INVENTORY REUSE STORAGE RESTRICT WHEN DELETE TRIGGERS";
DB2StatementParser parser = new DB2StatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
DB2SchemaStatVisitor visitor = new DB2SchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("INVENTORY")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("A", "F_0201")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "first_name")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "full_name")));
//
Assert.assertEquals(//
"TRUNCATE TABLE INVENTORY REUSE STORAGE RESTRICT WHEN DELETE TRIGGERS", SQLUtils.toSQLString(stmt, JdbcConstants.DB2));
//
Assert.assertEquals(//
"truncate table INVENTORY reuse storage restrict when delete triggers", SQLUtils.toSQLString(stmt, JdbcConstants.DB2, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
}
use of com.alibaba.druid.sql.dialect.db2.parser.DB2StatementParser in project druid by alibaba.
the class DB2TruncateTest4 method test_0.
public void test_0() throws Exception {
String sql = "TRUNCATE TABLE INVENTORY REUSE STORAGE IGNORE DELETE TRIGGERS IMMEDIATE";
DB2StatementParser parser = new DB2StatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
DB2SchemaStatVisitor visitor = new DB2SchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("INVENTORY")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("A", "F_0201")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "first_name")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "full_name")));
//
Assert.assertEquals(//
"TRUNCATE TABLE INVENTORY REUSE STORAGE IGNORE DELETE TRIGGERS IMMEDIATE", SQLUtils.toSQLString(stmt, JdbcConstants.DB2));
//
Assert.assertEquals(//
"truncate table INVENTORY reuse storage ignore delete triggers immediate", SQLUtils.toSQLString(stmt, JdbcConstants.DB2, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
}
use of com.alibaba.druid.sql.dialect.db2.parser.DB2StatementParser in project druid by alibaba.
the class DB2Values_Test method test_0.
public void test_0() throws Exception {
String sql = "values 1";
DB2StatementParser parser = new DB2StatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
DB2SchemaStatVisitor visitor = new DB2SchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(0, visitor.getTables().size());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
// Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("t")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("t", "*")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "first_name")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "full_name")));
String output = SQLUtils.toSQLString(stmt, JdbcConstants.DB2);
//
Assert.assertEquals(//
"VALUES 1", output);
}
Aggregations