Skip to content

Commit

Permalink
dialect/sql/schema: disable foreign keys before opening a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
masseelch committed Sep 27, 2022
1 parent 8b86528 commit f312edd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
2 changes: 1 addition & 1 deletion dialect/sql/schema/sqlite.go
Expand Up @@ -44,7 +44,7 @@ func (d *SQLite) Tx(ctx context.Context) (dialect.Tx, error) {
if err != nil {
return nil, err
}
tx := &tx{ExecQuerier: t, Tx: t}
tx := &tx{t}
cm, err := sqlite.CommitFunc(ctx, db, tx, true)
return &SQLiteTx{Tx: t, commit: cm, rollback: sqlite.RollbackFunc(ctx, db, tx, true)}, nil
}
Expand Down
8 changes: 0 additions & 8 deletions dialect/sql/schema/sqlite_test.go
Expand Up @@ -467,14 +467,6 @@ func (m sqliteMock) commit() {
WillReturnResult(sqlmock.NewResult(0, 1))
}

func (m sqliteMock) rollback() {
m.ExpectQuery("PRAGMA foreign_key_check").
WillReturnRows(sqlmock.NewRows([]string{})) // empty
m.ExpectRollback()
m.ExpectExec("PRAGMA foreign_keys = on").
WillReturnResult(sqlmock.NewResult(0, 1))
}

func (m sqliteMock) tableExists(table string, exists bool) {
count := 0
if exists {
Expand Down

0 comments on commit f312edd

Please sign in to comment.