From 86bd4623d40e6c1ba47c776c55b2d7ebc267e7e1 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Sun, 15 Nov 2020 11:10:05 +0000 Subject: [PATCH] Bug 1904305: annotation_count() displaying value for deleted annotations --- src/calibre/db/backend.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/db/backend.py b/src/calibre/db/backend.py index eed2f105bc..e6360c2d91 100644 --- a/src/calibre/db/backend.py +++ b/src/calibre/db/backend.py @@ -1949,7 +1949,10 @@ class DB(object): return changed def annotation_count_for_book(self, book_id): - for (count,) in self.execute('SELECT count(id) FROM annotations WHERE book=?', (book_id,)): + for (count,) in self.execute(''' + SELECT count(id) FROM annotations + WHERE book=? AND json_extract(annot_data, "$.removed") IS NULL + ''', (book_id,)): return count return 0