~emersion/soju-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2

[PATCH] Fix DeliveryReceipt not being cleaned up

Details
Message ID
<20210913162401.22541-1-hubert@hirtz.pm>
DKIM signature
pass
Download raw message
Patch: +16 -0
---
 db_sqlite.go | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/db_sqlite.go b/db_sqlite.go
index 6413acc..7c0840a 100644
--- a/db_sqlite.go
+++ b/db_sqlite.go
@@ -289,6 +289,17 @@ func (db *SqliteDB) DeleteUser(id int64) error {
	}
	defer tx.Rollback()

	_, err = tx.Exec(`DELETE FROM DeliveryReceipt
		WHERE id IN (
			SELECT DeliveryReceipt.id
			FROM DeliveryReceipt
			JOIN Network ON DeliveryReceipt.network = Network.id
			WHERE Network.user = ?
		)`, id)
	if err != nil {
		return err
	}

	_, err = tx.Exec(`DELETE FROM Channel
		WHERE id IN (
			SELECT Channel.id
@@ -422,6 +433,11 @@ func (db *SqliteDB) DeleteNetwork(id int64) error {
	}
	defer tx.Rollback()

	_, err = tx.Exec("DELETE FROM DeliveryReceipt WHERE network = ?", id)
	if err != nil {
		return err
	}

	_, err = tx.Exec("DELETE FROM Channel WHERE network = ?", id)
	if err != nil {
		return err
-- 
2.33.0
Details
Message ID
<j4jxJWiMXsiYbjdi5PiUjJsyfwv-NzgL4Oz27K-XutfrhOTrBhl5JdlgsT8yjF-XNPhsnirGDvQ-GafH8ESNqiI_bNfpKMTcBigOtKzMngk=@emersion.fr>
In-Reply-To
<20210913162401.22541-1-hubert@hirtz.pm> (view parent)
DKIM signature
pass
Download raw message
Pushed, thanks for the fix!
Details
Message ID
<pOMoCNDLvUaDLhWtSH8fvRWx_XJQAWlsi8xzU4PYVz09qFjXis0Z8FZ9jminERq6VzVRw_semjrICMwW7pDXx_TlEboCLakvrCss2zh9A0E=@emersion.fr>
In-Reply-To
<20210913162401.22541-1-hubert@hirtz.pm> (view parent)
DKIM signature
pass
Download raw message
BTW, I wonder if we should be using cascade delete so that we can avoid these
extra queries and ensure database consistency. OTOH, updating tables is a pain
with SQLite…
Reply to thread Export thread (mbox)