[Store] Fix more queries

This commit is contained in:
Christian Pauly 2019-08-08 14:13:32 +02:00
parent c2c93c2da9
commit d661fb4289

View file

@ -156,8 +156,8 @@ class Store {
} }
Future<void> storeRoomPrevBatch(Room room) async { Future<void> storeRoomPrevBatch(Room room) async {
await _db.rawUpdate( await _db.rawUpdate("UPDATE Rooms SET prev_batch=? WHERE room_id=?",
"UPDATE Rooms SET prev_batch=? WHERE id=?", [room.prev_batch, room.id]); [room.prev_batch, room.id]);
return null; return null;
} }
@ -189,7 +189,7 @@ class Store {
updateQuery += ", heroes=?"; updateQuery += ", heroes=?";
updateArgs.add(roomUpdate.summary.mHeroes.join(",")); updateArgs.add(roomUpdate.summary.mHeroes.join(","));
} }
updateQuery += " WHERE id=?"; updateQuery += " WHERE room_id=?";
updateArgs.add(roomUpdate.id); updateArgs.add(roomUpdate.id);
txn.rawUpdate(updateQuery, updateArgs); txn.rawUpdate(updateQuery, updateArgs);
@ -343,7 +343,7 @@ class Store {
"SELECT * " + "SELECT * " +
" FROM Events " + " FROM Events " +
" WHERE room_id=?" + " WHERE room_id=?" +
" GROUP BY id " + " GROUP BY event_id " +
" ORDER BY origin_server_ts DESC", " ORDER BY origin_server_ts DESC",
[room.id]); [room.id]);
@ -379,7 +379,7 @@ class Store {
/// Returns a room without events and participants. /// Returns a room without events and participants.
Future<Room> getRoomById(String id) async { Future<Room> getRoomById(String id) async {
List<Map<String, dynamic>> res = List<Map<String, dynamic>> res =
await db.rawQuery("SELECT * FROM Rooms WHERE id=?", [id]); await db.rawQuery("SELECT * FROM Rooms WHERE room_id=?", [id]);
if (res.length != 1) return null; if (res.length != 1) return null;
return Room.getRoomFromTableRow(res[0], client, return Room.getRoomFromTableRow(res[0], client,
states: getStatesFromRoomId(id)); states: getStatesFromRoomId(id));
@ -390,7 +390,7 @@ class Store {
} }
Future<void> forgetRoom(String roomID) async { Future<void> forgetRoom(String roomID) async {
await db.rawDelete("DELETE FROM Rooms WHERE id=?", [roomID]); await db.rawDelete("DELETE FROM Rooms WHERE room_id=?", [roomID]);
return; return;
} }