summaryrefslogtreecommitdiff
path: root/test/dialect/test_sqlite.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2023-02-27 22:05:08 +0100
committerMike Bayer <mike_mp@zzzcomputing.com>2023-03-04 11:27:00 -0500
commit1879aaf3733c4938f75320395b8faa08fa4fec09 (patch)
treeb0e687c5d54f2bf06d5e111cfa71b21ce72baf50 /test/dialect/test_sqlite.py
parentfcab6bcc5a5a414c9775120f15c7dbd52ccf4ae3 (diff)
downloadsqlalchemy-1879aaf3733c4938f75320395b8faa08fa4fec09.tar.gz
Restore connectivity with ancient sqlite
Fixed bug that prevented SQLAlchemy to connect when using a very old sqlite version (before 3.9) on python 3.8+. Fixes: #9379 Change-Id: I10ca347398221c952e1a572dc6ef80e491d1f5cf
Diffstat (limited to 'test/dialect/test_sqlite.py')
-rw-r--r--test/dialect/test_sqlite.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py
index c52c9f195..49c57c854 100644
--- a/test/dialect/test_sqlite.py
+++ b/test/dialect/test_sqlite.py
@@ -2786,6 +2786,43 @@ class RegexpTest(fixtures.TestBase, testing.AssertsCompiledSQL):
"mytable", column("myid", Integer), column("name", String)
)
+ def _only_on_py38_w_sqlite_39():
+ """in python 3.9 and above you can actually do::
+
+ @(testing.requires.python38 + testing.only_on("sqlite > 3.9"))
+ def test_determinsitic_parameter(self):
+ ...
+
+ that'll be cool. until then...
+
+ """
+ return testing.requires.python38 + testing.only_on("sqlite >= 3.9")
+
+ @_only_on_py38_w_sqlite_39()
+ def test_determinsitic_parameter(self):
+ """for #9379, make sure that "deterministic=True" is used when we are
+ on python 3.8 with modern SQLite version.
+
+ For the case where we are not on py3.8 or not on modern sqlite version,
+ the rest of the test suite confirms that connection still passes.
+
+ """
+ e = create_engine("sqlite://")
+
+ @event.listens_for(e, "do_connect", retval=True)
+ def _mock_connect(dialect, conn_rec, cargs, cparams):
+ conn = e.dialect.loaded_dbapi.connect(":memory:")
+ return mock.Mock(wraps=conn)
+
+ c = e.connect()
+ eq_(
+ c.connection.driver_connection.create_function.mock_calls,
+ [
+ mock.call("regexp", 2, mock.ANY, deterministic=True),
+ mock.call("floor", 1, mock.ANY, deterministic=True),
+ ],
+ )
+
def test_regexp_match(self):
self.assert_compile(
self.table.c.myid.regexp_match("pattern"),