Repository: MongoEngine/mongoengine

Issue:
Changes from clear() on ListField are not saved
```python
class MyDoc(Document):
    things = ListField(StringField())
```

If I get hold of a document with some things and do
```python
doc.things.clear()
doc.save()
```
`things` will not be emptied. If I do
```python
doc.things = []
doc.save()
```
`things` is emptied.

Hints from issue comments:

Solution patch:
diff --git a/mongoengine/base/datastructures.py b/mongoengine/base/datastructures.py
index a175cd119..dcb8438c7 100644
--- a/mongoengine/base/datastructures.py
+++ b/mongoengine/base/datastructures.py
@@ -177,6 +177,7 @@ def __setitem__(self, key, value):
     remove = mark_as_changed_wrapper(list.remove)
     reverse = mark_as_changed_wrapper(list.reverse)
     sort = mark_as_changed_wrapper(list.sort)
+    clear = mark_as_changed_wrapper(list.clear)
     __delitem__ = mark_as_changed_wrapper(list.__delitem__)
     __iadd__ = mark_as_changed_wrapper(list.__iadd__)
     __imul__ = mark_as_changed_wrapper(list.__imul__)


Test patch:
diff --git a/tests/test_datastructures.py b/tests/test_datastructures.py
index 42ce42a1d..eb1417d11 100644
--- a/tests/test_datastructures.py
+++ b/tests/test_datastructures.py
@@ -185,7 +185,7 @@ def test___iter__(self):
         base_list = BaseList(values, instance=None, name="my_name")
         assert values == list(base_list)
 
-    def test___iter___allow_modification_while_iterating_withou_error(self):
+    def test___iter___allow_modification_while_iterating_without_error(self):
         # regular list allows for this, thus this subclass must comply to that
         base_list = BaseList([True, False, True, False], instance=None, name="my_name")
         for idx, val in enumerate(base_list):
@@ -365,6 +365,11 @@ def test_sort_calls_with_key(self):
         base_list.sort(key=lambda i: str(i))
         assert base_list == [1, 11, 2]
 
+    def test_clear_calls_mark_as_changed(self):
+        base_list = self._get_baselist([True, False])
+        base_list.clear()
+        assert base_list._instance._changed_fields == ["my_name"]
+
 
 class TestStrictDict(unittest.TestCase):
     def setUp(self):