| 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 | """} |