Fix KeyError on reload() from a DynamicDocument

If the document is in memory and a field is deleted from the db,
calling reload() would raise a KeyError.
This commit is contained in:
André Ericson
2014-11-08 19:11:51 -03:00
parent 70942ac0f6
commit 3569529a84
3 changed files with 15 additions and 1 deletions

View File

@@ -81,6 +81,13 @@ class DynamicTest(unittest.TestCase):
obj = collection.find_one()
self.assertEqual(sorted(obj.keys()), ['_cls', '_id', 'name'])
def test_reload_after_unsetting(self):
p = self.Person()
p.misc = 22
p.save()
p.update(unset__misc=1)
p.reload()
def test_dynamic_document_queries(self):
"""Ensure we can query dynamic fields"""
p = self.Person()