summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-08-20 10:32:18 +0300
committerAndrew Godwin <andrew@aeracode.org>2013-08-21 22:30:46 +0100
commitcea720450485e0871daa7f9477fdf2bff5a5b821 (patch)
treeace96ccf3fe0f0fe5e1e44787e011ff4b65f8245 /tests
parentb773ef8fa0ef09641abf376ca8d4083d8966ec52 (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.py13
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
+ )