-
-
Notifications
You must be signed in to change notification settings - Fork 447
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
RFC: Modelschema rework #1281
Draft
Ksauder
wants to merge
17
commits into
vitalik:master
Choose a base branch
from
Ksauder:modelschema-and-meta-improvements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
RFC: Modelschema rework #1281
Ksauder
wants to merge
17
commits into
vitalik:master
from
Ksauder:modelschema-and-meta-improvements
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ksauder
force-pushed
the
modelschema-and-meta-improvements
branch
from
September 19, 2024 03:26
78c0646
to
88d2e0c
Compare
Ksauder
force-pushed
the
modelschema-and-meta-improvements
branch
from
September 21, 2024 03:25
16e8c4e
to
78f06eb
Compare
@vitalik Is this MR anywhere in the ballpark of changes you'd like to see? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses: #1300 #1249 #995 #347
I was having trouble getting inheritance to work in a logical way with the ModelSchema, so I took a stab at updating the ModelSchemaMetaclass, MetaConf, and some of the SchemaFactory. The added inheritance test shows a concrete example.
I think this rework allows more flexibility and ability to customize moving forward, would love some feedback.
primary_key_optional
option to MetaConf and create_schema() - this toggles how Django fields withprimary_key
are handledI forked and am running my develop branch on a medium (ish? 100+ endpoints) sized project. I have this branch working as intended after some fixes. Here's an example of a project schemas.py file:
nullable_wrapper is a param on a separate branch on my fork, allows a custom type to wrap
nullable
fields:I initially allowed values set in parent ModelSchema.Meta classes to be implicitly passed down to children. I have since removed that. Any inheritance in a Meta class must be explicit, what you see is what you get.