summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrew Clark <amclark7@gmail.com>2013-06-26 01:07:18 -0700
committerTim Graham <timograham@gmail.com>2013-06-26 08:13:26 -0400
commit273dc550a4eccdad958541f456332312b3369504 (patch)
treed31272f7bc4e343a2e808e4961d73777d681694a /tests
parentc6862d57c1e987f0f98a77826d19358b9040bad1 (diff)
Fixed #20462 -- null/non-string regex lookups are now consistent
Thanks to noirbizarre for the report and initial patch.
Diffstat (limited to 'tests')
-rw-r--r--tests/lookup/tests.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py
index de7105f92d..fe8a5fac64 100644
--- a/tests/lookup/tests.py
+++ b/tests/lookup/tests.py
@@ -610,6 +610,21 @@ class LookupTests(TestCase):
self.assertQuerysetEqual(Article.objects.filter(headline__regex=r'b(.).*b\1'),
['<Article: barfoobaz>', '<Article: bazbaRFOO>', '<Article: foobarbaz>'])
+ def test_regex_null(self):
+ """
+ Ensure that a regex lookup does not fail on null/None values
+ """
+ Season.objects.create(year=2012, gt=None)
+ self.assertQuerysetEqual(Season.objects.filter(gt__regex=r'^$'), [])
+
+ def test_regex_non_string(self):
+ """
+ Ensure that a regex lookup does not fail on non-string fields
+ """
+ Season.objects.create(year=2013, gt=444)
+ self.assertQuerysetEqual(Season.objects.filter(gt__regex=r'^444$'),
+ ['<Season: 2013>'])
+
def test_nonfield_lookups(self):
"""
Ensure that a lookup query containing non-fields raises the proper