parent
2afa2171f9
commit
44b9fb66e1
@ -5,6 +5,7 @@ Changelog
|
||||
Changes in dev
|
||||
==============
|
||||
|
||||
- Error raised if update doesn't have an operation
|
||||
- DeReferencing is now thread safe
|
||||
- Errors raised if trying to perform a join in a query
|
||||
- Updates can now take __raw__ queries
|
||||
|
@ -1332,11 +1332,14 @@ class QuerySet(object):
|
||||
|
||||
key = '.'.join(parts)
|
||||
|
||||
if not op:
|
||||
raise InvalidQueryError("Updates must supply an operation eg: set__FIELD=value")
|
||||
|
||||
if op:
|
||||
value = {key: value}
|
||||
key = '$' + op
|
||||
|
||||
if op is None or key not in mongo_update:
|
||||
if key not in mongo_update:
|
||||
mongo_update[key] = value
|
||||
elif key in mongo_update and isinstance(mongo_update[key], dict):
|
||||
mongo_update[key].update(value)
|
||||
|
@ -1432,6 +1432,12 @@ class DocumentTest(unittest.TestCase):
|
||||
|
||||
self.assertRaises(OperationError, update_no_value_raises)
|
||||
|
||||
def update_no_op_raises():
|
||||
person = self.Person.objects.first()
|
||||
person.update(name="Dan")
|
||||
|
||||
self.assertRaises(InvalidQueryError, update_no_op_raises)
|
||||
|
||||
def test_embedded_update(self):
|
||||
"""
|
||||
Test update on `EmbeddedDocumentField` fields
|
||||
|
Loading…
x
Reference in New Issue
Block a user