From 2ae0cc048d489204161f29e825485920c0604662 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 27 Jun 2011 17:18:51 +0100 Subject: [PATCH] Make get_categories respect a search restriction that finds no books. This is an incompatible change, as [] used to mean no restriction and now it means no books. Tested with tag browser and content server. --- src/calibre/library/database2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 8b4ad47284..9229d44cac 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1442,7 +1442,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): raise ValueError('sort ' + sort + ' not a valid value') self.books_list_filter.change([] if not ids else ids) - id_filter = None if not ids else frozenset(ids) + id_filter = None if ids is None else frozenset(ids) tb_cats = self.field_metadata tcategories = {} @@ -1520,7 +1520,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): rating_dex = self.FIELD_MAP['rating'] tag_class = LibraryDatabase2.TCat_Tag for book in self.data.iterall(): - if id_filter and book[id_dex] not in id_filter: + if id_filter is not None and book[id_dex] not in id_filter: continue rating = book[rating_dex] # We kept track of all possible category field_map positions above