diff options
| author | Srinivas Reddy Thatiparthy <thatiparthysreenivas@gmail.com> | 2018-07-01 02:19:20 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-09-10 15:08:55 -0400 |
| commit | 34d6bceec46c5d4234c156ed682573d2e5de474a (patch) | |
| tree | 7239bb1c2d435f9ddd4caf2e565d0d673f6e9735 /tests/backends/sqlite | |
| parent | 76dfa834e7ceeca97cd8e3cfa86651a955aa3f0c (diff) | |
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>
Diffstat (limited to 'tests/backends/sqlite')
| -rw-r--r-- | tests/backends/sqlite/tests.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/backends/sqlite/tests.py b/tests/backends/sqlite/tests.py index c82ed1667d..86723a72d2 100644 --- a/tests/backends/sqlite/tests.py +++ b/tests/backends/sqlite/tests.py @@ -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') |
