How is the value of 'auto_now_add' determi

2019-07-22 10:55发布

According to the ndb doc, auto_now_add would set property to current date/time when entity is created.

I would like to know how the value is determined in async ops - i.e., Is it determined by the time when an in-memory model object is created, or by the time when the model is actually written to datastore?

1条回答
贼婆χ
2楼-- · 2019-07-22 11:26

The docs say " The automatic value is not generated until the entity is written; that is, these options don't provide dynamic defaults. (These details differ from the old db API.)

Note: When a transaction writing a property with auto_now_add=True fails and is later retried, it will reuse the same time value as on the original try rather than update it to the time of the retry. If the transaction fails permanently, the property's value will still be set in the in-memory copy of the entity."

查看更多
登录 后发表回答