From e2c3bb40a51a3f11137a047fbfe0d2d2edbb81e4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 1 Aug 2013 07:41:49 +0530 Subject: [PATCH] newdb: Fix default value for identifiers is mutable --- src/calibre/db/fields.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/db/fields.py b/src/calibre/db/fields.py index 50fa658b29..e47e366c9b 100644 --- a/src/calibre/db/fields.py +++ b/src/calibre/db/fields.py @@ -410,7 +410,10 @@ class IdentifiersField(ManyToManyField): def for_book(self, book_id, default_value=None): ids = self.table.book_col_map.get(book_id, ()) if not ids: - ids = default_value + try: + ids = default_value.copy() # in case default_value is a mutable dict + except AttributeError: + ids = default_value return ids def sort_keys_for_books(self, get_metadata, lang_map, all_book_ids):