mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Document that rejected write PRAGMAs in db.query() still take effect
db.query() promises that a statement rejected with ValueError is rolled back and has no effect. PRAGMA statements are the exception: some of them refuse to run inside a transaction, so they execute outside the savepoint guard - a row-less PRAGMA such as "PRAGMA user_version = 5" therefore takes effect despite the ValueError. Documenting this as a known limitation rather than fixing it, since a fix would need a hardcoded list of row-returning PRAGMAs. Refs https://github.com/simonw/sqlite-utils/issues/769#issuecomment-4900034150 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
adc10df981
commit
66934918c6
4 changed files with 19 additions and 1 deletions
|
|
@ -797,7 +797,10 @@ class Database:
|
|||
parameters, or a dictionary for ``where id = :id``
|
||||
:raises ValueError: if the SQL statement does not return rows - use
|
||||
:meth:`execute` for those statements instead. The rejected statement
|
||||
is rolled back, so it has no effect on the database
|
||||
is rolled back, so it has no effect on the database. One exception:
|
||||
a row-less ``PRAGMA`` statement takes effect despite the
|
||||
``ValueError``, because PRAGMAs run outside the savepoint guard -
|
||||
some of them refuse to run inside a transaction
|
||||
"""
|
||||
message = (
|
||||
"query() can only be used with SQL that returns rows - "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue