diff --git a/callbacks/preload.go b/callbacks/preload.go index 4a6f2b79..fd8214bb 100644 --- a/callbacks/preload.go +++ b/callbacks/preload.go @@ -152,7 +152,7 @@ func preloadEntryPoint(db *gorm.DB, joins []string, relationships *schema.Relati return gorm.ErrInvalidData } } else { - tx := db.Table("").Session(&gorm.Session{Context: db.Statement.Context, SkipHooks: db.Statement.SkipHooks, Initialized: true}) + tx := db.Table("").Session(&gorm.Session{Context: db.Statement.Context, SkipHooks: db.Statement.SkipHooks}) tx.Statement.ReflectValue = db.Statement.ReflectValue tx.Statement.Unscoped = db.Statement.Unscoped if err := preload(tx, rel, append(preloads[name], associationsConds...), preloadMap[name]); err != nil { diff --git a/generics.go b/generics.go index 230f07f5..7c7257f6 100644 --- a/generics.go +++ b/generics.go @@ -388,7 +388,7 @@ func (c chainG[T]) Order(value interface{}) ChainInterface[T] { func (c chainG[T]) Preload(association string, query func(db PreloadBuilder) error) ChainInterface[T] { return c.with(func(db *DB) *DB { return db.Preload(association, func(tx *DB) *DB { - q := preloadBuilder{db: tx} + q := preloadBuilder{db: tx.getInstance()} if query != nil { if err := query(q); err != nil { db.AddError(err) diff --git a/tests/go.mod b/tests/go.mod index 7f4d84f7..1c644f31 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -11,7 +11,7 @@ require ( gorm.io/driver/postgres v1.5.11 gorm.io/driver/sqlite v1.5.7 gorm.io/driver/sqlserver v1.5.4 - gorm.io/gorm v1.25.12 + gorm.io/gorm v1.26.1 ) require ( @@ -22,11 +22,11 @@ require ( github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect - github.com/jackc/pgx/v5 v5.7.4 // indirect + github.com/jackc/pgx/v5 v5.7.5 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/kr/text v0.2.0 // indirect github.com/mattn/go-sqlite3 v1.14.28 // indirect - github.com/microsoft/go-mssqldb v1.8.0 // indirect + github.com/microsoft/go-mssqldb v1.8.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect golang.org/x/crypto v0.38.0 // indirect