Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.0.X] A queryset that has had ordering removed (order_by()) can hav…

…e ordering

added again later (order_by('foo')). Or, at least, it can now. Thanks to Ilya
Novoselov for diagnosing the problem here.

Backport of r9206 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9207 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a9936d0b1cc9a0f7468fed87192f60fc5a85c26a 1 parent 4b687d0
@malcolmt malcolmt authored
View
2  django/db/models/sql/query.py
@@ -608,7 +608,7 @@ def get_ordering(self):
if self.extra_order_by:
ordering = self.extra_order_by
elif not self.default_ordering:
- ordering = []
+ ordering = self.order_by
else:
ordering = self.order_by or self.model._meta.ordering
qn = self.quote_name_unless_alias
View
6 tests/regressiontests/queries/models.py
@@ -973,6 +973,12 @@ def __unicode__(self):
>>> query.bump_prefix()
>>> print query.as_sql()[0]
SELECT U0."id" FROM "queries_tag" U0
+
+Calling order_by() with no parameters removes any existing ordering on the
+model. But it should still be possible to add new ordering after that.
+>>> qs = Author.objects.order_by().order_by('name')
+>>> 'ORDER BY' in qs.query.as_sql()[0]
+True
"""}
# In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__
Please sign in to comment.
Something went wrong with that request. Please try again.