Edit DB.clone(), DB.Dialect(), and Scope.Dialect() preserve transactions.
This commit is contained in:
parent
82eb9f8a5b
commit
989ca54201
5
main.go
5
main.go
@ -119,7 +119,7 @@ func (s *DB) CommonDB() SQLCommon {
|
|||||||
|
|
||||||
// Dialect get dialect
|
// Dialect get dialect
|
||||||
func (s *DB) Dialect() Dialect {
|
func (s *DB) Dialect() Dialect {
|
||||||
return s.parent.dialect
|
return s.dialect
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback return `Callbacks` container, you could add/change/delete callbacks with it
|
// Callback return `Callbacks` container, you could add/change/delete callbacks with it
|
||||||
@ -484,6 +484,8 @@ func (s *DB) Begin() *DB {
|
|||||||
if db, ok := c.db.(sqlDb); ok && db != nil {
|
if db, ok := c.db.(sqlDb); ok && db != nil {
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
c.db = interface{}(tx).(SQLCommon)
|
c.db = interface{}(tx).(SQLCommon)
|
||||||
|
|
||||||
|
c.dialect.SetDB(c.db)
|
||||||
c.AddError(err)
|
c.AddError(err)
|
||||||
} else {
|
} else {
|
||||||
c.AddError(ErrCantStartTransaction)
|
c.AddError(ErrCantStartTransaction)
|
||||||
@ -748,6 +750,7 @@ func (s *DB) clone() *DB {
|
|||||||
Value: s.Value,
|
Value: s.Value,
|
||||||
Error: s.Error,
|
Error: s.Error,
|
||||||
blockGlobalUpdate: s.blockGlobalUpdate,
|
blockGlobalUpdate: s.blockGlobalUpdate,
|
||||||
|
dialect: newDialect(s.dialect.GetName(), s.db),
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value := range s.values {
|
for key, value := range s.values {
|
||||||
|
2
scope.go
2
scope.go
@ -63,7 +63,7 @@ func (scope *Scope) SQLDB() SQLCommon {
|
|||||||
|
|
||||||
// Dialect get dialect
|
// Dialect get dialect
|
||||||
func (scope *Scope) Dialect() Dialect {
|
func (scope *Scope) Dialect() Dialect {
|
||||||
return scope.db.parent.dialect
|
return scope.db.dialect
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quote used to quote string to escape them for database
|
// Quote used to quote string to escape them for database
|
||||||
|
Loading…
x
Reference in New Issue
Block a user