diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-08-20 10:32:18 +0300 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-08-20 10:55:00 +0300 |
| commit | 905409855c6b69f613190fcc2d8bd8bf5e1580b5 (patch) | |
| tree | f93badc4eb4dc8a1122178624381c3f57d6d203a /tests | |
| parent | b53ed351b34918e337cbf26773998dafc6f82f4d (diff) | |
Fixed #14056 -- Made sure LEFT JOIN aren't trimmed in ORDER BY
If LEFT JOINs are required for correct results, then trimming the join
can lead to incorrect results. Consider case:
TBL A: ID | TBL B: ID A_ID
1 1 1
2
Now A.order_by('b__a') did use a join to B, and B's a_id column. This
was seen to contain the same value as A's id, and so the join was
trimmed. But this wasn't correct as the join is LEFT JOIN, and for row
A.id = 2 the B.a_id column is NULL.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/queries/tests.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 4d9ffb353f..bb4e9eee8f 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -25,7 +25,7 @@ from .models import ( OneToOneCategory, NullableName, ProxyCategory, SingleObject, RelatedObject, ModelA, ModelB, ModelC, ModelD, Responsibility, Job, JobResponsibilities, BaseA, FK1, Identifier, Program, Channel, Page, Paragraph, Chapter, Book, - MyObject, Order, OrderItem) + MyObject, Order, OrderItem, SharedConnection) class BaseQuerysetTest(TestCase): def assertValueQuerysetEqual(self, qs, values): @@ -2977,3 +2977,14 @@ class RelatedLookupTypeTests(TestCase): self.assertQuerysetEqual( ObjectB.objects.filter(objecta__in=[wrong_type]), [ob], lambda x: x) + +class Ticket14056Tests(TestCase): + def test_ticket_14056(self): + s1 = SharedConnection.objects.create(data='s1') + s2 = SharedConnection.objects.create(data='s2') + s3 = SharedConnection.objects.create(data='s3') + PointerA.objects.create(connection=s2) + self.assertQuerysetEqual( + SharedConnection.objects.order_by('pointera__connection', 'pk'), + [s1, s3, s2], lambda x: x + ) |
