summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-04-29 19:25:46 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-04-29 19:25:46 +0300
commit584e2c03376895aeb0404cc1fcc1ad24dfdbc58e (patch)
treed191c71b3a8a6f9788658562be0f42e44816952c /tests/regressiontests
parente75bd7e51cd6fe1f02fcdb438d58770917116c8f (diff)
Prevent Oracle from changing field.null to True
Fixed #17957 -- when using Oracle and character fields, the fields were set null = True to ease the handling of empty strings. This caused problems when using multiple databases from different vendors, or when the character field happened to be also a primary key. The handling was changed so that NOT NULL is not emitted on Oracle even if field.null = False, and field.null is not touched otherwise. Thanks to bhuztez for the report, ramiro for triaging & comments, ikelly for the patch and alex for reviewing.
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/queries/tests.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
index fb78219977..416970d493 100644
--- a/tests/regressiontests/queries/tests.py
+++ b/tests/regressiontests/queries/tests.py
@@ -1930,3 +1930,25 @@ class NullInExcludeTest(TestCase):
self.assertQuerysetEqual(
NullableName.objects.exclude(name__in=[None]),
['i1'], attrgetter('name'))
+
+class EmptyStringsAsNullTest(TestCase):
+ """
+ Test that filtering on non-null character fields works as expected.
+ The reason for these tests is that Oracle treats '' as NULL, and this
+ can cause problems in query construction. Refs #17957.
+ """
+
+ def setUp(self):
+ self.nc = NamedCategory.objects.create(name='')
+
+ def test_direct_exclude(self):
+ self.assertQuerysetEqual(
+ NamedCategory.objects.exclude(name__in=['nonexisting']),
+ [self.nc.pk], attrgetter('pk')
+ )
+
+ def test_joined_exclude(self):
+ self.assertQuerysetEqual(
+ DumbCategory.objects.exclude(namedcategory__name__in=['nonexisting']),
+ [self.nc.pk], attrgetter('pk')
+ )