Ticket #18726: test_ticket_18726.diff
File test_ticket_18726.diff, 2.2 KB (added by , 11 years ago) |
---|
-
django/db/models/sql/query.py
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index c3c8e55..8f74b1d 100644
a b class Query(object): 1882 1882 if self.alias_map[self.tables[pos + 1]].join_type != self.LOUTER: 1883 1883 select_fields = [r[0] for r in join_field.related_fields] 1884 1884 select_alias = self.tables[pos + 1] 1885 self.unref_alias(self.tables[pos])1885 # self.unref_alias(self.tables[pos]) 1886 1886 extra_restriction = join_field.get_extra_restriction( 1887 1887 self.where_class, None, self.tables[pos + 1]) 1888 1888 if extra_restriction: -
tests/queries/tests.py
diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 338ec06..a8a87b8 100644
a b class Queries1Tests(BaseQuerysetTest): 99 99 # So, 'U0."id"' is referenced twice. 100 100 self.assertTrue(str(qs4.query).lower().count('u0'), 2) 101 101 102 def test_ticket_18726(self): 103 a = ObjectA.objects.create(name="alpha") 104 b = ObjectB.objects.create(name="beta", objecta=a, num=int()) 105 c = ObjectC.objects.create(name="charlie", objectb=b, objecta=None) 106 107 def test(*args, **kwds): 108 ObjectB.objects.filter(*args, **kwds).count() 109 try: ObjectB.objects.exclude(*args, **kwds).count() 110 except DatabaseError as e: self.fail(repr(e)) 111 112 test(objecta__objectb__name='beta') 113 test(objectc__objectb__name=F('name')) 114 #test(objecta__objectb__name=F('name')) 115 116 test(objecta__objectb__name=F('objecta__name')) 117 test(objecta__objectb__name=F('objecta__objectb__name')) 118 test(objecta__objectb__name=F('objectc__objectb__name')) 119 test(objecta__objectb__name=F('objectc__objectb__objecta__name')) 120 #test(objecta__objectb__name=F('objectc__name')) 121 122 test(name=F('objecta__objectb__name')) 123 test(objecta__name=F('objecta__objectb__name')) 124 #test(objectc__name=F('objecta__objectb__name')) 125 102 126 def test_ticket1050(self): 103 127 self.assertQuerysetEqual( 104 128 Item.objects.filter(tags__isnull=True),