mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 10:24:32 +02:00
optimize() and rebuild_fts() now commit their changes
Both ran their INSERT INTO fts(fts) statements via a bare execute() with no commit, leaving the connection inside an open implicit transaction - the FTS operation and all subsequent writes were then silently rolled back when the connection closed. Both are now wrapped in db.atomic(), matching delete_where() and the other write operations. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UnLnhsH25Nnv7LHhekUfPd
This commit is contained in:
parent
45af93d463
commit
e762656d06
2 changed files with 27 additions and 7 deletions
|
|
@ -2769,11 +2769,12 @@ class Table(Queryable):
|
|||
if fts_table is None:
|
||||
# Assume this is itself an FTS table
|
||||
fts_table = self.name
|
||||
self.db.execute(
|
||||
"INSERT INTO {table}({table}) VALUES('rebuild');".format(
|
||||
table=quote_identifier(fts_table)
|
||||
with self.db.atomic():
|
||||
self.db.execute(
|
||||
"INSERT INTO {table}({table}) VALUES('rebuild');".format(
|
||||
table=quote_identifier(fts_table)
|
||||
)
|
||||
)
|
||||
)
|
||||
return self
|
||||
|
||||
def detect_fts(self) -> Optional[str]:
|
||||
|
|
@ -2805,9 +2806,10 @@ class Table(Queryable):
|
|||
"Run the ``optimize`` operation against the associated full-text search index table."
|
||||
fts_table = self.detect_fts()
|
||||
if fts_table is not None:
|
||||
self.db.execute("""
|
||||
INSERT INTO {table} ({table}) VALUES ("optimize");
|
||||
""".strip().format(table=quote_identifier(fts_table)))
|
||||
with self.db.atomic():
|
||||
self.db.execute("""
|
||||
INSERT INTO {table} ({table}) VALUES ("optimize");
|
||||
""".strip().format(table=quote_identifier(fts_table)))
|
||||
return self
|
||||
|
||||
def search_sql(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue