diff --git a/AUTHORS b/AUTHORS index a5705eef..68b3ecf4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -98,3 +98,4 @@ that much better: * Chris Williams * Robert Kajic * Jacob Peddicord + * Adam Parrish diff --git a/docs/changelog.rst b/docs/changelog.rst index e4c61321..58d0430b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,10 @@ Changelog ========= +Changes in 0.6.X +================ +- Bug fix for collection naming and mixins + Changes in 0.6.2 ================ - Updated documentation for ReplicaSet connections diff --git a/docs/guide/signals.rst b/docs/guide/signals.rst index f60e4d78..c25c1788 100644 --- a/docs/guide/signals.rst +++ b/docs/guide/signals.rst @@ -5,15 +5,13 @@ Signals .. versionadded:: 0.5 -Signal support is provided by the excellent `blinker`_ library and -will gracefully fall back if it is not available. +.. note:: + + Signal support is provided by the excellent `blinker`_ library and + will gracefully fall back if it is not available. -<<<<<<< HEAD -The following document signals exist in MongoEngine and are pretty self explanatory: -======= The following document signals exist in MongoEngine and are pretty self-explanatory: ->>>>>>> master * `mongoengine.signals.pre_init` * `mongoengine.signals.post_init` diff --git a/mongoengine/fields.py b/mongoengine/fields.py index 14fcca01..13b7ed8e 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -8,7 +8,7 @@ import uuid from bson import Binary, DBRef, SON, ObjectId from base import (BaseField, ComplexBaseField, ObjectIdField, - ValidationError, get_document) + ValidationError, get_document, BaseDocument) from queryset import DO_NOTHING, QuerySet from document import Document, EmbeddedDocument from connection import get_db, DEFAULT_CONNECTION_NAME @@ -497,6 +497,7 @@ class ListField(ComplexBaseField): def prepare_query_value(self, op, value): if self.field: if op in ('set', 'unset') and (not isinstance(value, basestring) + and not isinstance(value, BaseDocument) and hasattr(value, '__iter__')): return [self.field.prepare_query_value(op, v) for v in value] return self.field.prepare_query_value(op, value) diff --git a/tests/queryset.py b/tests/queryset.py index ee3ab935..0d5aaabb 100644 --- a/tests/queryset.py +++ b/tests/queryset.py @@ -1518,6 +1518,37 @@ class QuerySetTest(unittest.TestCase): BlogPost.drop_collection() + + def test_set_list_embedded_documents(self): + + class Author(EmbeddedDocument): + name = StringField() + + class Message(Document): + title = StringField() + authors = ListField(EmbeddedDocumentField('Author')) + + Message.drop_collection() + + message = Message(title="hello", authors=[Author(name="Harry")]) + message.save() + + Message.objects(authors__name="Harry").update_one( + set__authors__S=Author(name="Ross")) + + message = message.reload() + self.assertEquals(message.authors[0].name, "Ross") + + Message.objects(authors__name="Ross").update_one( + set__authors=[Author(name="Harry"), + Author(name="Ross"), + Author(name="Adam")]) + + message = message.reload() + self.assertEquals(message.authors[0].name, "Harry") + self.assertEquals(message.authors[1].name, "Ross") + self.assertEquals(message.authors[2].name, "Adam") + def test_order_by(self): """Ensure that QuerySets may be ordered. """