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.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/vendor/github.com/uptrace/bun/query_table_create.go b/vendor/github.com/uptrace/bun/query_table_create.go
index a5fa8e231..08c68e054 100644
--- a/vendor/github.com/uptrace/bun/query_table_create.go
+++ b/vendor/github.com/uptrace/bun/query_table_create.go
@@ -186,14 +186,20 @@ func (q *CreateTableQuery) appendUniqueConstraints(fmter schema.Formatter, b []b
sort.Strings(keys)
for _, key := range keys {
- b = q.appendUniqueConstraint(fmter, b, key, unique[key])
+ if key == "" {
+ for _, field := range unique[key] {
+ b = q.appendUniqueConstraint(fmter, b, key, field)
+ }
+ continue
+ }
+ b = q.appendUniqueConstraint(fmter, b, key, unique[key]...)
}
return b
}
func (q *CreateTableQuery) appendUniqueConstraint(
- fmter schema.Formatter, b []byte, name string, fields []*schema.Field,
+ fmter schema.Formatter, b []byte, name string, fields ...*schema.Field,
) []byte {
if name != "" {
b = append(b, ", CONSTRAINT "...)
@@ -204,7 +210,6 @@ func (q *CreateTableQuery) appendUniqueConstraint(
b = append(b, " UNIQUE ("...)
b = appendColumns(b, "", fields)
b = append(b, ")"...)
-
return b
}