Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,4 @@ that much better:
* Michael Chase (https://github.com/rxsegrxup)
* Eremeev Danil (https://github.com/elephanter)
* Catstyle Lee (https://github.com/Catstyle)
* Kiryl Yermakou (https://github.com/rma4ok)
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Changes in 0.9.X - DEV
- Fixed unpickled documents replacing the global field's list. #888
- Fixed storage of microseconds in ComplexDateTimeField and unused separator option. #910
- Django support was removed and will be available as a separate extension. #958
- Fix for updating sorting in SortedListField. #978

Changes in 0.9.0
================
Expand Down
7 changes: 7 additions & 0 deletions mongoengine/base/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ def _get_changed_fields(self, inspected=None):
EmbeddedDocument = _import_class("EmbeddedDocument")
DynamicEmbeddedDocument = _import_class("DynamicEmbeddedDocument")
ReferenceField = _import_class("ReferenceField")
SortedListField = _import_class("SortedListField")
changed_fields = []
changed_fields += getattr(self, '_changed_fields', [])

Expand Down Expand Up @@ -577,6 +578,12 @@ def _get_changed_fields(self, inspected=None):
if (hasattr(field, 'field') and
isinstance(field.field, ReferenceField)):
continue
elif (isinstance(field, SortedListField) and field._ordering):
# if ordering is affected whole list is changed
if any(map(lambda d: field._ordering in d._changed_fields, data)):
changed_fields.append(db_field_name)
continue

self._nestable_types_changed_fields(
changed_fields, key, data, inspected)
return changed_fields
Expand Down
7 changes: 7 additions & 0 deletions tests/fields/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,13 @@ class BlogPost(Document):
self.assertEqual(post.comments[0].content, comment2.content)
self.assertEqual(post.comments[1].content, comment1.content)

post.comments[0].order = 2
post.save()
post.reload()

self.assertEqual(post.comments[0].content, comment1.content)
self.assertEqual(post.comments[1].content, comment2.content)

BlogPost.drop_collection()

def test_reverse_list_sorting(self):
Expand Down