mirror of
https://github.com/simonw/datasette.git
synced 2026-09-24 19:04:08 +02:00
Stop running sqlite-utils plugins on Datasette connections
Wrapping a connection in sqlite_utils.Database() runs sqlite-utils plugins' prepare_connection hooks against it by default. Datasette's write API views and introspection helpers now pass execute_plugins=False (matching what utils/internal_db.py already did), so third-party sqlite-utils plugins no longer touch Datasette's connections. Also apply PRAGMA recursive_triggers=on in Datasette._prepare_connection so every connection gets consistent trigger semantics - previously only the write connection got it, as a side effect of the first sqlite-utils based write. Refs #2831 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N76afGMhBRQk528VF1LTpR
This commit is contained in:
parent
a3f8b440e6
commit
5cec9c9faa
8 changed files with 75 additions and 8 deletions
|
|
@ -1302,3 +1302,24 @@ async def test_database_close_is_idempotent(tmpdir):
|
|||
# Second call should be a no-op, not raise
|
||||
db.close()
|
||||
ds._internal_database.close()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_recursive_triggers_enabled_on_all_connections(tmp_path):
|
||||
# https://github.com/simonw/datasette/issues/2831
|
||||
# Previously recursive_triggers was only enabled on the write connection,
|
||||
# and only as a side effect of the first sqlite-utils based write - so
|
||||
# trigger semantics could differ between connections
|
||||
path = str(tmp_path / "test.db")
|
||||
sqlite3.connect(path).close()
|
||||
datasette = Datasette([path])
|
||||
db = datasette.get_database("test")
|
||||
write_value = await db.execute_write_fn(
|
||||
lambda conn: conn.execute("PRAGMA recursive_triggers").fetchone()[0],
|
||||
transaction=False,
|
||||
)
|
||||
read_value = await db.execute_fn(
|
||||
lambda conn: conn.execute("PRAGMA recursive_triggers").fetchone()[0]
|
||||
)
|
||||
assert write_value == 1
|
||||
assert read_value == 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue