More robust creation of dynamic id filters

This commit is contained in:
Kovid Goyal 2010-05-08 11:41:26 -06:00
parent c4ee3b2950
commit 7eecfb0668
2 changed files with 5 additions and 1 deletions

View File

@ -106,6 +106,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
self.conn = connect(self.dbpath, self.row_factory) self.conn = connect(self.dbpath, self.row_factory)
if self.user_version == 0: if self.user_version == 0:
self.initialize_database() self.initialize_database()
# remember to add any filter to the connect method in sqlite.py as well
# so that various code taht connects directly will not complain about
# missing functions
self.books_list_filter = self.conn.create_dynamic_filter('books_list_filter') self.books_list_filter = self.conn.create_dynamic_filter('books_list_filter')
def __init__(self, library_path, row_factory=False): def __init__(self, library_path, row_factory=False):
@ -1469,7 +1472,6 @@ books_series_link feeds
conn = ndb.conn conn = ndb.conn
conn.execute('create table temp_sequence(id INTEGER PRIMARY KEY AUTOINCREMENT)') conn.execute('create table temp_sequence(id INTEGER PRIMARY KEY AUTOINCREMENT)')
conn.commit() conn.commit()
conn.create_function(self.books_list_filter.name, 1, lambda x: 1)
conn.executescript(sql) conn.executescript(sql)
conn.commit() conn.commit()
conn.execute('pragma user_version=%d'%user_version) conn.execute('pragma user_version=%d'%user_version)

View File

@ -117,6 +117,8 @@ class DBThread(Thread):
self.conn.create_aggregate('sort_concat', 2, SafeSortedConcatenate) self.conn.create_aggregate('sort_concat', 2, SafeSortedConcatenate)
self.conn.create_function('title_sort', 1, title_sort) self.conn.create_function('title_sort', 1, title_sort)
self.conn.create_function('uuid4', 0, lambda : str(uuid.uuid4())) self.conn.create_function('uuid4', 0, lambda : str(uuid.uuid4()))
# Dummy functions for dynamically created filters
self.conn.create_function('books_list_filter', 1, lambda x: 1)
def run(self): def run(self):
try: try: