summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/query_table_create.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/uptrace/bun/query_table_create.go')
-rw-r--r--vendor/github.com/uptrace/bun/query_table_create.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/vendor/github.com/uptrace/bun/query_table_create.go b/vendor/github.com/uptrace/bun/query_table_create.go
index 3d98da07b..aeb79cd37 100644
--- a/vendor/github.com/uptrace/bun/query_table_create.go
+++ b/vendor/github.com/uptrace/bun/query_table_create.go
@@ -9,6 +9,7 @@ import (
"strconv"
"strings"
+ "github.com/uptrace/bun/dialect"
"github.com/uptrace/bun/dialect/feature"
"github.com/uptrace/bun/dialect/sqltype"
"github.com/uptrace/bun/internal"
@@ -165,7 +166,7 @@ func (q *CreateTableQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []by
b = append(b, field.SQLName...)
b = append(b, " "...)
b = q.appendSQLType(b, field)
- if field.NotNull {
+ if field.NotNull && q.db.dialect.Name() != dialect.Oracle {
b = append(b, " NOT NULL"...)
}
@@ -246,7 +247,11 @@ func (q *CreateTableQuery) appendSQLType(b []byte, field *schema.Field) []byte {
return append(b, field.CreateTableSQLType...)
}
- b = append(b, sqltype.VarChar...)
+ if q.db.dialect.Name() == dialect.Oracle {
+ b = append(b, "VARCHAR2"...)
+ } else {
+ b = append(b, sqltype.VarChar...)
+ }
b = append(b, "("...)
b = strconv.AppendInt(b, int64(q.varchar), 10)
b = append(b, ")"...)
@@ -297,9 +302,9 @@ func (q *CreateTableQuery) appendFKConstraintsRel(fmter schema.Formatter, b []by
b, err = q.appendFK(fmter, b, schema.QueryWithArgs{
Query: "(?) REFERENCES ? (?) ? ?",
Args: []interface{}{
- Safe(appendColumns(nil, "", rel.BaseFields)),
+ Safe(appendColumns(nil, "", rel.BasePKs)),
rel.JoinTable.SQLName,
- Safe(appendColumns(nil, "", rel.JoinFields)),
+ Safe(appendColumns(nil, "", rel.JoinPKs)),
Safe(rel.OnUpdate),
Safe(rel.OnDelete),
},