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