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:
23
vendor/github.com/uptrace/bun/migrate/sqlschema/inspector.go
generated
vendored
23
vendor/github.com/uptrace/bun/migrate/sqlschema/inspector.go
generated
vendored
@ -7,8 +7,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/uptrace/bun"
|
||||
"github.com/uptrace/bun/internal/ordered"
|
||||
"github.com/uptrace/bun/schema"
|
||||
orderedmap "github.com/wk8/go-ordered-map/v2"
|
||||
)
|
||||
|
||||
type InspectorDialect interface {
|
||||
@ -102,25 +102,25 @@ func (bmi *BunModelInspector) Inspect(ctx context.Context) (Database, error) {
|
||||
BaseDatabase: BaseDatabase{
|
||||
ForeignKeys: make(map[ForeignKey]string),
|
||||
},
|
||||
Tables: orderedmap.New[string, Table](),
|
||||
Tables: ordered.NewMap[string, Table](),
|
||||
}
|
||||
for _, t := range bmi.tables.All() {
|
||||
if t.Schema != bmi.SchemaName {
|
||||
continue
|
||||
}
|
||||
|
||||
columns := orderedmap.New[string, Column]()
|
||||
columns := ordered.NewMap[string, Column]()
|
||||
for _, f := range t.Fields {
|
||||
|
||||
sqlType, length, err := parseLen(f.CreateTableSQLType)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse length in %q: %w", f.CreateTableSQLType, err)
|
||||
}
|
||||
columns.Set(f.Name, &BaseColumn{
|
||||
columns.Store(f.Name, &BaseColumn{
|
||||
Name: f.Name,
|
||||
SQLType: strings.ToLower(sqlType), // TODO(dyma): maybe this is not necessary after Column.Eq()
|
||||
VarcharLen: length,
|
||||
DefaultValue: exprToLower(f.SQLDefault),
|
||||
DefaultValue: exprOrLiteral(f.SQLDefault),
|
||||
IsNullable: !f.NotNull,
|
||||
IsAutoIncrement: f.AutoIncrement,
|
||||
IsIdentity: f.Identity,
|
||||
@ -162,7 +162,7 @@ func (bmi *BunModelInspector) Inspect(ctx context.Context) (Database, error) {
|
||||
// produces
|
||||
// schema.Table{ Schema: "favourite", Name: "favourite.books" }
|
||||
tableName := strings.TrimPrefix(t.Name, t.Schema+".")
|
||||
state.Tables.Set(tableName, &BunTable{
|
||||
state.Tables.Store(tableName, &BunTable{
|
||||
BaseTable: BaseTable{
|
||||
Schema: t.Schema,
|
||||
Name: tableName,
|
||||
@ -211,12 +211,13 @@ func parseLen(typ string) (string, int, error) {
|
||||
return typ[:paren], length, nil
|
||||
}
|
||||
|
||||
// exprToLower converts string to lowercase, if it does not contain a string literal 'lit'.
|
||||
// exprOrLiteral converts string to lowercase, if it does not contain a string literal 'lit'
|
||||
// and trims the surrounding '' otherwise.
|
||||
// Use it to ensure that user-defined default values in the models are always comparable
|
||||
// to those returned by the database inspector, regardless of the case convention in individual drivers.
|
||||
func exprToLower(s string) string {
|
||||
func exprOrLiteral(s string) string {
|
||||
if strings.HasPrefix(s, "'") && strings.HasSuffix(s, "'") {
|
||||
return s
|
||||
return strings.Trim(s, "'")
|
||||
}
|
||||
return strings.ToLower(s)
|
||||
}
|
||||
@ -225,10 +226,10 @@ func exprToLower(s string) string {
|
||||
type BunModelSchema struct {
|
||||
BaseDatabase
|
||||
|
||||
Tables *orderedmap.OrderedMap[string, Table]
|
||||
Tables *ordered.Map[string, Table]
|
||||
}
|
||||
|
||||
func (ms BunModelSchema) GetTables() *orderedmap.OrderedMap[string, Table] {
|
||||
func (ms BunModelSchema) GetTables() *ordered.Map[string, Table] {
|
||||
return ms.Tables
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user