Skip to content

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

fix: add space in default and comment (#8690)

zll6005c5b35f91ebc
diff --git a/backend/api/v1/schema_design_transformer_tidb.go b/backend/api/v1/schema_design_transformer_tidb.go
index 50b5617a9b..fe2ac8cd4f 100644
--- a/backend/api/v1/schema_design_transformer_tidb.go
+++ b/backend/api/v1/schema_design_transformer_tidb.go
@@ -493,11 +493,11 @@ func (g *tidbDesignSchemaGenerator) Enter(in tidbast.Node) (tidbast.Node, bool)
}
}
} else if stateColumn.defaultValue != nil {
- if _, err := g.columnDefine.WriteString("DEFAULT"); err != nil {
+ if _, err := g.columnDefine.WriteString(" DEFAUL"); err != nil {
g.err = err
return in, true
}
- if _, err := g.columnDefine.WriteString(*stateColumn.defaultValue); err != nil {
+ if _, err := g.columnDefine.WriteString(" " + *stateColumn.defaultValue); err != nil {
g.err = err
return in, true
}
@@ -516,11 +516,11 @@ func (g *tidbDesignSchemaGenerator) Enter(in tidbast.Node) (tidbast.Node, bool)
}
}
} else if stateColumn.comment != "" {
- if _, err := g.columnDefine.WriteString("COMMENT" + " "); err != nil {
+ if _, err := g.columnDefine.WriteString(" COMMENT"); err != nil {
g.err = err
return in, true
}
- if _, err := g.columnDefine.WriteString(fmt.Sprintf("'%s'", stateColumn.comment)); err != nil {
+ if _, err := g.columnDefine.WriteString(fmt.Sprintf(" '%s'", stateColumn.comment)); err != nil {
g.err = err
return in, true
}
diff --git a/backend/api/v1/testdata/tidb/design.yaml b/backend/api/v1/testdata/tidb/design.yaml
index 1ca318a6a0..3bde3d24ae 100644
--- a/backend/api/v1/testdata/tidb/design.yaml
+++ b/backend/api/v1/testdata/tidb/design.yaml
@@ -23,215 +23,239 @@
target:
name: ""
schemas:
- - name: ""
- tables:
- - name: users
- columns:
- - name: id
- position: 0
- default: null
- nullable: false
- type: int
- characterset: ""
- collation: ""
- comment: "ID"
- classification: ""
- usercomment: ""
- - name: age
- position: 0
- default: null
- nullable: true
- type: varbinary(500)
- characterset: ""
- collation: ""
- comment: ""
- classification: ""
- usercomment: ""
- - name: name
- position: 0
- default: null
- nullable: true
- type: binary(10)
- characterset: ""
- collation: ""
- comment: ""
- classification: ""
- usercomment: ""
- indexes:
- - name: PRIMARY
- expressions:
- - id
- type: ""
- unique: true
- primary: true
- visible: true
- comment: ""
- - name: t
- columns:
- - name: a
- position: 0
- default: null
- nullable: false
- type: int
- characterset: ""
- collation: ""
- comment: ""
- classification: ""
- usercomment: ""
- indexes: []
- engine: ""
- collation: ""
- rowcount: 0
- datasize: 0
- indexsize: 0
- datafree: 0
- createoptions: ""
- comment: ""
- classification: ""
- usercomment: ""
- foreignkeys: []
- - name: t4
- columns:
- - name: a
- position: 0
- default:
- value: "'default value'"
- nullable: false
- type: varchar(10)
- characterset: ""
- collation: ""
- comment: this is comment, aha
- classification: ""
- usercomment: ""
- - name: b
- position: 0
- default: null
- nullable: false
- type: char(10)
- characterset: ""
- collation: ""
- comment: ""
- classification: ""
- usercomment: ""
- - name: c
- position: 0
- default: null
- nullable: false
- type: int
- characterset: ""
- collation: ""
- comment: ""
- classification: ""
- usercomment: ""
- - name: e
- position: 0
- default: null
- nullable: true
- type: int
- characterset: ""
- collation: ""
- comment: ""
- classification: ""
- usercomment: ""
- indexes:
- - name: PRIMARY
- expressions:
- - a
- - b
- - c
- type: ""
- unique: true
- primary: true
- visible: true
- comment: ""
- engine: ""
- collation: ""
- rowcount: 0
- datasize: 0
- indexsize: 0
- datafree: 0
- createoptions: ""
- comment: ""
- classification: ""
- usercomment: ""
- foreignkeys:
- - name: fk1
- columns:
- - b
- referencedschema: ""
- referencedtable: t2
- referencedcolumns:
- - b
- ondelete: ""
- onupdate: ""
- matchtype: ""
- - name: t2
- columns:
- - name: b
- position: 0
- default: null
- nullable: true
- type: int
- characterset: ""
- collation: ""
- comment: ""
- classification: ""
- usercomment: ""
- - name: a
- position: 0
- default: null
- nullable: true
- type: int
- characterset: ""
- collation: ""
- comment: ""
- classification: ""
- usercomment: ""
- indexes:
- - name: PRIMARY
- expressions:
- - b
- type: ""
- unique: true
- primary: true
- visible: true
- comment: ""
- engine: ""
- collation: ""
- rowcount: 0
- datasize: 0
- indexsize: 0
- datafree: 0
- createoptions: ""
- comment: ""
- classification: ""
- usercomment: ""
- foreignkeys:
- - name: fk1
- columns:
- - b
- referencedschema: ""
- referencedtable: t4
- referencedcolumns:
- - b
- ondelete: ""
- onupdate: ""
- matchtype: ""
- views: []
- functions: []
- streams: []
- tasks: []
+ - name: ""
+ tables:
+ - name: users
+ columns:
+ - name: id
+ position: 0
+ default: null
+ nullable: false
+ type: int
+ characterset: ""
+ collation: ""
+ comment: ID
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ - name: age
+ position: 0
+ default: null
+ nullable: true
+ type: varbinary(500)
+ characterset: ""
+ collation: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ - name: name
+ position: 0
+ default: null
+ nullable: true
+ type: binary(10)
+ characterset: ""
+ collation: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ indexes:
+ - name: PRIMARY
+ expressions:
+ - id
+ type: ""
+ unique: true
+ primary: true
+ visible: true
+ comment: ""
+ engine: ""
+ collation: ""
+ rowcount: 0
+ datasize: 0
+ indexsize: 0
+ datafree: 0
+ createoptions: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ foreignkeys: []
+ - name: t
+ columns:
+ - name: a
+ position: 0
+ default: null
+ nullable: false
+ type: int
+ characterset: ""
+ collation: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ indexes: []
+ engine: ""
+ collation: ""
+ rowcount: 0
+ datasize: 0
+ indexsize: 0
+ datafree: 0
+ createoptions: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ foreignkeys: []
+ - name: t4
+ columns:
+ - name: a
+ position: 0
+ default:
+ value: '''default value'''
+ nullable: false
+ type: varchar(10)
+ characterset: ""
+ collation: ""
+ comment: this is comment, aha
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ - name: b
+ position: 0
+ default: null
+ nullable: false
+ type: char(10)
+ characterset: ""
+ collation: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ - name: c
+ position: 0
+ default:
+ value: "1"
+ nullable: false
+ type: int
+ characterset: ""
+ collation: ""
+ comment: col_b
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ - name: e
+ position: 0
+ default:
+ value: "1"
+ nullable: true
+ type: int
+ characterset: ""
+ collation: ""
+ comment: col_e
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ indexes:
+ - name: PRIMARY
+ expressions:
+ - a
+ - b
+ - c
+ type: ""
+ unique: true
+ primary: true
+ visible: true
+ comment: ""
+ engine: ""
+ collation: ""
+ rowcount: 0
+ datasize: 0
+ indexsize: 0
+ datafree: 0
+ createoptions: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ foreignkeys:
+ - name: fk1
+ columns:
+ - b
+ referencedschema: ""
+ referencedtable: t2
+ referencedcolumns:
+ - b
+ ondelete: ""
+ onupdate: ""
+ matchtype: ""
+ - name: t2
+ columns:
+ - name: b
+ position: 0
+ default: null
+ nullable: true
+ type: int
+ characterset: ""
+ collation: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ - name: a
+ position: 0
+ default: null
+ nullable: true
+ type: int
+ characterset: ""
+ collation: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ effectivemaskinglevel: 0
+ indexes:
+ - name: PRIMARY
+ expressions:
+ - b
+ type: ""
+ unique: true
+ primary: true
+ visible: true
+ comment: ""
+ engine: ""
+ collation: ""
+ rowcount: 0
+ datasize: 0
+ indexsize: 0
+ datafree: 0
+ createoptions: ""
+ comment: ""
+ classification: ""
+ usercomment: ""
+ foreignkeys:
+ - name: fk1
+ columns:
+ - b
+ referencedschema: ""
+ referencedtable: t4
+ referencedcolumns:
+ - b
+ ondelete: ""
+ onupdate: ""
+ matchtype: ""
+ views: []
+ functions: []
+ streams: []
+ tasks: []
characterset: ""
collation: ""
extensions: []
+ schemaconfigs: []
result: |
CREATE TABLE `t` (
`a` int NOT NULL
);
CREATE TABLE `t4` (
`a` varchar(10) NOT NULL DEFAULT 'default value' COMMENT 'this is comment, aha',
- `c` int NOT NULL,
- `e` int NULL,
+ `c` int NOT NULL DEFAULT 1 COMMENT 'col_b',
+ `e` int NULL DEFAUL 1 COMMENT 'col_e',
`b` char(10) NOT NULL,
PRIMARY KEY (`a`, `b`, `c`),
CONSTRAINT `fk1` FOREIGN KEY (`b`) REFERENCES `t2` (`b`)