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 /roomserver/storage | |
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 'roomserver/storage')
-rw-r--r-- | roomserver/storage/postgres/state_snapshot_table.go | 3 | ||||
-rw-r--r-- | roomserver/storage/sqlite3/state_block_table.go | 4 | ||||
-rw-r--r-- | roomserver/storage/sqlite3/state_snapshot_table.go | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/roomserver/storage/postgres/state_snapshot_table.go b/roomserver/storage/postgres/state_snapshot_table.go index 0f8f1c51..63175955 100644 --- a/roomserver/storage/postgres/state_snapshot_table.go +++ b/roomserver/storage/postgres/state_snapshot_table.go @@ -21,6 +21,7 @@ import ( "fmt" "github.com/lib/pq" + "github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/roomserver/storage/shared" "github.com/matrix-org/dendrite/roomserver/storage/tables" "github.com/matrix-org/dendrite/roomserver/types" @@ -86,7 +87,7 @@ func (s *stateSnapshotStatements) InsertState( for i := range stateBlockNIDs { nids[i] = int64(stateBlockNIDs[i]) } - err = txn.Stmt(s.insertStateStmt).QueryRowContext(ctx, int64(roomNID), pq.Int64Array(nids)).Scan(&stateNID) + err = sqlutil.TxStmt(txn, s.insertStateStmt).QueryRowContext(ctx, int64(roomNID), pq.Int64Array(nids)).Scan(&stateNID) return } diff --git a/roomserver/storage/sqlite3/state_block_table.go b/roomserver/storage/sqlite3/state_block_table.go index 8033903f..2c544f2b 100644 --- a/roomserver/storage/sqlite3/state_block_table.go +++ b/roomserver/storage/sqlite3/state_block_table.go @@ -105,12 +105,12 @@ func (s *stateBlockStatements) BulkInsertStateData( return 0, nil } var stateBlockNID types.StateBlockNID - err := txn.Stmt(s.selectNextStateBlockNIDStmt).QueryRowContext(ctx).Scan(&stateBlockNID) + err := sqlutil.TxStmt(txn, s.selectNextStateBlockNIDStmt).QueryRowContext(ctx).Scan(&stateBlockNID) if err != nil { return 0, err } for _, entry := range entries { - _, err = txn.Stmt(s.insertStateDataStmt).ExecContext( + _, err = sqlutil.TxStmt(txn, s.insertStateDataStmt).ExecContext( ctx, int64(stateBlockNID), int64(entry.EventTypeNID), diff --git a/roomserver/storage/sqlite3/state_snapshot_table.go b/roomserver/storage/sqlite3/state_snapshot_table.go index 392c2a67..bf49f62c 100644 --- a/roomserver/storage/sqlite3/state_snapshot_table.go +++ b/roomserver/storage/sqlite3/state_snapshot_table.go @@ -76,7 +76,7 @@ func (s *stateSnapshotStatements) InsertState( if err != nil { return } - insertStmt := txn.Stmt(s.insertStateStmt) + insertStmt := sqlutil.TxStmt(txn, s.insertStateStmt) res, err := insertStmt.ExecContext(ctx, int64(roomNID), string(stateBlockNIDsJSON)) if err != nil { return 0, err |