Merge pull request #5125 from CaoManhDat/master

ToSQL should enable SkipDefaultTransaction by default
This commit is contained in:
Jason Lee 2022-03-04 11:37:37 +08:00 committed by GitHub
commit b566ed7913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -462,7 +462,7 @@ func (db *DB) Use(plugin Plugin) error {
// .First(&User{})
// })
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
return db.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)