-
-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: async default value #1498
Feature: async default value #1498
Conversation
Thanks! LGTM. Please update changelog also. |
Pull Request Test Coverage Report for Build 8858936385Details
💛 - Coveralls |
I've done the change log, do you think we should update the doc? Seems that this behavior is natural, and there is no need to @long2ice |
567b31b
to
246314f
Compare
@YAGregor hi! Please rebase PR on actual develop and resolve conflict in Changelog |
246314f
to
b6864a2
Compare
CHANGELOG.rst
Outdated
@@ -1333,3 +1333,4 @@ Docs/examples: | |||
await Tournament.filter( | |||
events__name__in=['1', '3'] | |||
).order_by('-events__participants__name').distinct() | |||
* Allow field's default keyword to be async function (#1498) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this entry is in wrong place
b6864a2
to
12b66d9
Compare
allow Field's default value not only be callable, literal value, but also async function
Description
when set Field's default keyword option to async function, then while save and create model, if the field never set, the field will be set as the async function's result
Motivation and Context
I write a model and I want a serial of unique, auto increasing serial names generate from redis (by aioredis), but the field's default do not support retrieve value from async function, I have to override create method, that's cumbersome.
and tortoise is an async orm, it should support async first.
How Has This Been Tested?
I create a new model for new test case, test model's behavior when combine async default with
save
,create
, and when default field value was covered by set attribute.I run tests on linux, include sqlite's test cases.
Almost no effect.
Checklist: