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!
-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
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
ORDER BY messageid ASC
LIMIT $6
-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
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
ORDER BY messageid ASC
LIMIT :limit