Added a regression test for get() ordering clearing.

This commit is contained in:
Simon Charette 2015-07-09 14:37:17 -04:00
parent 07577a2d05
commit 3b0cdb1410
1 changed files with 8 additions and 0 deletions

View File

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