Repository: MongoEngine/mongoengine

Issue:
Pushing a list of values into a list field works not correct from version 0.14
Example of code
```python
document.update(push__mylist=['value1', 123])
document.update(push__mylist=['value2', 456])
```
In Mongoengine < 0.14 this code produce the follow document in the mongodb:
```
{
  ...
  "mylist": [["value1", 123], ["value2", 456]]
}
```
After I has updated Mongoengine to version 0.14+, this code produces the follow document:
```
{
  ...
  "mylist": ["value1", 123, "value2", 456]
}
```
I think that is a result of #1566 pull request from @erdenezul.


Discussion:
It is correct behavior. What do you think? @wojcikstefan 
@Cykooz did you check your code in 0.13? Does it really return nested as you mentioned?
@erdenezul
> It is correct behavior. 

This is not correct behavior because mongodb command:
```db.mycollection.update({}, {$push: {mylist: ['value1', 123]}})```
is not equal to command:
```db.mycollection.update({}, {$push: {mylist: {$each: ['value1', 123]}}})```


@erdenezul Yes, mongoengine v0.13 really returns list of lists. 
I has updated mongoengine to version 0.14 some hours ago then some unit-tests in my project has failed.
it is really returning the list of lists in <0.14. 
In my opinion, there were no tests for the list of lists that's why my PR did not get failing(all green). Do you want to send PR to fix this? or me?
I am making PR for this. @Cykooz  thanks for reporting it.

Resolving patch:
diff --git a/mongoengine/queryset/transform.py b/mongoengine/queryset/transform.py
--- a/mongoengine/queryset/transform.py
+++ b/mongoengine/queryset/transform.py
@@ -344,8 +344,6 @@ def update(_doc_cls=None, **update):
                 if not isinstance(value, (set, tuple, list)):
                     value = [value]
                 value = {key: {'$each': value, '$position': position}}
-            elif isinstance(value, list):
-                value = {key: {'$each': value}}
             else:
                 value = {key: value}
         else:


Test patch:
diff --git a/tests/document/instance.py b/tests/document/instance.py
--- a/tests/document/instance.py
+++ b/tests/document/instance.py
@@ -3183,6 +3183,17 @@ class BlogPost(Document):
         blog.reload()
         self.assertEqual(blog.tags, ['mongodb', 'code', 'python'])
 
+    def test_push_nested_list(self):
+        """Ensure that push update works in nested list"""
+        class BlogPost(Document):
+            slug = StringField()
+            tags = ListField()
+
+        blog = BlogPost(slug="test").save()
+        blog.update(push__tags=["value1", 123])
+        blog.reload()
+        self.assertEqual(blog.tags, [["value1", 123]])
+
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/tests/queryset/queryset.py b/tests/queryset/queryset.py
--- a/tests/queryset/queryset.py
+++ b/tests/queryset/queryset.py
@@ -1929,6 +1929,21 @@ class BlogPost(Document):
         post.reload()
         self.assertEqual(post.tags, ['scala', 'mongodb', 'python', 'java'])
 
+    def test_update_push_list_of_list(self):
+        """Ensure that the 'push' update operation works in the list of list
+        """
+        class BlogPost(Document):
+            slug = StringField()
+            tags = ListField()
+
+        BlogPost.drop_collection()
+
+        post = BlogPost(slug="test").save()
+
+        BlogPost.objects.filter(slug="test").update(push__tags=["value1", 123])
+        post.reload()
+        self.assertEqual(post.tags, [["value1", 123]])
+
     def test_update_push_and_pull_add_to_set(self):
         """Ensure that the 'pull' update operation works correctly.
         """