Merge branch 'master' into dev

This commit is contained in:
Ross Lawley 2012-03-22 15:46:32 +00:00
commit 8cfe13ad90
5 changed files with 42 additions and 7 deletions

View File

@ -98,3 +98,4 @@ that much better:
* Chris Williams
* Robert Kajic
* Jacob Peddicord
* Adam Parrish

View File

@ -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

View File

@ -5,15 +5,13 @@ Signals
.. versionadded:: 0.5
.. 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`

View File

@ -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)

View File

@ -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.
"""