Support Falsey primary_keys (#1354)

This commit is contained in:
Ollie Ford
2016-12-03 21:10:05 +00:00
committed by Stefan Wójcik
parent 02fb3b9315
commit d8d98b6143
2 changed files with 18 additions and 3 deletions

View File

@@ -3202,5 +3202,20 @@ class InstanceTest(unittest.TestCase):
self.assertEqual(b._instance, a)
self.assertEqual(idx, 2)
def test_falsey_pk(self):
"""Ensure that we can create and update a document with Falsey PK.
"""
class Person(Document):
age = IntField(primary_key=True)
height = FloatField()
person = Person()
person.age = 0
person.height = 1.89
person.save()
person.update(set__height=2.0)
if __name__ == '__main__':
unittest.main()