mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-04-02 15:21:57 -04:00
Use the actual max number of variable supported by the sqlite connection
This commit is contained in:
parent
12b4b50969
commit
6776f6c05d
@ -554,6 +554,10 @@ class DB:
|
||||
set_global_state(self)
|
||||
self.initialize_notes()
|
||||
|
||||
@property
|
||||
def max_number_of_variables(self) -> int:
|
||||
return self.conn.limit(apsw.SQLITE_LIMIT_VARIABLE_NUMBER)
|
||||
|
||||
@property
|
||||
def last_expired_trash_at(self) -> float:
|
||||
return float(self.prefs['last_expired_trash_at'])
|
||||
|
||||
@ -918,7 +918,7 @@ class Cache:
|
||||
books_by_year[year].add(book_id)
|
||||
else:
|
||||
books = tuple(restrict_to_books)
|
||||
BATCH_SIZE = 900
|
||||
BATCH_SIZE = self.backend.max_number_of_variables
|
||||
for i in range(0, len(books), BATCH_SIZE):
|
||||
batch = books[i:i + BATCH_SIZE]
|
||||
placeholders = '?,' * len(batch)
|
||||
@ -943,7 +943,7 @@ class Cache:
|
||||
ans[(year, month)].add(book_id)
|
||||
else:
|
||||
books = tuple(restrict_to_books)
|
||||
BATCH_SIZE = 900
|
||||
BATCH_SIZE = self.backend.max_number_of_variables
|
||||
for i in range(0, len(books), BATCH_SIZE):
|
||||
batch = books[i:i + BATCH_SIZE]
|
||||
placeholders = '?,' * len(batch)
|
||||
|
||||
@ -472,6 +472,7 @@ class ReadingTest(BaseTest):
|
||||
self.assertEqual(cache.books_by_year(restrict_to_books={1,2}), {2011: {1, 2}})
|
||||
self.assertEqual(cache.books_by_month(), {(2011, 8): {1}, (2011, 9): {2, 3}})
|
||||
self.assertEqual(cache.books_by_month(restrict_to_books={1,2}), {(2011, 8): {1}, (2011, 9): {2}})
|
||||
self.assertEqual(cache.books_by_year(restrict_to_books=range(cache.backend.max_number_of_variables+200)), {2011: {1, 2, 3}})
|
||||
|
||||
def test_author_sort_for_authors(self): # {{{
|
||||
'Test getting the author sort for authors from the db'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user