ToSQL should enable SkipDefaultTransaction by default

This commit is contained in:
Cao Manh Dat 2022-03-03 09:17:29 +07:00
parent 4e523499d1
commit 29a8557384
1 changed files with 1 additions and 1 deletions

View File

@ -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...)