use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor in project druid by alibaba.
the class CreateUserTest method test_0.
public void test_0() throws Exception {
String sql = "CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
// print(statementList);
Assert.assertEquals(1, statementList.size());
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
statemen.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
Assert.assertTrue(visitor.getTables().size() == 0);
}
use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor in project druid by alibaba.
the class CommitTest method test_0.
public void test_0() throws Exception {
String sql = "COMMIT;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
// print(statementList);
Assert.assertEquals(1, statementList.size());
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
statemen.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
Assert.assertTrue(visitor.getTables().size() == 0);
}
use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor in project druid by alibaba.
the class DropTableTest method test_0.
public void test_0() throws Exception {
String sql = "DROP TABLE films, distributors;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
// print(statementList);
Assert.assertEquals(1, statementList.size());
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
statemen.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("films")));
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("distributors")));
Assert.assertTrue(visitor.getTables().get(new TableStat.Name("films")).getDropCount() == 1);
Assert.assertTrue(visitor.getTables().get(new TableStat.Name("distributors")).getDropCount() == 1);
Assert.assertTrue(visitor.getColumns().size() == 0);
}
use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor in project druid by alibaba.
the class DropUserTest method test_0.
public void test_0() throws Exception {
String sql = "DROP USER 'jeffrey'@'localhost';";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
// print(statementList);
Assert.assertEquals(1, statementList.size());
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
statemen.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
Assert.assertTrue(visitor.getTables().size() == 0);
}
use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor in project druid by alibaba.
the class MySqlAnalyzeTest_1 method test_0.
public void test_0() throws Exception {
String sql = "ANALYZE TABLE t1,t2";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
// print(statementList);
Assert.assertEquals(1, statementList.size());
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
stmt.accept(visitor);
String output = SQLUtils.toMySqlString(stmt);
//
Assert.assertEquals(//
"ANALYZE TABLE t1, t2", output);
// 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(2, visitor.getTables().size());
Assert.assertEquals(0, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
// Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("City")));
// Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("t2")));
// Assert.assertTrue(visitor.getColumns().contains(new Column("t2", "id")));
}
Aggregations