Fix bug: Parse "national" keywords in DataType #3561

This commit is contained in:
Dagon0577
2020-05-14 11:58:05 +08:00
parent f95f1c6436
commit 99e6bdf34d
3 changed files with 53 additions and 0 deletions
@@ -0,0 +1,41 @@
package com.alibaba.druid.bvt.sql.mysql.createTable;
import com.alibaba.druid.sql.MysqlTest;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement;
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
import java.util.List;
/**
* @author Dagon0577
* @date 2020/5/14 10:51
*/
public class MySqlCreateTableTest135 extends MysqlTest {
public void test_0() throws Exception {
String sql =
"create table MQ_TOPIC_RECORD(\n"
+ " TOPIC_ID bigint(11) not null,\n"
+ " BROKENNAME national VARCHAR(50),\n"
+ " BROKENNAME2 national CHAR(50)\n" + ");";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
MySqlCreateTableStatement stmt = (MySqlCreateTableStatement) statementList.get(0);
assertEquals(1, statementList.size());
assertEquals("CREATE TABLE MQ_TOPIC_RECORD (\n"
+ "\tTOPIC_ID bigint(11) NOT NULL,\n"
+ "\tBROKENNAME nvarchar(50),\n"
+ "\tBROKENNAME2 nchar(50)\n"
+ ");", stmt.toString());
assertEquals("create table MQ_TOPIC_RECORD (\n"
+ "\tTOPIC_ID bigint(11) not null,\n"
+ "\tBROKENNAME nvarchar(50),\n"
+ "\tBROKENNAME2 nchar(50)\n" + ");", stmt.toLowerCaseString());
}
}