Ticket #14601: promote_alias.diff
File promote_alias.diff, 2.6 KB (added by , 14 years ago) |
---|
-
TabularUnified django/db/models/sql/query.py
641 641 False, the join is only promoted if it is nullable, otherwise it is 642 642 always promoted. 643 643 644 Returns True if the join was promoted .644 Returns True if the join was promoted or had been previously. 645 645 """ 646 if ((unconditional or self.alias_map[alias][NULLABLE]) and647 self.alias_map[alias][JOIN_TYPE] != self.LOUTER):648 data = list(self.alias_map[alias])649 data[JOIN_TYPE] = self.LOUTER650 self.alias_map[alias] = tuple(data)646 if unconditional or self.alias_map[alias][NULLABLE]: 647 if self.alias_map[alias][JOIN_TYPE] != self.LOUTER: 648 data = list(self.alias_map[alias]) 649 data[JOIN_TYPE] = self.LOUTER 650 self.alias_map[alias] = tuple(data) 651 651 return True 652 652 return False 653 653 -
TabularUnified tests/modeltests/promote_alias/__init__.py
1 -
TabularUnified tests/modeltests/promote_alias/models.py
1 """ 2 Testing query promote_alias bug. 3 """ 4 5 from django.db import models 6 7 class User(models.Model): 8 first_name = models.CharField(max_length=100) 9 last_name = models.CharField(max_length=100) 10 11 class Person(models.Model): 12 user = models.ForeignKey(User) 13 14 class Item(models.Model): 15 person = models.ForeignKey(Person, null=True) 16 amount = models.IntegerField() 17 18 19 __test__ = {'API_TESTS':""" 20 >>> from django.db.models import Q 21 22 >>> Item.objects.create(person=None, amount=123) 23 <Item: Item object> 24 25 >>> Item.objects.values('amount', 'person__user__first_name', 'person__user__last_name') 26 [{'amount': 123, 'person__user__last_name': None, 'person__user__first_name': None}] 27 28 >>> Item.objects.filter(Q(person__isnull=True) | Q(person__isnull=False)) 29 [<Item: Item object>] 30 31 >>> Item.objects.filter(Q(person__isnull=True) | Q(person__isnull=False)).values('amount', 'person__user__first_name', 'person__user__last_name') 32 [{'amount': 123, 'person__user__last_name': None, 'person__user__first_name': None}] 33 34 """}