Update gorm.go

This commit is contained in:
Lucas Gonçalves de Paula 2024-08-26 20:37:33 -03:00 committed by GitHub
parent 0daaf1747c
commit 36b41fadd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

18
gorm.go
View File

@ -407,6 +407,23 @@ func (db *DB) getInstance() *DB {
tx := &DB{Config: db.Config, Error: db.Error} tx := &DB{Config: db.Config, Error: db.Error}
if db.clone == 1 { if db.clone == 1 {
setings := sync.Map{}
d,e := db.Get("xs-uuid")
if e{
setings.Store("xs-uuid",d)
}
d,e = db.Get("xs-uuid-internal")
if e{
setings.Store("xs-uuid-internal",d)
}
d,e = db.Get("signed-user")
if e{
setings.Store("signed-user",d)
}
// clone with new statement // clone with new statement
tx.Statement = &Statement{ tx.Statement = &Statement{
DB: tx, DB: tx,
@ -415,6 +432,7 @@ func (db *DB) getInstance() *DB {
Clauses: map[string]clause.Clause{}, Clauses: map[string]clause.Clause{},
Vars: make([]interface{}, 0, 8), Vars: make([]interface{}, 0, 8),
SkipHooks: db.Statement.SkipHooks, SkipHooks: db.Statement.SkipHooks,
Settings: setings,
} }
if db.Config.PropagateUnscoped { if db.Config.PropagateUnscoped {
tx.Statement.Unscoped = db.Statement.Unscoped tx.Statement.Unscoped = db.Statement.Unscoped