From: Benjamin Auder Date: Mon, 16 Mar 2020 19:27:55 +0000 (+0100) Subject: Fix SQL query to get completed games X-Git-Url: https://git.auder.net/pieces/current/doc/html/R.css?a=commitdiff_plain;h=11589e7c4bb1b69473588d133db8b6d1d37b8fee;p=vchess.git Fix SQL query to get completed games --- diff --git a/server/models/Game.js b/server/models/Game.js index 080cab3c..641c0dce 100644 --- a/server/models/Game.js +++ b/server/models/Game.js @@ -232,11 +232,18 @@ const GameModel = "JOIN Variants v " + " ON g.vid = v.id " + "WHERE " + - " score <> '*' AND " + - " created < " + cursor + " AND " + + " score <> '*' AND" + + " created < " + cursor + " AND" + " (" + - " (" + uid + " = white AND NOT deletedByWhite) OR " + - " (" + uid + " = black AND NOT deletedByBlack)" + + " (" + + " white = " + uid + " AND" + + " (deletedByWhite IS NULL OR NOT deletedByWhite)" + + " )" + + " OR " + + " (" + + " black = " + uid + " AND" + + " (deletedByBlack IS NULL OR NOT deletedByBlack)" + + " )" + " ) "; query += "ORDER BY created DESC " +