parent
391f659af1
commit
071562d755
1
AUTHORS
1
AUTHORS
@ -82,3 +82,4 @@ that much better:
|
||||
* aid
|
||||
* yamaneko1212
|
||||
* dave mankoff
|
||||
* Alexander G. Morano
|
||||
|
@ -5,6 +5,7 @@ Changelog
|
||||
Changes in dev
|
||||
==============
|
||||
|
||||
- Fixed issue with dynamic documents deltas
|
||||
- Added Reverse Delete Rule support to ListFields - MapFields aren't supported
|
||||
- Added customisable cascade kwarg options
|
||||
- Fixed Handle None values for non-required fields
|
||||
|
@ -954,6 +954,7 @@ class BaseDocument(object):
|
||||
set_fields = self._get_changed_fields()
|
||||
set_data = {}
|
||||
unset_data = {}
|
||||
parts = []
|
||||
if hasattr(self, '_changed_fields'):
|
||||
set_data = {}
|
||||
# Fetch each set item from its path
|
||||
@ -980,7 +981,7 @@ class BaseDocument(object):
|
||||
|
||||
# If we've set a value that ain't the default value dont unset it.
|
||||
default = None
|
||||
if self._dynamic and parts[0] in self._dynamic_fields:
|
||||
if self._dynamic and len(parts) and parts[0] in self._dynamic_fields:
|
||||
del(set_data[path])
|
||||
unset_data[path] = 1
|
||||
continue
|
||||
|
@ -36,6 +36,15 @@ class DynamicDocTest(unittest.TestCase):
|
||||
# Confirm no changes to self.Person
|
||||
self.assertFalse(hasattr(self.Person, 'age'))
|
||||
|
||||
def test_dynamic_document_delta(self):
|
||||
"""Ensures simple dynamic documents can delta correctly"""
|
||||
p = self.Person(name="James", age=34)
|
||||
self.assertEquals(p._delta(), ({'_types': ['Person'], 'age': 34, 'name': 'James', '_cls': 'Person'}, {}))
|
||||
|
||||
p.doc = 123
|
||||
del(p.doc)
|
||||
self.assertEquals(p._delta(), ({'_types': ['Person'], 'age': 34, 'name': 'James', '_cls': 'Person'}, {'doc': 1}))
|
||||
|
||||
def test_change_scope_of_variable(self):
|
||||
"""Test changing the scope of a dynamic field has no adverse effects"""
|
||||
p = self.Person()
|
||||
|
Loading…
x
Reference in New Issue
Block a user