Fix composite column searching to make #x:false. Before, books with an empty column were not returned. With this change it returns None.

This commit is contained in:
Charles Haley 2022-09-25 13:24:06 +01:00
parent 270f503775
commit e2f34bc386

View File

@ -345,9 +345,16 @@ class CompositeField(OneToOneField):
for book_id in candidates:
vals = self.get_value_with_cache(book_id, get_metadata)
vals = (vv.strip() for vv in vals.split(splitter)) if splitter else (vals,)
found = False
for v in vals:
if v:
val_map[v].add(book_id)
found = True
if not found:
# Convert columns with no value to None to ensure #x:false
# searches work. We do it outside the loop to avoid generating
# None for is_multiple columns containing text like "a,,,b".
val_map[None].add(book_id)
yield from iteritems(val_map)
def iter_counts(self, candidates, get_metadata=None):