From 8a027ac60cadea17efc3b8eeb55bbba24f920e65 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 6 Sep 2010 14:18:00 +0100 Subject: [PATCH] Fix problem where db.set_author forced a recalculation of author_sort whenever editing metadata of a book with a unique author (only book with that author). The problem arose because the author was deleted from the DB then recreated, causing the trigger to be fired. --- src/calibre/gui2/dialogs/metadata_single.py | 1 + src/calibre/library/database2.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py index 1393a50738..82b6ac8cbf 100644 --- a/src/calibre/gui2/dialogs/metadata_single.py +++ b/src/calibre/gui2/dialogs/metadata_single.py @@ -760,6 +760,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog): _('Could not open %s. Is it being used by another' ' program?')%fname, show=True) raise + self.db.clean() self.save_state() QDialog.accept(self) if callable(self.accepted_callback): diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 3b7efd500d..93c42ea342 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1126,7 +1126,6 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): if not authors: authors = [_('Unknown')] self.conn.execute('DELETE FROM books_authors_link WHERE book=?',(id,)) - self.conn.execute('DELETE FROM authors WHERE (SELECT COUNT(id) FROM books_authors_link WHERE author=authors.id) < 1') for a in authors: if not a: continue