Browse Source

1. fix bug : https://github.com/jinzhu/gorm/issues/2700

misko 4 years ago
parent
commit
f616ccd397
1 changed files with 4 additions and 1 deletions
  1. 4 1
      main.go

+ 4 - 1
main.go

@@ -124,7 +124,10 @@ func (s *DB) Close() error {
 // DB get `*sql.DB` from current connection
 // If the underlying database connection is not a *sql.DB, returns nil
 func (s *DB) DB() *sql.DB {
-	db, _ := s.db.(*sql.DB)
+	db, ok := s.db.(*sql.DB)
+	if !ok {
+		panic("can't support full GORM on currently status, maybe this is a TX instance.")
+	}
 	return db
 }