Use NULL-tolerant comparison for DeliveryReceipts

Since NULL = NULL is always FALSE, this query needs to use IS instead.
This should fix the flood of DeliveryReceipts in the DB.

See https://www.sqlite.org/lang_expr.html

> The IS and IS NOT operators work like = and != except when one or both
> of the operands are NULL. In this case, if both operands are NULL,
> then the IS operator evaluates to 1 (true) and the IS NOT operator
> evaluates to 0 (false). If one operand is NULL and the other is not,
> then the IS operator evaluates to 0 (false) and the IS NOT operator is
> 1 (true). It is not possible for an IS or IS NOT expression to
> evaluate to NULL.

git-svn-id: file:///srv/svn/repo/suika/trunk@589 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
hubert 2021-09-14 16:38:58 +00:00
parent e0e9f5d21a
commit b19b03fa6d

View File

@ -542,7 +542,7 @@ func (db *SqliteDB) StoreClientDeliveryReceipts(networkID int64, client string,
}
defer tx.Rollback()
_, err = tx.Exec("DELETE FROM DeliveryReceipt WHERE network = ? AND client = ?",
_, err = tx.Exec("DELETE FROM DeliveryReceipt WHERE network = ? AND client IS ?",
networkID, toNullString(client))
if err != nil {
return err