mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
fix SQLColumnDefinition#getParent() is null, for issue #4492
This commit is contained in:
+1
-1
@@ -210,7 +210,7 @@ public class OdpsCreateTableParser extends SQLCreateTableParser {
|
||||
throw new ParserException("expect identifier. " + lexer.info());
|
||||
}
|
||||
|
||||
stmt.getTableElementList().add(column);
|
||||
stmt.addColumn(column);
|
||||
|
||||
if (lexer.isKeepComments() && lexer.hasComment()) {
|
||||
column.addAfterComment(lexer.readAndResetComments());
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.alibaba.druid.bvt.sql.odps.issues;
|
||||
|
||||
import com.alibaba.druid.DbType;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class Issue4992 {
|
||||
@Test
|
||||
public void testInsert() {
|
||||
String sql = "CREATE TABLE IF NOT EXISTS test_table \n" +
|
||||
"(\n" +
|
||||
" user_id STRING COMMENT\"userid\"\n" +
|
||||
" ,user_features STRING COMMENT\"用户特征\"\n" +
|
||||
")\n" +
|
||||
";";
|
||||
SQLCreateTableStatement stmt = (SQLCreateTableStatement) SQLUtils.parseSingleStatement(sql, DbType.odps);
|
||||
SQLColumnDefinition column = stmt.getColumn("user_id");
|
||||
assertNotNull(column);
|
||||
assertNotNull(column.getParent());
|
||||
assertSame(stmt, column.getParent());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user