Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: use right compare result (#8886)

rebeliceb931b492b56b
diff --git a/backend/api/v1/schema_design_transformer.go b/backend/api/v1/schema_design_transformer.go
index 713a48136f..3b551d4981 100644
--- a/backend/api/v1/schema_design_transformer.go
+++ b/backend/api/v1/schema_design_transformer.go
@@ -249,7 +249,7 @@ func (t *tableState) toString(buf *strings.Builder) error {
}
if t.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" COMMENT='%s'", t.comment)); err != nil {
+ if _, err := buf.WriteString(fmt.Sprintf(" COMMENT '%s'", strings.ReplaceAll(t.comment, "'", "''"))); err != nil {
return err
}
}
@@ -615,7 +615,7 @@ func (t *mysqlTransformer) EnterCreateTableOption(ctx *mysql.CreateTableOptionCo
if ctx.COMMENT_SYMBOL() != nil {
commentString := ctx.TextStringLiteral().GetText()
- if len(commentString) < 2 {
+ if len(commentString) > 2 {
quotes := commentString[0]
escape := fmt.Sprintf("%c%c", quotes, quotes)
commentString = strings.ReplaceAll(commentString[1:len(commentString)-1], escape, string(quotes))
@@ -1095,7 +1095,7 @@ func (g *mysqlDesignSchemaGenerator) EnterCreateTableOption(ctx *mysql.CreateTab
if ctx.COMMENT_SYMBOL() != nil {
commentString := ctx.TextStringLiteral().GetText()
- if len(commentString) < 2 {
+ if len(commentString) > 2 {
quotes := commentString[0]
escape := fmt.Sprintf("%c%c", quotes, quotes)
commentString = strings.ReplaceAll(commentString[1:len(commentString)-1], escape, string(quotes))
diff --git a/backend/api/v1/testdata/schema.yaml b/backend/api/v1/testdata/schema.yaml
index cd7bcfc12b..85e5fce403 100644
--- a/backend/api/v1/testdata/schema.yaml
+++ b/backend/api/v1/testdata/schema.yaml
@@ -51,8 +51,8 @@
"visible": true
}
],
- "comment": "'this is comment with '' escaped'",
- "userComment": "'this is comment with '' escaped'",
+ "comment": "this is comment with ' escaped",
+ "userComment": "this is comment with ' escaped",
"foreignKeys": [
{
"name": "fk1",