mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Change the implementation to not do case insensitive comparison, because no other part of calibre does that with composites. For correctness get the split value from field metadata, even though at the moment it can only be a comma.
Return a list for compatibility with other field getters. There are a fair number of places that do isinstance(v, list).
This commit is contained in:
parent
45275a4824
commit
f1f597a06b
@ -2350,17 +2350,18 @@ class Cache:
|
|||||||
return self._books_for_field(f.name, int(item_id_or_composite_value))
|
return self._books_for_field(f.name, int(item_id_or_composite_value))
|
||||||
|
|
||||||
@read_api
|
@read_api
|
||||||
def split_if_is_multiple_composite(self, f, v):
|
def split_if_is_multiple_composite(self, f, val):
|
||||||
'''
|
'''
|
||||||
If f is a composite column lookup key and the column is is_multiple then
|
If f is a composite column lookup key and the column is is_multiple then
|
||||||
split comma-separated v into unique non-empty values. The uniqueness
|
split v into unique non-empty values. The comparison is case sensitive.
|
||||||
comparison is case-insensitive. If values are case-insensitive equals
|
Order is not preserved. Return a list() for compatibility with proxy
|
||||||
then the last is returned.
|
metadata field getters, for example tags.
|
||||||
'''
|
'''
|
||||||
fm = self.field_metadata.get(f, None)
|
fm = self.field_metadata.get(f, None)
|
||||||
if fm and fm['datatype'] == 'composite' and fm['is_multiple']:
|
if fm and fm['datatype'] == 'composite' and fm['is_multiple']:
|
||||||
return list({v.strip().lower() : v.strip() for v in v.split(',') if v.strip()}.values())
|
sep = fm['is_multiple'].get('cache_to_list', ',')
|
||||||
return v
|
return (list(set(v.strip() for v in val.split(sep) if v.strip())))
|
||||||
|
return val
|
||||||
|
|
||||||
@read_api
|
@read_api
|
||||||
def data_for_find_identical_books(self):
|
def data_for_find_identical_books(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user