mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
bump uptrace/bun dependencies from 1.2.6 to 1.2.8 (#3645)
This commit is contained in:
33
vendor/github.com/uptrace/bun/schema/table.go
generated
vendored
33
vendor/github.com/uptrace/bun/schema/table.go
generated
vendored
@ -4,6 +4,7 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -22,7 +23,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
baseModelType = reflect.TypeOf((*BaseModel)(nil)).Elem()
|
||||
baseModelType = reflect.TypeFor[BaseModel]()
|
||||
tableNameInflector = inflection.Plural
|
||||
)
|
||||
|
||||
@ -75,7 +76,7 @@ type structField struct {
|
||||
Table *Table
|
||||
}
|
||||
|
||||
func (table *Table) init(dialect Dialect, typ reflect.Type, canAddr bool) {
|
||||
func (table *Table) init(dialect Dialect, typ reflect.Type) {
|
||||
table.dialect = dialect
|
||||
table.Type = typ
|
||||
table.ZeroValue = reflect.New(table.Type).Elem()
|
||||
@ -90,7 +91,7 @@ func (table *Table) init(dialect Dialect, typ reflect.Type, canAddr bool) {
|
||||
|
||||
table.Fields = make([]*Field, 0, typ.NumField())
|
||||
table.FieldMap = make(map[string]*Field, typ.NumField())
|
||||
table.processFields(typ, canAddr)
|
||||
table.processFields(typ)
|
||||
|
||||
hooks := []struct {
|
||||
typ reflect.Type
|
||||
@ -110,7 +111,7 @@ func (table *Table) init(dialect Dialect, typ reflect.Type, canAddr bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Table) processFields(typ reflect.Type, canAddr bool) {
|
||||
func (t *Table) processFields(typ reflect.Type) {
|
||||
type embeddedField struct {
|
||||
prefix string
|
||||
index []int
|
||||
@ -250,6 +251,30 @@ func (t *Table) processFields(typ reflect.Type, canAddr bool) {
|
||||
t.addUnique(subfield, embfield.prefix, v)
|
||||
}
|
||||
}
|
||||
|
||||
if len(embedded) > 0 {
|
||||
// https://github.com/uptrace/bun/issues/1095
|
||||
// < v1.2, all fields follow the order corresponding to the struct
|
||||
// >= v1.2, < v1.2.8, fields of nested structs have been moved to the end.
|
||||
// >= v1.2.8, The default behavior remains the same as initially,
|
||||
sortFieldsByStruct(t.allFields)
|
||||
sortFieldsByStruct(t.Fields)
|
||||
sortFieldsByStruct(t.PKs)
|
||||
sortFieldsByStruct(t.DataFields)
|
||||
}
|
||||
}
|
||||
|
||||
func sortFieldsByStruct(fields []*Field) {
|
||||
sort.Slice(fields, func(i, j int) bool {
|
||||
left, right := fields[i], fields[j]
|
||||
for k := 0; k < len(left.Index) && k < len(right.Index); k++ {
|
||||
if left.Index[k] != right.Index[k] {
|
||||
return left.Index[k] < right.Index[k]
|
||||
}
|
||||
}
|
||||
// NOTE: should not reach
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func (t *Table) addUnique(field *Field, prefix string, tagOptions []string) {
|
||||
|
Reference in New Issue
Block a user