fix: ensure ErrRecordNotFound is triggered on find queries
This commit ensures that ErrRecordNotFound is properly triggered when using find queries with the RaiseErrorOnNotFound flag enabled, without the need for using `WithContext`.
This commit is contained in:
parent
9ca84b3dde
commit
6e0d37aaf4
13
gorm.go
13
gorm.go
@ -414,12 +414,13 @@ func (db *DB) getInstance() *DB {
|
||||
if db.clone == 1 {
|
||||
// clone with new statement
|
||||
tx.Statement = &Statement{
|
||||
DB: tx,
|
||||
ConnPool: db.Statement.ConnPool,
|
||||
Context: db.Statement.Context,
|
||||
Clauses: map[string]clause.Clause{},
|
||||
Vars: make([]interface{}, 0, 8),
|
||||
SkipHooks: db.Statement.SkipHooks,
|
||||
DB: tx,
|
||||
ConnPool: db.Statement.ConnPool,
|
||||
Context: db.Statement.Context,
|
||||
Clauses: map[string]clause.Clause{},
|
||||
Vars: make([]interface{}, 0, 8),
|
||||
SkipHooks: db.Statement.SkipHooks,
|
||||
RaiseErrorOnNotFound: db.Statement.RaiseErrorOnNotFound,
|
||||
}
|
||||
if db.Config.PropagateUnscoped {
|
||||
tx.Statement.Unscoped = db.Statement.Unscoped
|
||||
|
Loading…
x
Reference in New Issue
Block a user