From 58635b24ba2488af907e3af302eadc33acff0950 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Mon, 12 Mar 2012 10:35:02 +0000 Subject: [PATCH 1/5] Updated changelog --- docs/changelog.rst | 4 ++++ 1 file changed, 4 insertions(+) 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 From 64860c628706cfd2682912ce3ff8b9e3b4674ef5 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Thu, 15 Mar 2012 16:27:31 +0000 Subject: [PATCH 2/5] Fix signals documentation --- docs/guide/signals.rst | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/guide/signals.rst b/docs/guide/signals.rst index f60e4d78..4d0b0df5 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` From fd18a4860840e5fe34e01113e0f64b7b4215ab6f Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Thu, 15 Mar 2012 16:36:04 +0000 Subject: [PATCH 3/5] Rst fix --- docs/guide/signals.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/signals.rst b/docs/guide/signals.rst index 4d0b0df5..c25c1788 100644 --- a/docs/guide/signals.rst +++ b/docs/guide/signals.rst @@ -5,7 +5,7 @@ Signals .. versionadded:: 0.5 -..note :: +.. note:: Signal support is provided by the excellent `blinker`_ library and will gracefully fall back if it is not available. From 520051af25934b577647bd88fd869a275cf65b13 Mon Sep 17 00:00:00 2001 From: Adam Parrish Date: Wed, 11 Jan 2012 16:41:39 -0800 Subject: [PATCH 4/5] preparing values in a ListField won't mangle embedded documents any more --- mongoengine/fields.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) From 0f420abc8ea48a61a003ddb8083c26327673f153 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Thu, 22 Mar 2012 15:44:22 +0000 Subject: [PATCH 5/5] Added test for listfields containing embedded documents Added Adam to the authors - thanks for the patch fixes #466 --- AUTHORS | 1 + tests/queryset.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) 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/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. """