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),