Skip to content

Commit d107004

Browse files
committed
fix: postgresql comments single quote problem
1 parent 8ba6395 commit d107004

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/sql2code/parser/postgresql.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func ConvertToSQLByPgFields(tableName string, fields PGFields) (string, map[stri
3434
if !field.Notnull {
3535
notnullStr = "null"
3636
}
37-
fieldStr += fmt.Sprintf(" `%s` %s %s comment '%s',\n", field.Name, sqlType, notnullStr, field.Comment)
37+
comment := strings.ReplaceAll(field.Comment, "'", "\\'")
38+
fieldStr += fmt.Sprintf(" `%s` %s %s comment '%s',\n", field.Name, sqlType, notnullStr, comment)
3839
}
3940

4041
primaryField := fields.getPrimaryField()

0 commit comments

Comments
 (0)