Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions sqlmodel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def __init__(self, default: Any = Undefined, **kwargs: Any) -> None:
raise RuntimeError(
"Passing sa_type is not supported when also passing a sa_column"
)
if not hasattr(PydanticFieldInfo, "validation_alias"):
kwargs.pop("validation_alias")
if not hasattr(PydanticFieldInfo, "serialization_alias"):
kwargs.pop("serialization_alias")
Comment on lines +154 to +157

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)

super().__init__(default=default, **kwargs)
self.primary_key = primary_key
self.nullable = nullable
Expand Down Expand Up @@ -197,6 +201,8 @@ def Field(
*,
default_factory: Optional[NoArgAnyCallable] = None,
alias: Optional[str] = None,
validation_alias: Optional[str] = None,
serialization_alias: Optional[str] = None,
title: Optional[str] = None,
description: Optional[str] = None,
exclude: Union[
Expand Down Expand Up @@ -240,6 +246,8 @@ def Field(
*,
default_factory: Optional[NoArgAnyCallable] = None,
alias: Optional[str] = None,
validation_alias: Optional[str] = None,
serialization_alias: Optional[str] = None,
title: Optional[str] = None,
description: Optional[str] = None,
exclude: Union[
Expand Down Expand Up @@ -275,6 +283,8 @@ def Field(
*,
default_factory: Optional[NoArgAnyCallable] = None,
alias: Optional[str] = None,
validation_alias: Optional[str] = None,
serialization_alias: Optional[str] = None,
title: Optional[str] = None,
description: Optional[str] = None,
exclude: Union[
Expand Down Expand Up @@ -316,6 +326,8 @@ def Field(
default,
default_factory=default_factory,
alias=alias,
validation_alias=validation_alias,
serialization_alias=serialization_alias,
title=title,
description=description,
exclude=exclude,
Expand Down
Loading