Fix custom series indicies being preserved when a custom series is cleared, making the column sort correctly. The problem is that the series index is still in the table cache for a book after the series is removed.

See https://www.mobileread.com/forums/showthread.php?p=4142361#post4142361

I freely confess that this might not be the best fix. :)
This commit is contained in:
Charles Haley 2021-07-28 12:32:04 +01:00
parent 96d5d5a764
commit 9ae0c1df95

View File

@ -239,7 +239,10 @@ def custom_series_index(book_id_val_map, db, field, *args):
ids = series_field.ids_for_book(book_id)
if ids:
sequence.append((sidx, book_id, ids[0]))
field.table.book_col_map[book_id] = sidx
if series_field.table.book_col_map.get(book_id) is None:
field.table.book_col_map.pop(book_id, None)
else:
field.table.book_col_map[book_id] = sidx
if sequence:
db.executemany('UPDATE %s SET %s=? WHERE book=? AND value=?'%(
field.metadata['table'], field.metadata['column']), sequence)