Skip to content

Commit

Permalink
Merge pull request #24 from twharmon/tx-fix
Browse files Browse the repository at this point in the history
Fix tx bug
  • Loading branch information
twharmon authored Sep 3, 2020
2 parents 5308b6d + e0f004a commit fc0d354
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ func (db *DB) mustBeValid(m *model) error {
}

// Begin starts a transaction.
func (db *DB) Begin() (*sql.Tx, error) {
return db.db.Begin()
func (db *DB) Begin() (*Tx, error) {
sqlTx, err := db.db.Begin()
tx := Tx{
tx: sqlTx,
db: db,
}
return &tx, err
}

// Insert insterts a row in the database.
Expand Down

0 comments on commit fc0d354

Please sign in to comment.