File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -208,15 +208,19 @@ func (c Column) pkDefinition(isPrev bool) (string, bool) {
208
208
if sql .IsSqlite () {
209
209
// SQLite overrides, that pingcap doesn't support
210
210
if opt .Tp == ast .ColumnOptionDefaultValue {
211
+ // Parsed StrValue may be quoted in single quotes, which breaks SQL expression.
212
+ // We need to unquote it and, if it's a TEXT column. quote it again with double quotes.
211
213
expression , err := strconv .Unquote (opt .StrValue )
212
214
if err != nil {
213
215
expression = opt .StrValue
214
216
}
215
217
if len (expression ) >= 2 && expression [0 ] == '\'' && expression [len (expression )- 1 ] == '\'' {
216
218
// remove single quotes. strconv may not detect it
217
- expression = strconv .Quote (expression [1 : len (expression )- 1 ])
219
+ expression = expression [1 : len (expression )- 1 ]
220
+ }
221
+ if c .typeDefinition (isPrev ) == "TEXT" {
222
+ expression = strconv .Quote (expression )
218
223
}
219
-
220
224
strSql += " DEFAULT " + expression
221
225
continue
222
226
}
You can’t perform that action at this time.
0 commit comments