mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor sql parser about the desc and explain parts of the code
This commit is contained in:
@@ -11,8 +11,7 @@ public class Issue1645 extends TestCase {
|
||||
public void test_for_issue() throws Exception {
|
||||
String sql = "explain extended select * from foo";
|
||||
String formatedSql = SQLUtils.format(sql, JdbcConstants.MYSQL);
|
||||
assertEquals("EXPLAIN extended\n" +
|
||||
"SELECT *\n" +
|
||||
assertEquals("EXPLAIN extended SELECT *\n" +
|
||||
"FROM foo", formatedSql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package com.alibaba.druid.bvt.sql.cobar;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlExplainStatement;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -81,7 +82,7 @@ public class DALParserTest extends TestCase {
|
||||
public void testdesc() throws Exception {
|
||||
String sql = "desc tb1";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
MySqlExplainStatement desc = parser.parseDescribe();
|
||||
SQLStatement desc = parser.parseDescribe();
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(desc);
|
||||
Assert.assertEquals("DESC tb1", output);
|
||||
@@ -90,7 +91,7 @@ public class DALParserTest extends TestCase {
|
||||
public void testdesc_1() throws Exception {
|
||||
String sql = "desc db.tb1";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
MySqlExplainStatement desc = parser.parseDescribe();
|
||||
SQLStatement desc = parser.parseDescribe();
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(desc);
|
||||
Assert.assertEquals("DESC db.tb1", output);
|
||||
|
||||
Reference in New Issue
Block a user