diff --git a/src/test/java/com/alibaba/druid/bvt/sql/mysql/issues/Issue4444.java b/src/test/java/com/alibaba/druid/bvt/sql/mysql/issues/Issue4444.java index e35e1096ab..b2c2d0af8f 100644 --- a/src/test/java/com/alibaba/druid/bvt/sql/mysql/issues/Issue4444.java +++ b/src/test/java/com/alibaba/druid/bvt/sql/mysql/issues/Issue4444.java @@ -1,8 +1,13 @@ package com.alibaba.druid.bvt.sql.mysql.issues; +import com.alibaba.druid.DbType; +import com.alibaba.druid.sql.SQLUtils; import com.alibaba.druid.sql.ast.SQLStatement; import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser; import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor; +import com.alibaba.druid.sql.parser.SQLParserUtils; +import com.alibaba.druid.sql.parser.SQLStatementParser; +import com.alibaba.druid.sql.visitor.SchemaStatVisitor; import com.alibaba.druid.stat.TableStat; import org.junit.Test; @@ -12,12 +17,14 @@ import static org.junit.Assert.assertFalse; public class Issue4444 { + protected final DbType dbType = DbType.mysql; + @Test public void test_idle2() throws Exception { String sql = "create role 'role1'"; - MySqlStatementParser parser = new MySqlStatementParser(sql); + SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType); SQLStatement statement = parser.parseStatement(); - MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor(); + SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(dbType); statement.accept(visitor); assertEquals("CREATE ROLE 'role1'", statement.toString()); } diff --git a/src/test/java/com/alibaba/druid/bvt/sql/mysql/issues/Issue4454.java b/src/test/java/com/alibaba/druid/bvt/sql/mysql/issues/Issue4454.java index 8426e283b4..030fcb12ba 100644 --- a/src/test/java/com/alibaba/druid/bvt/sql/mysql/issues/Issue4454.java +++ b/src/test/java/com/alibaba/druid/bvt/sql/mysql/issues/Issue4454.java @@ -1,8 +1,13 @@ package com.alibaba.druid.bvt.sql.mysql.issues; +import com.alibaba.druid.DbType; +import com.alibaba.druid.sql.SQLUtils; import com.alibaba.druid.sql.ast.SQLStatement; import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser; import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor; +import com.alibaba.druid.sql.parser.SQLParserUtils; +import com.alibaba.druid.sql.parser.SQLStatementParser; +import com.alibaba.druid.sql.visitor.SchemaStatVisitor; import com.alibaba.druid.stat.TableStat; import org.junit.Test; @@ -12,6 +17,8 @@ import static org.junit.Assert.assertFalse; public class Issue4454 { + protected final DbType dbType = DbType.mysql; + @Test public void test_idle2() throws Exception { String sql = "CREATE TABLE `test_trigger` (\n" + @@ -19,10 +26,11 @@ public void test_idle2() throws Exception { " `test` int(11) signed NOT NULL DEFAULT '0' COMMENT 'trigger test',\n" + " PRIMARY KEY (`id`)\n" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; - MySqlStatementParser parser = new MySqlStatementParser(sql); - SQLStatement statement = parser.parseStatement(); - MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor(); - statement.accept(visitor); + SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType); + SQLStatement stmt = parser.parseStatement(); + SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(dbType); + + stmt.accept(visitor); Map tableMap = visitor.getTables(); assertFalse(tableMap.isEmpty()); }