aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage/postgres/rooms_table.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-03-17 18:00:10 +0000
committerGitHub <noreply@github.com>2020-03-17 18:00:10 +0000
commitc2bd0b97b34c9040325bf31c5c4a2a06579239d9 (patch)
tree45af6cf66af901b1a285fb8be6f7db278bea4dcd /roomserver/storage/postgres/rooms_table.go
parent1467cc10d8bd40b9ea85bc4f0aa4644b16cb37bb (diff)
Get room versions from database (#918)
* Retrieve room version where known in roomserver * Get room versions in alias code * Increase gocyclothreshold to 13, since we hit that number a lot * Remove gocyclo nolint from StoreEvent * Update interface to get room version from room ID instead of NID * Remove new API * Fixed this query for SQLite but not for Postgres
Diffstat (limited to 'roomserver/storage/postgres/rooms_table.go')
-rw-r--r--roomserver/storage/postgres/rooms_table.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/roomserver/storage/postgres/rooms_table.go b/roomserver/storage/postgres/rooms_table.go
index ef8b8ece..6bb96f1d 100644
--- a/roomserver/storage/postgres/rooms_table.go
+++ b/roomserver/storage/postgres/rooms_table.go
@@ -65,8 +65,8 @@ const selectLatestEventNIDsForUpdateSQL = "" +
const updateLatestEventNIDsSQL = "" +
"UPDATE roomserver_rooms SET latest_event_nids = $2, last_event_sent_nid = $3, state_snapshot_nid = $4 WHERE room_nid = $1"
-const selectRoomVersionForRoomNIDSQL = "" +
- "SELECT room_version FROM roomserver_rooms WHERE room_nid = $1"
+const selectRoomVersionForRoomIDSQL = "" +
+ "SELECT room_version FROM roomserver_rooms WHERE room_id = $1"
type roomStatements struct {
insertRoomNIDStmt *sql.Stmt
@@ -74,7 +74,7 @@ type roomStatements struct {
selectLatestEventNIDsStmt *sql.Stmt
selectLatestEventNIDsForUpdateStmt *sql.Stmt
updateLatestEventNIDsStmt *sql.Stmt
- selectRoomVersionForRoomNIDStmt *sql.Stmt
+ selectRoomVersionForRoomIDStmt *sql.Stmt
}
func (s *roomStatements) prepare(db *sql.DB) (err error) {
@@ -88,7 +88,7 @@ func (s *roomStatements) prepare(db *sql.DB) (err error) {
{&s.selectLatestEventNIDsStmt, selectLatestEventNIDsSQL},
{&s.selectLatestEventNIDsForUpdateStmt, selectLatestEventNIDsForUpdateSQL},
{&s.updateLatestEventNIDsStmt, updateLatestEventNIDsSQL},
- {&s.selectRoomVersionForRoomNIDStmt, selectRoomVersionForRoomNIDSQL},
+ {&s.selectRoomVersionForRoomIDStmt, selectRoomVersionForRoomIDSQL},
}.prepare(db)
}
@@ -165,11 +165,11 @@ func (s *roomStatements) updateLatestEventNIDs(
return err
}
-func (s *roomStatements) selectRoomVersionForRoomNID(
- ctx context.Context, txn *sql.Tx, roomNID types.RoomNID,
+func (s *roomStatements) selectRoomVersionForRoomID(
+ ctx context.Context, txn *sql.Tx, roomID string,
) (gomatrixserverlib.RoomVersion, error) {
var roomVersion gomatrixserverlib.RoomVersion
- stmt := common.TxStmt(txn, s.selectRoomVersionForRoomNIDStmt)
- err := stmt.QueryRowContext(ctx, roomNID).Scan(&roomVersion)
+ stmt := common.TxStmt(txn, s.selectRoomVersionForRoomIDStmt)
+ err := stmt.QueryRowContext(ctx, roomID).Scan(&roomVersion)
return roomVersion, err
}