Merge pull request #519 from cloudbase/dependabot/go_modules/gorm.io/gorm-1.30.5

Bump gorm.io/gorm from 1.30.3 to 1.30.5
This commit is contained in:
Gabriel 2025-09-09 09:32:18 +03:00 committed by GitHub
commit 08507ddbf9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 106 additions and 11 deletions

2
go.mod
View file

@ -32,7 +32,7 @@ require (
gorm.io/datatypes v1.2.6
gorm.io/driver/mysql v1.6.0
gorm.io/driver/sqlite v1.6.0
gorm.io/gorm v1.30.3
gorm.io/gorm v1.30.5
)
require (

4
go.sum
View file

@ -234,5 +234,5 @@ gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
gorm.io/driver/sqlserver v1.6.0 h1:VZOBQVsVhkHU/NzNhRJKoANt5pZGQAS1Bwc6m6dgfnc=
gorm.io/driver/sqlserver v1.6.0/go.mod h1:WQzt4IJo/WHKnckU9jXBLMJIVNMVeTu25dnOzehntWw=
gorm.io/gorm v1.30.3 h1:QiG8upl0Sg9ba2Zatfjy0fy4It2iNBL2/eMdvEkdXNs=
gorm.io/gorm v1.30.3/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
gorm.io/gorm v1.30.5 h1:dvEfYwxL+i+xgCNSGGBT1lDjCzfELK8fHZxL3Ee9X0s=
gorm.io/gorm v1.30.5/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=

11
vendor/gorm.io/gorm/clause/set.go generated vendored
View file

@ -9,6 +9,11 @@ type Assignment struct {
Value interface{}
}
// Assigner assignments provider interface
type Assigner interface {
Assignments() []Assignment
}
func (set Set) Name() string {
return "SET"
}
@ -37,6 +42,9 @@ func (set Set) MergeClause(clause *Clause) {
clause.Expression = Set(copiedAssignments)
}
// Assignments implements Assigner for Set.
func (set Set) Assignments() []Assignment { return []Assignment(set) }
func Assignments(values map[string]interface{}) Set {
keys := make([]string, 0, len(values))
for key := range values {
@ -58,3 +66,6 @@ func AssignmentColumns(values []string) Set {
}
return assignments
}
// Assignments implements Assigner for a single Assignment.
func (a Assignment) Assignments() []Assignment { return []Assignment{a} }

88
vendor/gorm.io/gorm/generics.go generated vendored
View file

@ -35,10 +35,33 @@ type Interface[T any] interface {
}
type CreateInterface[T any] interface {
ChainInterface[T]
ExecInterface[T]
// chain methods available at start; return ChainInterface
Scopes(scopes ...func(db *Statement)) ChainInterface[T]
Where(query interface{}, args ...interface{}) ChainInterface[T]
Not(query interface{}, args ...interface{}) ChainInterface[T]
Or(query interface{}, args ...interface{}) ChainInterface[T]
Limit(offset int) ChainInterface[T]
Offset(offset int) ChainInterface[T]
Joins(query clause.JoinTarget, on func(db JoinBuilder, joinTable clause.Table, curTable clause.Table) error) ChainInterface[T]
Preload(association string, query func(db PreloadBuilder) error) ChainInterface[T]
Select(query string, args ...interface{}) ChainInterface[T]
Omit(columns ...string) ChainInterface[T]
MapColumns(m map[string]string) ChainInterface[T]
Distinct(args ...interface{}) ChainInterface[T]
Group(name string) ChainInterface[T]
Having(query interface{}, args ...interface{}) ChainInterface[T]
Order(value interface{}) ChainInterface[T]
Build(builder clause.Builder)
Delete(ctx context.Context) (rowsAffected int, err error)
Update(ctx context.Context, name string, value any) (rowsAffected int, err error)
Updates(ctx context.Context, t T) (rowsAffected int, err error)
Table(name string, args ...interface{}) CreateInterface[T]
Create(ctx context.Context, r *T) error
CreateInBatches(ctx context.Context, r *[]T, batchSize int) error
Set(assignments ...clause.Assigner) SetCreateOrUpdateInterface[T]
}
type ChainInterface[T any] interface {
@ -58,15 +81,28 @@ type ChainInterface[T any] interface {
Group(name string) ChainInterface[T]
Having(query interface{}, args ...interface{}) ChainInterface[T]
Order(value interface{}) ChainInterface[T]
Set(assignments ...clause.Assigner) SetUpdateOnlyInterface[T]
Build(builder clause.Builder)
Table(name string, args ...interface{}) ChainInterface[T]
Delete(ctx context.Context) (rowsAffected int, err error)
Update(ctx context.Context, name string, value any) (rowsAffected int, err error)
Updates(ctx context.Context, t T) (rowsAffected int, err error)
Count(ctx context.Context, column string) (result int64, err error)
}
// SetUpdateOnlyInterface is returned by Set after chaining; only Update is allowed
type SetUpdateOnlyInterface[T any] interface {
Update(ctx context.Context) (rowsAffected int, err error)
}
// SetCreateOrUpdateInterface is returned by Set at start; Create or Update are allowed
type SetCreateOrUpdateInterface[T any] interface {
Create(ctx context.Context) error
Update(ctx context.Context) (rowsAffected int, err error)
}
type ExecInterface[T any] interface {
Scan(ctx context.Context, r interface{}) error
First(context.Context) (T, error)
@ -163,6 +199,10 @@ func (c createG[T]) Table(name string, args ...interface{}) CreateInterface[T] {
})}
}
func (c createG[T]) Set(assignments ...clause.Assigner) SetCreateOrUpdateInterface[T] {
return setCreateOrUpdateG[T]{c: c.chainG, assigns: toAssignments(assignments...)}
}
func (c createG[T]) Create(ctx context.Context, r *T) error {
return c.g.apply(ctx).Create(r).Error
}
@ -189,6 +229,12 @@ func (c chainG[T]) with(v op) chainG[T] {
}
}
func (c chainG[T]) Table(name string, args ...interface{}) ChainInterface[T] {
return c.with(func(db *DB) *DB {
return db.Table(name, args...)
})
}
func (c chainG[T]) Scopes(scopes ...func(db *Statement)) ChainInterface[T] {
return c.with(func(db *DB) *DB {
for _, fc := range scopes {
@ -198,12 +244,6 @@ func (c chainG[T]) Scopes(scopes ...func(db *Statement)) ChainInterface[T] {
})
}
func (c chainG[T]) Table(name string, args ...interface{}) ChainInterface[T] {
return c.with(func(db *DB) *DB {
return db.Table(name, args...)
})
}
func (c chainG[T]) Where(query interface{}, args ...interface{}) ChainInterface[T] {
return c.with(func(db *DB) *DB {
return db.Where(query, args...)
@ -390,6 +430,10 @@ func (c chainG[T]) MapColumns(m map[string]string) ChainInterface[T] {
})
}
func (c chainG[T]) Set(assignments ...clause.Assigner) SetUpdateOnlyInterface[T] {
return setCreateOrUpdateG[T]{c: c, assigns: toAssignments(assignments...)}
}
func (c chainG[T]) Distinct(args ...interface{}) ChainInterface[T] {
return c.with(func(db *DB) *DB {
return db.Distinct(args...)
@ -557,6 +601,36 @@ func (c chainG[T]) Build(builder clause.Builder) {
}
}
type setCreateOrUpdateG[T any] struct {
c chainG[T]
assigns []clause.Assignment
}
// toAssignments converts various supported types into []clause.Assignment.
// Supported inputs implement clause.Assigner.
func toAssignments(items ...clause.Assigner) []clause.Assignment {
out := make([]clause.Assignment, 0, len(items))
for _, it := range items {
out = append(out, it.Assignments()...)
}
return out
}
func (s setCreateOrUpdateG[T]) Update(ctx context.Context) (rowsAffected int, err error) {
var r T
res := s.c.g.apply(ctx).Model(r).Clauses(clause.Set(s.assigns)).Updates(map[string]interface{}{})
return int(res.RowsAffected), res.Error
}
func (s setCreateOrUpdateG[T]) Create(ctx context.Context) error {
var r T
data := make(map[string]interface{}, len(s.assigns))
for _, a := range s.assigns {
data[a.Column.Name] = a.Value
}
return s.c.g.apply(ctx).Model(r).Create(data).Error
}
type execG[T any] struct {
g *g[T]
}

10
vendor/gorm.io/gorm/logger/slog.go generated vendored
View file

@ -1,3 +1,5 @@
//go:build go1.21
package logger
import (
@ -88,3 +90,11 @@ func (l *slogLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql
})
}
}
// ParamsFilter filter params
func (l *slogLogger) ParamsFilter(ctx context.Context, sql string, params ...interface{}) (string, []interface{}) {
if l.Parameterized {
return sql, nil
}
return sql, params
}

2
vendor/modules.txt vendored
View file

@ -385,7 +385,7 @@ gorm.io/driver/mysql
# gorm.io/driver/sqlite v1.6.0
## explicit; go 1.20
gorm.io/driver/sqlite
# gorm.io/gorm v1.30.3
# gorm.io/gorm v1.30.5
## explicit; go 1.18
gorm.io/gorm
gorm.io/gorm/callbacks