From 3b0cdb141057dd882db8c8711adf879f55655944 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Thu, 9 Jul 2015 14:37:17 -0400 Subject: [PATCH] Added a regression test for get() ordering clearing. --- tests/queries/tests.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 36bbdfea29..6fb1ea6066 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -280,6 +280,14 @@ class Queries1Tests(BaseQuerysetTest): qs = qs.order_by('id') self.assertNotIn('OUTER JOIN', str(qs.query)) + def test_get_clears_ordering(self): + """ + get() should clear ordering for optimization purposes. + """ + with CaptureQueriesContext(connection) as captured_queries: + Author.objects.order_by('name').get(pk=self.a1.pk) + self.assertNotIn('order by', captured_queries[0]['sql'].lower()) + def test_tickets_4088_4306(self): self.assertQuerysetEqual( Report.objects.filter(creator=1001),