From a0b9a799d97e44f650cf1ac337d63b2062a36809 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Aug 2023 11:31:13 +0530 Subject: [PATCH] custom ratings tables should not support notes --- src/calibre/db/tables.py | 6 ++++-- src/calibre/db/write.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/db/tables.py b/src/calibre/db/tables.py index ae2199130f..74cd08f11c 100644 --- a/src/calibre/db/tables.py +++ b/src/calibre/db/tables.py @@ -57,18 +57,20 @@ class Table: def __init__(self, name, metadata, link_table=None): self.name, self.metadata = name, metadata self.sort_alpha = metadata.get('is_multiple', False) and metadata.get('display', {}).get('sort_alpha', False) + dt = metadata['datatype'] # self.unserialize() maps values from the db to python objects self.unserialize = { 'datetime': c_parse, 'bool': bool - }.get(metadata['datatype'], None) + }.get(dt) if name == 'authors': # Legacy self.unserialize = lambda x: x.replace('|', ',') if x else '' - self.link_table = (link_table if link_table else 'books_%s_link'%self.metadata['table']) + if self.supports_notes and dt == 'rating': # custom ratings table + self.supports_notes = False def remove_books(self, book_ids, db): return set() diff --git a/src/calibre/db/write.py b/src/calibre/db/write.py index d0442caf53..af5d1b9a14 100644 --- a/src/calibre/db/write.py +++ b/src/calibre/db/write.py @@ -297,7 +297,7 @@ def get_db_id(val, db, m, table, kmap, rid_map, allow_case_change, table.asort_map[item_id] = aus if hasattr(table, 'link_map'): table.link_map[item_id] = '' - if table.supports_notes and isinstance(val, str): + if table.supports_notes: db.unretire_note(table.name, item_id, val) elif allow_case_change and val != table.id_map[item_id]: case_changes[item_id] = val