diff options
author | Sam <me@samcday.com> | 2020-09-24 12:10:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-24 11:10:14 +0100 |
commit | a6700331cee70a3ca04c834efdc68cc2ef63947d (patch) | |
tree | 10420639a2a4685b2562ff1d106d1ae9a11712d4 /internal | |
parent | 60524f4b994ba070fff74fa47599e0fcc7856fc0 (diff) |
Update all usages of tx.Stmt to sqlutil.TxStmt (#1423)
* Replace all usages of txn.Stmt with sqlutil.TxStmt
Signed-off-by: Sam Day <me@samcday.com>
* Fix sign off link in PR template.
Signed-off-by: Sam Day <me@samcday.com>
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'internal')
-rw-r--r-- | internal/sqlutil/sql.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/sqlutil/sql.go b/internal/sqlutil/sql.go index 90562ded..a3885d66 100644 --- a/internal/sqlutil/sql.go +++ b/internal/sqlutil/sql.go @@ -88,6 +88,14 @@ func TxStmt(transaction *sql.Tx, statement *sql.Stmt) *sql.Stmt { return statement } +// TxStmtContext behaves similarly to TxStmt, with support for also passing context. +func TxStmtContext(context context.Context, transaction *sql.Tx, statement *sql.Stmt) *sql.Stmt { + if transaction != nil { + statement = transaction.StmtContext(context, statement) + } + return statement +} + // Hack of the century func QueryVariadic(count int) string { return QueryVariadicOffset(count, 0) |