diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 80b925e770..82ed243a14 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -2351,9 +2351,15 @@ class Cache: @read_api def split_if_is_multiple_composite(self, f, v): + ''' + 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 + comparison is case-insensitive. If values are case-insensitive equals + then the last is returned. + ''' fm = self.field_metadata.get(f, None) if fm and fm['datatype'] == 'composite' and fm['is_multiple']: - return [v.strip() for v in v.split(',') if v.strip()] + return list({v.strip().lower() : v.strip() for v in v.split(',') if v.strip()}.values()) return v @read_api diff --git a/src/calibre/gui2/dialogs/quickview.py b/src/calibre/gui2/dialogs/quickview.py index 2a17db7c2d..3fcaa0e7c6 100644 --- a/src/calibre/gui2/dialogs/quickview.py +++ b/src/calibre/gui2/dialogs/quickview.py @@ -542,10 +542,9 @@ class Quickview(QDialog, Ui_Quickview): self.books_table.setRowCount(0) mi = self.db.new_api.get_proxy_metadata(book_id) - vals = mi.get(key, None) - if self.fm[key]['datatype'] == 'composite' and self.fm[key]['is_multiple']: - sep = self.fm[key]['is_multiple'].get('cache_to_list', ',') - vals = [v.strip() for v in vals.split(sep) if v.strip()] + print('aaa', key, mi.get(key, None)) + vals = self.db.new_api.split_if_is_multiple_composite(key, mi.get(key, None)) + print('bbb', vals) try: # Check if we are in the GridView and there are no values for the # selected column. In this case switch the column to 'authors'