mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-15 21:14:10 +02:00
Fix for test failure against sqlean
This commit is contained in:
parent
61619498fa
commit
623331b3f4
2 changed files with 17 additions and 4 deletions
|
|
@ -713,10 +713,14 @@ class Database:
|
||||||
args: tuple = (params,) if params is not None else ()
|
args: tuple = (params,) if params is not None else ()
|
||||||
if keyword == "PRAGMA":
|
if keyword == "PRAGMA":
|
||||||
# Some PRAGMA statements refuse to run inside a transaction, so
|
# Some PRAGMA statements refuse to run inside a transaction, so
|
||||||
# execute these without the savepoint guard used below. PRAGMAs
|
# execute these without the savepoint guard used below. Some
|
||||||
# never open an implicit transaction, so there is nothing to
|
# adapters open an implicit transaction before comment-prefixed
|
||||||
# undo if this one turns out not to return rows
|
# PRAGMAs, so temporarily use driver autocommit when it is safe.
|
||||||
cursor = self.conn.execute(sql, *args)
|
if self.conn.in_transaction:
|
||||||
|
cursor = self.conn.execute(sql, *args)
|
||||||
|
else:
|
||||||
|
with self.ensure_autocommit_off():
|
||||||
|
cursor = self.conn.execute(sql, *args)
|
||||||
if cursor.description is None:
|
if cursor.description is None:
|
||||||
raise ValueError(message)
|
raise ValueError(message)
|
||||||
keys = [d[0] for d in cursor.description]
|
keys = [d[0] for d in cursor.description]
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,15 @@ def test_query_comment_prefixed_pragma(tmpdir):
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
|
def test_query_comment_prefixed_pragma_inside_transaction(fresh_db):
|
||||||
|
fresh_db.begin()
|
||||||
|
assert list(fresh_db.query("-- check version\npragma user_version")) == [
|
||||||
|
{"user_version": 0}
|
||||||
|
]
|
||||||
|
assert fresh_db.conn.in_transaction
|
||||||
|
fresh_db.rollback()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"sql,expected",
|
"sql,expected",
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue