mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix set_custom legacy API for series fields with index in value
Fixes #1220914 [db.set_custom on custom series column ignores [number]](https://bugs.launchpad.net/calibre/+bug/1220914)
This commit is contained in:
parent
ff18978f1c
commit
58ac84cb57
@ -20,7 +20,7 @@ from calibre.db.cache import Cache
|
||||
from calibre.db.errors import NoSuchFormat
|
||||
from calibre.db.categories import CATEGORY_SORTS
|
||||
from calibre.db.view import View
|
||||
from calibre.db.write import clean_identifier
|
||||
from calibre.db.write import clean_identifier, get_series_values
|
||||
from calibre.utils.date import utcnow
|
||||
from calibre.utils.search_query_parser import set_saved_searches
|
||||
|
||||
@ -645,6 +645,8 @@ class LibraryDatabase(object):
|
||||
else:
|
||||
affected_books = self.new_api._set_field(field, {book_id:val}, allow_case_change=allow_case_change)
|
||||
if data['datatype'] == 'series':
|
||||
s, sidx = get_series_values(val)
|
||||
if sidx is None:
|
||||
extra = 1.0 if extra is None else extra
|
||||
self.new_api._set_field(field + '_index', {book_id:extra})
|
||||
if notify and affected_books:
|
||||
|
@ -760,6 +760,12 @@ class LegacyTest(BaseTest):
|
||||
ndb.delete_custom_column('created')
|
||||
ndb = self.init_legacy(n)
|
||||
self.assertRaises(KeyError, ndb.custom_field_name, num=num)
|
||||
|
||||
# Test setting custom series
|
||||
ndb = self.init_legacy(self.cloned_library)
|
||||
ndb.set_custom(1, 'TS [9]', label='series')
|
||||
self.assertEqual(ndb.new_api.field_for('#series', 1), 'TS')
|
||||
self.assertEqual(ndb.new_api.field_for('#series_index', 1), 9)
|
||||
# }}}
|
||||
|
||||
def test_legacy_original_fmt(self): # {{{
|
||||
|
Loading…
x
Reference in New Issue
Block a user