forked from mirror/gorm
Merge pull request #5125 from CaoManhDat/master
ToSQL should enable SkipDefaultTransaction by default
This commit is contained in:
commit
b566ed7913
2
gorm.go
2
gorm.go
|
@ -462,7 +462,7 @@ func (db *DB) Use(plugin Plugin) error {
|
||||||
// .First(&User{})
|
// .First(&User{})
|
||||||
// })
|
// })
|
||||||
func (db *DB) ToSQL(queryFn func(tx *DB) *DB) string {
|
func (db *DB) ToSQL(queryFn func(tx *DB) *DB) string {
|
||||||
tx := queryFn(db.Session(&Session{DryRun: true}))
|
tx := queryFn(db.Session(&Session{DryRun: true, SkipDefaultTransaction: true}))
|
||||||
stmt := tx.Statement
|
stmt := tx.Statement
|
||||||
|
|
||||||
return db.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)
|
return db.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)
|
||||||
|
|
Loading…
Reference in New Issue