fix: postgresql comments single quote problem

This commit is contained in:
zhuyasen
2025-07-17 22:40:42 +08:00
parent 8ba6395902
commit d10700480c

View File

@@ -34,7 +34,8 @@ func ConvertToSQLByPgFields(tableName string, fields PGFields) (string, map[stri
if !field.Notnull {
notnullStr = "null"
}
fieldStr += fmt.Sprintf(" `%s` %s %s comment '%s',\n", field.Name, sqlType, notnullStr, field.Comment)
comment := strings.ReplaceAll(field.Comment, "'", "\\'")
fieldStr += fmt.Sprintf(" `%s` %s %s comment '%s',\n", field.Name, sqlType, notnullStr, comment)
}
primaryField := fields.getPrimaryField()