-
-
Notifications
You must be signed in to change notification settings - Fork 515
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
InsertModel
and UpdateModel
#101
Comments
I like what you've desribed here... looks promising. I think this could be related to: #105 - perhaps a refactor to the API can be considered. |
After #105, I think it will provide us some compile-time info to work with, i.e. the As such, we'd be able to generate two extra models |
Btw... why we cant set an value for primary key with auto_increment during insert? |
It is possible to specify the primary key even if a primary key column is auto_increment, but I can't imagine many situations where that'd be useful to anyone. I'm also thinking that the update and insert models can be used with async-graphql under a feature flag in the future, and you typically wouldn't allow the primary key to be set when inserting a new item. But for the async-graphql case, it could just add |
Please also note all
Maybe those could be directly excluded for |
Thanks @nicoulaj I think you raised a good point not yet considered. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Following up on #97 #94 #96
I have a rough idea:
to annotate the attributes of Entity's Model, where each attribute has three possible 'requirements':
auto_identity
(auto generated primary key),required
(implied and thus can be omitted) andoptional
from there, we can derive two more structs,
InsertModel
andUpdateModel
For
InsertModel
,auto_identity
will be omitted, and required fields will be wrapped withRequiredValue
, which must beSet
. Optional fields will be wrapped withActiveValue
, which can beSet
orUnset
.For
UpdateModel
,auto_identity
will be wrapped withRequiredValue
, while all other fields will be wrapped withActiveValue
(thus are optional)change the
Insert
andUpdate
API such that they acceptIntoInsertModel
andIntoUpdateModel
respectively.ActiveModel
can still be converted automatically intoInsertModel
andUpdateModel
, but will panic if the 'requirements' mismatchThe text was updated successfully, but these errors were encountered: