Skip to content

Commit

Permalink
Exclude pragma from is_dml logic and implicit transaction.
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Jun 26, 2023
1 parent 63c0189 commit 5a97877
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
PyOS_strnicmp(p, "alter", 5) &&
PyOS_strnicmp(p, "analyze", 7) &&
PyOS_strnicmp(p, "reindex", 7) &&
PyOS_strnicmp(p, "vacuum", 6));
PyOS_strnicmp(p, "vacuum", 6) &&
PyOS_strnicmp(p, "pragma", 6));
break;
}
}
Expand Down
17 changes: 16 additions & 1 deletion test/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.

import os, unittest
import glob, os, unittest
from sqlcipher3 import dbapi2 as sqlite

def get_db_path():
Expand Down Expand Up @@ -212,6 +212,14 @@ class DMLStatementDetectionTestCase(unittest.TestCase):
Use sqlite3_stmt_readonly to determine if the statement is DML or not.
"""
def setUp(self):
for f in glob.glob(get_db_path() + '*'):
try:
os.unlink(f)
except OSError:
pass
tearDown = setUp

@unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3),
'needs sqlite 3.8.3 or newer')
def test_dml_detection_cte(self):
Expand Down Expand Up @@ -268,6 +276,13 @@ def test_dml_detection_vacuum(self):
conn.execute('vacuum')
self.assertFalse(conn.in_transaction)

def test_dml_detection_vacuum(self):
conn = sqlite.connect(get_db_path())
conn.execute('pragma journal_mode=\'wal\'')
jmode, = conn.execute('pragma journal_mode').fetchone()
self.assertEqual(jmode, 'wal')
self.assertFalse(conn.in_transaction)


def suite():
default_suite = unittest.makeSuite(TransactionTests, "Check")
Expand Down

0 comments on commit 5a97877

Please sign in to comment.