mirror of https://github.com/go-gorm/gorm.git
tests/sqilte: enable FOREIGN_KEYS inside OpenTestConnection (#6641)
This commit is contained in:
parent
6bef318891
commit
78e905919f
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue