DobyTang / LazyLibrarian

This project isn't finished yet. Goal is to create a SickBeard, CouchPotato, Headphones-like application for ebooks. Headphones is used as a base, so there are still a lot of references to it.
729 stars 72 forks source link

Foreign Key error on Member during author update #1655

Closed wizzy99 closed 5 years ago

wizzy99 commented 5 years ago

Current Version: 37efad16ddce03a37677bd0192fea5718461abf4

I was running an author update and triggered the following error. SeriesID 185644 exists in the Series table, BookID 42633199 does not exist in Books.

05-Nov-2018 15:08:07 - ERROR :: API : database.py:_action:88 : Database Integrity error: FOREIGN KEY constraint failed 05-Nov-2018 15:08:07 - ERROR :: API : database.py:_action:89 : Failed query: [INSERT INTO member (SeriesNum, WorkID, SeriesID, BookID) VALUES (?, ?, ?, ?)] 05-Nov-2018 15:08:07 - ERROR :: API : database.py:_action:90 : Failed args: [[u'2.5', '66366292', 185644, '42633199']] 05-Nov-2018 15:08:07 - ERROR :: API : gr.py:get_author_books:963 : Unhandled exception in GR.get_author_books: Traceback (most recent call last): File "/app/lazylibrarian/lazylibrarian/gr.py", line 759, in get_author_books _api_hits, originalpubdate = setSeries(serieslist, bookid, authorid, workid) File "/app/lazylibrarian/lazylibrarian/bookwork.py", line 173, in setSeries myDB.upsert("member", newValueDict, controlValueDict) File "/app/lazylibrarian/lazylibrarian/database.py", line 143, in upsert self._action(query, list(valueDict.values()) + list(keyDict.values()), suppress="UNIQUE") File "/app/lazylibrarian/lazylibrarian/database.py", line 58, in _action sqlResult = self.connection.execute(query, args) IntegrityError: FOREIGN KEY constraint failed

philborman commented 5 years ago

Bug adding a new book to an existing series, trying to update the series before the book has been added. Should be easy to fix, the new foreign_key constraint is much more strict but should stop orphans in the database. Will fix this shortly.