mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Made Query.clear_ordering force_empty arg mandatory
Previously it was possible to call clear_ordering without the force_empty argument. The result was that the query was still ordered by model's meta ordering if that was defined. By making the arg mandatory it will be easier to spot possible errors caused by assuming clear_ordering will remove all ordering. Thanks to Dylan Klomparens for the suggestion. Refs #19720.
This commit is contained in:
parent
af2bb17470
commit
5cc0f5f8c1
2 changed files with 3 additions and 3 deletions
|
@ -500,7 +500,7 @@ class QuerySet(object):
|
|||
"Cannot change a query once a slice has been taken."
|
||||
obj = self._clone()
|
||||
obj.query.set_limits(high=1)
|
||||
obj.query.clear_ordering()
|
||||
obj.query.clear_ordering(force_empty=True)
|
||||
obj.query.add_ordering('%s%s' % (direction, order_by))
|
||||
return obj.get()
|
||||
|
||||
|
@ -793,7 +793,7 @@ class QuerySet(object):
|
|||
assert self.query.can_filter(), \
|
||||
"Cannot reorder a query once a slice has been taken."
|
||||
obj = self._clone()
|
||||
obj.query.clear_ordering()
|
||||
obj.query.clear_ordering(force_empty=False)
|
||||
obj.query.add_ordering(*field_names)
|
||||
return obj
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue