diff options
| author | 2025-06-30 15:19:09 +0200 | |
|---|---|---|
| committer | 2025-06-30 15:19:09 +0200 | |
| commit | 8b0ea560279a5bf4479555d3924c763ddeecfcad (patch) | |
| tree | 005e26d4a658e565594fb259cc17948659195822 /vendor/github.com/uptrace/bun/query_table_create.go | |
| parent | [chore] bumps ncruces/go-sqlite3 v0.26.1 => v0.26.3 (#4302) (diff) | |
| download | gotosocial-8b0ea560279a5bf4479555d3924c763ddeecfcad.tar.xz | |
[chore] update go dependencies (#4304)
- github.com/KimMachineGun/automemlimit v0.7.2 => v0.7.3
- github.com/gin-contrib/cors v1.7.5 => v1.7.6
- github.com/minio/minio-go/v7 v7.0.92 => v7.0.94
- github.com/spf13/cast v1.8.0 => v1.9.2
- github.com/uptrace/bun{,/*} v1.2.11 => v1.2.14
- golang.org/x/image v0.27.0 => v0.28.0
- golang.org/x/net v0.40.0 => v0.41.0
- code.superseriousbusiness.org/go-swagger v0.31.0-gts-go1.23-fix => v0.32.3-gts-go1.23-fix
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4304
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/uptrace/bun/query_table_create.go')
| -rw-r--r-- | vendor/github.com/uptrace/bun/query_table_create.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/vendor/github.com/uptrace/bun/query_table_create.go b/vendor/github.com/uptrace/bun/query_table_create.go index 0ae56bf78..3e1474ed7 100644 --- a/vendor/github.com/uptrace/bun/query_table_create.go +++ b/vendor/github.com/uptrace/bun/query_table_create.go @@ -5,7 +5,7 @@ import ( "context" "database/sql" "fmt" - "sort" + "slices" "strconv" "strings" @@ -276,7 +276,7 @@ func (q *CreateTableQuery) appendUniqueConstraints(fmter schema.Formatter, b []b for key := range unique { keys = append(keys, key) } - sort.Strings(keys) + slices.Sort(keys) for _, key := range keys { if key == "" { @@ -308,8 +308,16 @@ func (q *CreateTableQuery) appendUniqueConstraint( // appendFKConstraintsRel appends a FOREIGN KEY clause for each of the model's existing relations. func (q *CreateTableQuery) appendFKConstraintsRel(fmter schema.Formatter, b []byte) (_ []byte, err error) { - for _, rel := range q.tableModel.Table().Relations { - if rel.References() { + relations := q.tableModel.Table().Relations + + keys := make([]string, 0, len(relations)) + for key := range relations { + keys = append(keys, key) + } + slices.Sort(keys) + + for _, key := range keys { + if rel := relations[key]; rel.References() { b, err = q.appendFK(fmter, b, schema.QueryWithArgs{ Query: "(?) REFERENCES ? (?) ? ?", Args: []interface{}{ @@ -400,11 +408,12 @@ func (q *CreateTableQuery) afterCreateTableHook(ctx context.Context) error { return nil } +// String returns the generated SQL query string. The CreateTableQuery instance must not be +// modified during query generation to ensure multiple calls to String() return identical results. func (q *CreateTableQuery) String() string { buf, err := q.AppendQuery(q.db.Formatter(), nil) if err != nil { panic(err) } - return string(buf) } |
