Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion oracle/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"database/sql"
"errors"
"fmt"
"regexp"
"slices"
"strconv"
"strings"
Expand Down Expand Up @@ -193,8 +194,17 @@ func (m Migrator) CreateTable(values ...interface{}) error {
}

for _, chk := range stmt.Schema.ParseCheckConstraints() {
constraintSQL := chk.Constraint

// Quote column names that appear in the constraint
for _, f := range stmt.Schema.Fields {
if strings.Contains(constraintSQL, f.DBName) {
re := regexp.MustCompile(`\b` + regexp.QuoteMeta(f.DBName) + `\b`)
constraintSQL = re.ReplaceAllString(constraintSQL, QuoteIdentifier(f.DBName))
}
}
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: constraintSQL})
}

createTableSQL = strings.TrimSuffix(createTableSQL, ",")
Expand Down
2 changes: 0 additions & 2 deletions tests/json_bulk_2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ func TestUnicodeJSON(t *testing.T) {
}

func TestJSONStrict(t *testing.T) {
t.Skip("Skipping due to issue #100")
type StrictJSONRecord struct {
ID uint `gorm:"primaryKey;autoIncrement;column:record_id"`
DocJson datatypes.JSON `gorm:"type:CLOB;column:doc;check:doc_is_json_strict,doc IS JSON (STRICT)"`
Expand All @@ -422,7 +421,6 @@ func TestJSONStrict(t *testing.T) {
}

func TestJSONLAX(t *testing.T) {
t.Skip("Skipping due to issue #100")
type LaxJSONRecord struct {
ID uint `gorm:"primaryKey;autoIncrement;column:record_id"`
Doc datatypes.JSON `gorm:"type:CLOB;column:doc;check:doc_is_json_lax,doc IS JSON(LAX)"`
Expand Down
Loading