-
-
Notifications
You must be signed in to change notification settings - Fork 678
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
Expose pydantic's Field(validation_alias=,serialization_alias=...) parameter #988
base: main
Are you sure you want to change the base?
Conversation
In the SQLModel's main file, the "serialization_alias" parameter has been added. This allows to handle serialization separately if necessary. Simultaneously, a check has been added to pop the "serialization_alias" attribute if it's not present in PydanticFieldInfo.
In the main sqlmodel, validation_alias and serialization_alias have been added as optional attributes. These aliases would provide more flexibility in handling and managing data validation and serialization respectively.
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.
Changes look fine (other than the small nitpick below).
if not hasattr(PydanticFieldInfo, "validation_alias"): | ||
kwargs.pop("validation_alias") | ||
if not hasattr(PydanticFieldInfo, "serialization_alias"): | ||
kwargs.pop("serialization_alias") |
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.
This doesn't look necessary (PydanticFieldInfo
seems to accept kwargs even if it doesn't use them later)
Dear all, it would be totally awesome to release this. The issue exists several months and several versions already #725. Please, let's get some traction here :) |
second the push to get this merged as soon as possible please 🙏 |
This expands upon and closes PR #774 by adding serialization_alias and missing Field override parameters.
Allows for serializing json using serialization_alias when by_alias is true
object.model_dump_json(by_alias=True)