Skip to content
Snippets Groups Projects

make database.DB transactable

Created by: camdencheek

This PR makes database.DB transactable by wrapping a basestore.Store rather than a dbutil.DB directly. This allows us to run db.Transact(), get a new transaction, then call tx.Repos() or whatever to get a more specific store. It also allows us to use transactions for small tasks that don't have a store associated with them, such as GetFirstServiceVersion. This makes it now possible to remove the dbconn.Global reference in that function, and migrate those tests to use dbtest.NewDB() rather than dbtesting.SetupGlobalDB().

Example:

db := database.NewDB(sqlDB)
tx, _ := db.Transact(ctx)
tx.Repos() // do something with repos
tx.Users() // do something with users in the same transaction

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading