From a2f95fdc4d0826d0b20e8b4dd91f5bb59bff5bcd Mon Sep 17 00:00:00 2001 From: David Dworken Date: Tue, 20 Sep 2022 21:15:20 -0700 Subject: [PATCH] Fix typo in SQL query --- backend/server/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/server/server.go b/backend/server/server.go index 5203d6c..70fdf9c 100644 --- a/backend/server/server.go +++ b/backend/server/server.go @@ -114,6 +114,8 @@ func apiQueryHandler(w http.ResponseWriter, r *http.Request) { panic(result.Error) } + // Delete any entries that match a pending deletion request + // Then retrieve, to avoid a race condition tx := GLOBAL_DB.Where("device_id = ? AND read_count < 5", deviceId) var historyEntries []*shared.EncHistoryEntry @@ -212,7 +214,7 @@ func getDeletionRequestsHandler(w http.ResponseWriter, r *http.Request) { deviceId := getRequiredQueryParam(r, "device_id") // Increment the ReadCount - result := GLOBAL_DB.Exec("UPDATE deletion_requesy SET read_count = read_count + 1 WHERE destination_device_id = ? AND user_id = ?", deviceId, userId) + result := GLOBAL_DB.Exec("UPDATE deletion_requests SET read_count = read_count + 1 WHERE destination_device_id = ? AND user_id = ?", deviceId, userId) if result.Error != nil { panic(result.Error) }