Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a test for negated Q object querying

The added test is from the patch in ticket #19672 (written by Ian
Kelly). Fixed #19672, refs #19849.
  • Loading branch information...
commit e8fc3f3783744e4fcd3ff0ac43e3ce2572292f3a 1 parent 10f9ba0
Anssi Kääriäinen authored February 20, 2013
1  tests/regressiontests/queries/models.py
@@ -64,6 +64,7 @@ def __str__(self):
64 64
 class ExtraInfo(models.Model):
65 65
     info = models.CharField(max_length=100)
66 66
     note = models.ForeignKey(Note)
  67
+    value = models.IntegerField(null=True)
67 68
 
68 69
     class Meta:
69 70
         ordering = ['info']
11  tests/regressiontests/queries/tests.py
@@ -52,8 +52,8 @@ def setUp(self):
52 52
 
53 53
         # Create these out of order so that sorting by 'id' will be different to sorting
54 54
         # by 'info'. Helps detect some problems later.
55  
-        self.e2 = ExtraInfo.objects.create(info='e2', note=n2)
56  
-        e1 = ExtraInfo.objects.create(info='e1', note=self.n1)
  55
+        self.e2 = ExtraInfo.objects.create(info='e2', note=n2, value=41)
  56
+        e1 = ExtraInfo.objects.create(info='e1', note=self.n1, value=42)
57 57
 
58 58
         self.a1 = Author.objects.create(name='a1', num=1001, extra=e1)
59 59
         self.a2 = Author.objects.create(name='a2', num=2002, extra=e1)
@@ -1106,6 +1106,13 @@ def test_ticket_10790_combine(self):
1106 1106
         self.assertTrue(str(q3.query).count('LEFT OUTER JOIN') == 1)
1107 1107
         self.assertTrue(str(q3.query).count('INNER JOIN') == 0)
1108 1108
 
  1109
+    def test_ticket19672(self):
  1110
+        self.assertQuerysetEqual(
  1111
+            Report.objects.filter(Q(creator__isnull=False) &
  1112
+                                  ~Q(creator__extra__value=41)),
  1113
+            ['<Report: r1>']
  1114
+        )
  1115
+
1109 1116
 
1110 1117
 class Queries2Tests(TestCase):
1111 1118
     def setUp(self):

0 notes on commit e8fc3f3

Please sign in to comment.
Something went wrong with that request. Please try again.