core: Fix/unify SQL for forward message fetch
authorShane Synan <digitalcircuit36939@gmail.com>
Fri, 10 Jul 2020 21:23:18 +0000 (17:23 -0400)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 4 Oct 2020 15:01:02 +0000 (17:01 +0200)
NOTE: This commit should be squashed into the previous commit from
justJanne.  It's committed separately just to make it easier to see
what I changed.

Fixup the SQLite and PostgreSQL queries to treat "<= 0" as any
type/flag instead of just "= 0".  This matches the function
definitions and fixes specifying "-1" instead of "0".  Without this
change, specifying "-1" will result in missing messages!

src/core/SQL/PostgreSQL/select_messagesForward.sql
src/core/SQL/SQLite/select_messagesForward.sql

index e645e96..d8e76e8 100644 (file)
@@ -1,10 +1,10 @@
-SELECT messageid, time,  type, flags, sender, senderprefixes, realname, avatarurl, message
+SELECT messageid, time, type, flags, sender, senderprefixes, realname, avatarurl, message
 FROM backlog
 JOIN sender ON backlog.senderid = sender.senderid
 WHERE backlog.messageid >= $1
     AND backlog.messageid < $2
     AND bufferid = $3
-    AND backlog.type & $4 != 0
-    AND ($5 = 0 OR backlog.flags & $5 != 0)
+    AND ($4 <= 0 OR backlog.type & $4 != 0)
+    AND ($5 <= 0 OR backlog.flags & $5 != 0)
 ORDER BY messageid ASC
 LIMIT $6
index 881bb9f..e4e7819 100644 (file)
@@ -1,10 +1,10 @@
-SELECT messageid, time,  type, flags, sender, senderprefixes, realname, avatarurl, message
+SELECT messageid, time, type, flags, sender, senderprefixes, realname, avatarurl, message
 FROM backlog
 JOIN sender ON backlog.senderid = sender.senderid
 WHERE bufferid = :bufferid
     AND backlog.messageid >= :firstmsg
     AND backlog.messageid < :lastmsg
-    AND (:type = 0 OR backlog.type & :type != 0)
-    AND (:flags = 0 OR backlog.flags & :flags != 0)
+    AND (:type <= 0 OR backlog.type & :type != 0)
+    AND (:flags <= 0 OR backlog.flags & :flags != 0)
 ORDER BY messageid ASC
 LIMIT :limit