mirror of https://github.com/go-gorm/gorm.git
CHECK constraint without parentheses
This commit is contained in:
parent
619cd332ec
commit
30188e7aa4
|
@ -182,7 +182,7 @@ func (m Migrator) CreateTable(values ...interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, chk := range stmt.Schema.ParseCheckConstraints() {
|
for _, chk := range stmt.Schema.ParseCheckConstraints() {
|
||||||
createTableSQL += "CONSTRAINT ? CHECK ?,"
|
createTableSQL += "CONSTRAINT ? CHECK (?),"
|
||||||
values = append(values, clause.Column{Name: chk.Name}, clause.Expr{SQL: chk.Constraint})
|
values = append(values, clause.Column{Name: chk.Name}, clause.Expr{SQL: chk.Constraint})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ func (m Migrator) CreateConstraint(value interface{}, name string) error {
|
||||||
checkConstraints := stmt.Schema.ParseCheckConstraints()
|
checkConstraints := stmt.Schema.ParseCheckConstraints()
|
||||||
if chk, ok := checkConstraints[name]; ok {
|
if chk, ok := checkConstraints[name]; ok {
|
||||||
return m.DB.Exec(
|
return m.DB.Exec(
|
||||||
"ALTER TABLE ? ADD CONSTRAINT ? CHECK ?",
|
"ALTER TABLE ? ADD CONSTRAINT ? CHECK (?)",
|
||||||
clause.Table{Name: stmt.Table}, clause.Column{Name: chk.Name}, clause.Expr{SQL: chk.Constraint},
|
clause.Table{Name: stmt.Table}, clause.Column{Name: chk.Name}, clause.Expr{SQL: chk.Constraint},
|
||||||
).Error
|
).Error
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue