summaryrefslogtreecommitdiff
path: root/tests/foreign_object/test_agnostic_order_trimjoin.py
diff options
context:
space:
mode:
authordarius BERNARD <darius.bernard@onysos.fr>2016-04-18 14:59:01 +0200
committerTim Graham <timograham@gmail.com>2016-05-19 09:56:24 -0400
commita7ad473ad27995736b07750ac64e2651ff790529 (patch)
tree89dd5c74ab8ced3a87e5d274ace58445f237a6fe /tests/foreign_object/test_agnostic_order_trimjoin.py
parent2e1d44e46d1ea3d8c9fdc5c323a127f51006f6c3 (diff)
Fixed #26515 -- Fixed Query.trim_joins() for nested ForeignObjects.
Diffstat (limited to 'tests/foreign_object/test_agnostic_order_trimjoin.py')
-rw-r--r--tests/foreign_object/test_agnostic_order_trimjoin.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/foreign_object/test_agnostic_order_trimjoin.py b/tests/foreign_object/test_agnostic_order_trimjoin.py
new file mode 100644
index 0000000000..d3b7184be6
--- /dev/null
+++ b/tests/foreign_object/test_agnostic_order_trimjoin.py
@@ -0,0 +1,28 @@
+from operator import attrgetter
+
+from django.test.testcases import TestCase
+
+from .models import Address, Contact, Customer
+
+
+class TestLookupQuery(TestCase):
+
+ @classmethod
+ def setUpTestData(cls):
+ cls.address = Address.objects.create(company=1, customer_id=20)
+ cls.customer1 = Customer.objects.create(company=1, customer_id=20)
+ cls.contact1 = Contact.objects.create(company_code=1, customer_code=20)
+
+ def test_deep_mixed_forward(self):
+ self.assertQuerysetEqual(
+ Address.objects.filter(customer__contacts=self.contact1),
+ [self.address.id],
+ attrgetter('id')
+ )
+
+ def test_deep_mixed_backward(self):
+ self.assertQuerysetEqual(
+ Contact.objects.filter(customer__address=self.address),
+ [self.contact1.id],
+ attrgetter('id')
+ )