mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
gh-105875: Require SQLite 3.15.2 or newer (#105876)
SQLite 3.15.2 was released 2016-11-28.
This commit is contained in:
parent
bc07c8f096
commit
6849acb3fe
13 changed files with 61 additions and 202 deletions
|
@ -381,38 +381,22 @@ class FunctionTests(unittest.TestCase):
|
|||
# Regarding deterministic functions:
|
||||
#
|
||||
# Between 3.8.3 and 3.15.0, deterministic functions were only used to
|
||||
# optimize inner loops, so for those versions we can only test if the
|
||||
# sqlite machinery has factored out a call or not. From 3.15.0 and onward,
|
||||
# deterministic functions were permitted in WHERE clauses of partial
|
||||
# indices, which allows testing based on syntax, iso. the query optimizer.
|
||||
@unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "Requires SQLite 3.8.3 or higher")
|
||||
# optimize inner loops. From 3.15.0 and onward, deterministic functions
|
||||
# were permitted in WHERE clauses of partial indices, which allows testing
|
||||
# based on syntax, iso. the query optimizer.
|
||||
def test_func_non_deterministic(self):
|
||||
mock = Mock(return_value=None)
|
||||
self.con.create_function("nondeterministic", 0, mock, deterministic=False)
|
||||
if sqlite.sqlite_version_info < (3, 15, 0):
|
||||
self.con.execute("select nondeterministic() = nondeterministic()")
|
||||
self.assertEqual(mock.call_count, 2)
|
||||
else:
|
||||
with self.assertRaises(sqlite.OperationalError):
|
||||
self.con.execute("create index t on test(t) where nondeterministic() is not null")
|
||||
with self.assertRaises(sqlite.OperationalError):
|
||||
self.con.execute("create index t on test(t) where nondeterministic() is not null")
|
||||
|
||||
@unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "Requires SQLite 3.8.3 or higher")
|
||||
def test_func_deterministic(self):
|
||||
mock = Mock(return_value=None)
|
||||
self.con.create_function("deterministic", 0, mock, deterministic=True)
|
||||
if sqlite.sqlite_version_info < (3, 15, 0):
|
||||
self.con.execute("select deterministic() = deterministic()")
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
else:
|
||||
try:
|
||||
self.con.execute("create index t on test(t) where deterministic() is not null")
|
||||
except sqlite.OperationalError:
|
||||
self.fail("Unexpected failure while creating partial index")
|
||||
|
||||
@unittest.skipIf(sqlite.sqlite_version_info >= (3, 8, 3), "SQLite < 3.8.3 needed")
|
||||
def test_func_deterministic_not_supported(self):
|
||||
with self.assertRaises(sqlite.NotSupportedError):
|
||||
self.con.create_function("deterministic", 0, int, deterministic=True)
|
||||
try:
|
||||
self.con.execute("create index t on test(t) where deterministic() is not null")
|
||||
except sqlite.OperationalError:
|
||||
self.fail("Unexpected failure while creating partial index")
|
||||
|
||||
def test_func_deterministic_keyword_only(self):
|
||||
with self.assertRaises(TypeError):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue