From 3fe93968a6d428a94ca70cca4a39d090ff5e10f7 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Sun, 18 Oct 2015 00:19:36 -0400 Subject: [PATCH] update test case for: Please recall fix on: Saving document doesn't create new fields in existing collection #620 #1126 --- tests/document/instance.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/document/instance.py b/tests/document/instance.py index 7a393416..3d41857e 100644 --- a/tests/document/instance.py +++ b/tests/document/instance.py @@ -2941,6 +2941,17 @@ class InstanceTest(unittest.TestCase): p4 = Person.objects()[0] p4.save() self.assertEquals(p4.height, 189) + + # However the default will not be fixed in DB + self.assertEquals(Person.objects(height=189).count(), 0) + + # alter DB for the new default + coll = Person._get_collection() + for person in Person.objects.as_pymongo(): + if 'height' not in person: + person['height'] = 189 + coll.save(person) + self.assertEquals(Person.objects(height=189).count(), 1) def test_from_son(self):