Code

Ticket #7312: 7312.regressiontest.diff

File 7312.regressiontest.diff, 934 bytes (added by anonymous, 6 years ago)
Line 
1Index: tests/regressiontests/queries/models.py
2===================================================================
3--- tests/regressiontests/queries/models.py     (revision 7554)
4+++ tests/regressiontests/queries/models.py     (working copy)
5@@ -134,6 +134,12 @@
6     def __unicode__(self):
7         return self.data
8 
9+class CustomQ(object):
10+    def __init__(self, *args, **kwargs):
11+        self.args = args
12+        self.kwargs = kwargs
13+    def add_to_query(self, query, aliases):
14+        query.add_q(Q(*self.args, **self.kwargs))
15 
16 __test__ = {'API_TESTS':"""
17 >>> t1 = Tag(name='t1')
18@@ -701,5 +707,11 @@
19 >>> mm = ManagedModel.objects.create(data='mm1', tag=t1, is_public=True)
20 >>> ManagedModel.objects.update(data='mm')
21 
22+Bug #7312
23+>>> Item.objects.complex_filter(CustomQ(tags=t1)).order_by('name')
24+[<Item: one>, <Item: two>]
25+>>> Item.objects.complex_filter(CustomQ(tags=t1)).filter(Q(tags=t2))
26+[<Item: one>]
27+
28 """}