tests/sqilte: enable FOREIGN_KEYS inside OpenTestConnection (#6641)
This commit is contained in:
+4
-4
@@ -43,9 +43,6 @@ func init() {
|
||||
}
|
||||
|
||||
RunMigrations()
|
||||
if DB.Dialector.Name() == "sqlite" {
|
||||
DB.Exec("PRAGMA foreign_keys = ON")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +86,10 @@ func OpenTestConnection(cfg *gorm.Config) (db *gorm.DB, err error) {
|
||||
db, err = gorm.Open(mysql.Open(dbDSN), cfg)
|
||||
default:
|
||||
log.Println("testing sqlite3...")
|
||||
db, err = gorm.Open(sqlite.Open(filepath.Join(os.TempDir(), "gorm.db?_foreign_keys=on")), cfg)
|
||||
db, err = gorm.Open(sqlite.Open(filepath.Join(os.TempDir(), "gorm.db")), cfg)
|
||||
if err == nil {
|
||||
db.Exec("PRAGMA foreign_keys = ON")
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user