Allow to reset ordering by calling order_by() with no arguments
This commit is contained in:
parent
2a93a69085
commit
5e787404f5
2 changed files with 3 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ Differences between Mongomallard and Mongoengine
|
||||||
* `_get_changed_fields()` / `_changed_fields` returns a set
|
* `_get_changed_fields()` / `_changed_fields` returns a set
|
||||||
* Simplified `EmailField` email regex to be more compatible
|
* Simplified `EmailField` email regex to be more compatible
|
||||||
* Assigning invalid types (e.g. an invalid string to `IntField`) raises immediately a `ValueError`
|
* Assigning invalid types (e.g. an invalid string to `IntField`) raises immediately a `ValueError`
|
||||||
|
* `order_by()` without an argument resets the ordering (no ordering will be applied)
|
||||||
|
|
||||||
Untested / not implemented yet:
|
Untested / not implemented yet:
|
||||||
-----
|
-----
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class QuerySet(object):
|
||||||
self._initial_query = {}
|
self._initial_query = {}
|
||||||
self._where_clause = None
|
self._where_clause = None
|
||||||
self._loaded_fields = QueryFieldList()
|
self._loaded_fields = QueryFieldList()
|
||||||
self._ordering = []
|
self._ordering = None
|
||||||
self._snapshot = False
|
self._snapshot = False
|
||||||
self._timeout = True
|
self._timeout = True
|
||||||
self._class_check = True
|
self._class_check = True
|
||||||
|
|
@ -1211,7 +1211,7 @@ class QuerySet(object):
|
||||||
if self._ordering:
|
if self._ordering:
|
||||||
# Apply query ordering
|
# Apply query ordering
|
||||||
self._cursor_obj.sort(self._ordering)
|
self._cursor_obj.sort(self._ordering)
|
||||||
elif self._document._meta['ordering']:
|
elif self._ordering == None and self._document._meta['ordering']:
|
||||||
# Otherwise, apply the ordering from the document model
|
# Otherwise, apply the ordering from the document model
|
||||||
order = self._get_order_by(self._document._meta['ordering'])
|
order = self._get_order_by(self._document._meta['ordering'])
|
||||||
self._cursor_obj.sort(order)
|
self._cursor_obj.sort(order)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue