Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ public String toSql(boolean isUniqueTable, boolean isCompatible) {
if (defaultValueExprDef != null) {
sb.append(" DEFAULT ").append(defaultValue).append("");
} else {
sb.append(" DEFAULT \"").append(defaultValue).append("\"");
sb.append(" DEFAULT \"").append(SqlUtils.escapeQuota(defaultValue)).append("\"");
}
}
if (getDataType() == PrimitiveType.BITMAP && defaultValue != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ protected void runBeforeAll() throws Exception {
createDatabase("test");
useDatabase("test");
createTable("create table table1\n"
+ "(k1 int comment 'test column k1', k2 int comment 'test column k2', `timestamp` DATE NOT NULL COMMENT '[''0000-01-01'', ''9999-12-31'']') comment 'test table1' "
+ "(`k1` int comment 'test column k1', "
+ "`k2` int comment 'test column k2', "
+ "`k3` varchar NOT NULL DEFAULT \"xxx\\\"xxx\\\"\", "
+ "`timestamp` DATE NOT NULL COMMENT '[''0000-01-01'', ''9999-12-31'']')\n"
+ "comment 'test table1'"
+ "PARTITION BY RANGE(`k1`)\n"
+ "(\n"
+ " PARTITION `p01` VALUES LESS THAN (\"10\"),\n"
Expand Down Expand Up @@ -62,6 +66,14 @@ public void testColumnComment() throws Exception {
Assertions.assertTrue(showSql.contains("`timestamp` date NOT NULL COMMENT \"['0000-01-01', '9999-12-31']\""));
}

@Test
public void testColumnDefault() throws Exception {
String sql = "show create table table1";
ShowResultSet showResultSet = showCreateTable(sql);
String showSql = showResultSet.getResultRows().get(0).get(1);
Assertions.assertTrue(showSql.contains("`k3` varchar(65533) NOT NULL DEFAULT \"xxx\\\"xxx\\\"\""));
}

@Test
public void testBrief() throws Exception {
String sql = "show brief create table table1";
Expand Down