use of com.alibaba.druid.stat.TableStat.Column in project druid by alibaba.
the class MySqlCreateProcedureTest6 method test_3.
public void test_3() throws Exception {
String sql = "create or replace procedure sp_name(inout level int,inout age int)" + " begin" + " insert into test values(id,age);" + " end";
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());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(2, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("test")));
Assert.assertTrue(visitor.getColumns().contains(new Column("test", "id")));
Assert.assertTrue(visitor.getColumns().contains(new Column("test", "age")));
}
use of com.alibaba.druid.stat.TableStat.Column in project druid by alibaba.
the class MySqlCreateProcedureTest6 method test_0.
public void test_0() throws Exception {
String sql = "create or replace procedure sp_name(level int,age int)" + " begin" + " insert into test values(id,age);" + " end";
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());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(2, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("test")));
Assert.assertTrue(visitor.getColumns().contains(new Column("test", "id")));
Assert.assertTrue(visitor.getColumns().contains(new Column("test", "age")));
}
use of com.alibaba.druid.stat.TableStat.Column in project druid by alibaba.
the class MySqlCreateTableTest10 method test_0.
public void test_0() throws Exception {
String sql = //
"create table TACCOUNT (" + //
" ID varchar(36) not null," + //
" ACCOUNT varchar(100) not null," + //
" account_money double precision," + //
" NAME varchar(100) not null," + //
" TYPE integer," + //
" primary key (ID)" + " )";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLCreateTableStatement stmt = (SQLCreateTableStatement) statementList.get(0);
// print(statementList);
Assert.assertEquals(1, statementList.size());
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
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(5, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("TACCOUNT")));
Assert.assertTrue(visitor.getColumns().contains(new Column("TACCOUNT", "ID")));
Assert.assertTrue(visitor.getColumns().contains(new Column("TACCOUNT", "ACCOUNT")));
Assert.assertTrue(visitor.getColumns().contains(new Column("TACCOUNT", "account_money")));
Assert.assertTrue(visitor.getColumns().contains(new Column("TACCOUNT", "NAME")));
Assert.assertTrue(visitor.getColumns().contains(new Column("TACCOUNT", "TYPE")));
}
use of com.alibaba.druid.stat.TableStat.Column in project druid by alibaba.
the class MySqlCreateTableTest12 method test_0.
public void test_0() throws Exception {
String sql = "CREATE TABLE 'test' ('blob_col' BLOB, INDEX(blob_col(10)));";
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());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(1, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("test")));
Assert.assertTrue(visitor.getColumns().contains(new Column("test", "blob_col")));
}
use of com.alibaba.druid.stat.TableStat.Column in project druid by alibaba.
the class MySqlCreateTableTest13 method test_0.
public void test_0() throws Exception {
String sql = //
"CREATE TABLE `xx_video` (" + //
"`id` int(11) NOT NULL AUTO_INCREMENT," + //
"`video_url` varchar(500) DEFAULT NULL," + //
"`video_title` varchar(200) DEFAULT NULL," + //
"`video_des` varchar(500) DEFAULT NULL," + //
"`video_type` varchar(11) NOT NULL," + //
"`delete_flag` int(11) DEFAULT '0'," + //
"`create_date` datetime DEFAULT NULL," + //
"`last_update` datetime DEFAULT NULL," + //
"PRIMARY KEY (`id`)" + ") ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=gbk;";
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());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(8, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("xx_video")));
Assert.assertTrue(visitor.getColumns().contains(new Column("xx_video", "id")));
Assert.assertTrue(visitor.getColumns().contains(new Column("xx_video", "video_url")));
}
Aggregations