mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #29500 -- Fixed SQLite function crashes on null values.
Co-authored-by: Srinivas Reddy Thatiparthy <thatiparthysreenivas@gmail.com> Co-authored-by: Nick Pope <nick.pope@flightdataservices.com>
This commit is contained in:
parent
76dfa834e7
commit
34d6bceec4
29 changed files with 272 additions and 38 deletions
|
@ -59,6 +59,22 @@ class Tests(TestCase):
|
|||
creation = DatabaseWrapper(settings_dict).creation
|
||||
self.assertEqual(creation._get_test_db_name(), creation.connection.settings_dict['TEST']['NAME'])
|
||||
|
||||
def test_regexp_function(self):
|
||||
tests = (
|
||||
('test', r'[0-9]+', False),
|
||||
('test', r'[a-z]+', True),
|
||||
('test', None, None),
|
||||
(None, r'[a-z]+', None),
|
||||
(None, None, None),
|
||||
)
|
||||
for string, pattern, expected in tests:
|
||||
with self.subTest((string, pattern)):
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute('SELECT %s REGEXP %s', [string, pattern])
|
||||
value = cursor.fetchone()[0]
|
||||
value = bool(value) if value in {0, 1} else value
|
||||
self.assertIs(value, expected)
|
||||
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests')
|
||||
@isolate_apps('backends')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue