heynemann / motorengine

Motorengine is a port of MongoEngine for Tornado.
http://motorengine.readthedocs.org
204 stars 67 forks source link

Default value for field is ignored when the db_field is set #118

Open thekie opened 8 years ago

thekie commented 8 years ago

Hello. I have found the following:

>>> from motorengine import Document,IntField
>>> class Test(Document):
...     foo = IntField(default=0)
... test = Test()
>>> test.foo
0

Whereas

>>> from motorengine import Document,IntField
>>> class Test(Document):
...     foo = IntField(default=0, db_field="faa")
... test = Test()
>>> test.foo
None

Do you have an idea, what I am doing wrong? Or is it a bug, that the default value gets ignored in the later case?