Fix database queries

This commit is contained in:
Neil Alexander 2021-07-09 14:44:41 +01:00
parent 2b93b5dcb7
commit 47a5204734
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 3 additions and 2 deletions

View file

@ -130,7 +130,8 @@ var selectKnownUsersSQL = "" +
// is expensive. The presence of a single row from this query suggests we're still in the
// room, no rows returned suggests we aren't.
const selectLocalServerInRoomSQL = "" +
"SELECT TOP 1 room_nid FROM roomserver_membership WHERE target_local = true AND membership_nid = 3 AND room_nid = $1"
"SELECT room_nid FROM roomserver_membership WHERE target_local = true AND membership_nid = 3 AND room_nid = $1 " +
"FETCH FIRST 1 ROWS ONLY"
type membershipStatements struct {
insertMembershipStmt *sql.Stmt

View file

@ -106,7 +106,7 @@ var selectKnownUsersSQL = "" +
// is expensive. The presence of a single row from this query suggests we're still in the
// room, no rows returned suggests we aren't.
const selectLocalServerInRoomSQL = "" +
"SELECT room_nid FROM roomserver_membership WHERE target_local = true AND membership_nid = 3 AND room_nid = $1 LIMIT 1"
"SELECT room_nid FROM roomserver_membership WHERE target_local = 1 AND membership_nid = 3 AND room_nid = $1 LIMIT 1"
type membershipStatements struct {
db *sql.DB