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

♻️ SQLModel EmailStr support #1227

Open
wants to merge 4 commits into
base: master
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
15 changes: 6 additions & 9 deletions backend/app/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from sqlmodel import Field, Relationship, SQLModel
from pydantic import EmailStr
from sqlmodel import AutoString, Field, Relationship, SQLModel


# Shared properties
# TODO replace email str with EmailStr when sqlmodel supports it
class UserBase(SQLModel):
email: str = Field(unique=True, index=True)
email: EmailStr = Field(unique=True, index=True, sa_type=AutoString)
is_active: bool = True
is_superuser: bool = False
full_name: str | None = None
Expand All @@ -15,24 +15,21 @@ class UserCreate(UserBase):
password: str


# TODO replace email str with EmailStr when sqlmodel supports it
class UserRegister(SQLModel):
email: str
email: EmailStr
password: str
full_name: str | None = None


# Properties to receive via API on update, all are optional
# TODO replace email str with EmailStr when sqlmodel supports it
class UserUpdate(UserBase):
email: str | None = None # type: ignore
email: EmailStr | None = None # type: ignore
password: str | None = None


# TODO replace email str with EmailStr when sqlmodel supports it
class UserUpdateMe(SQLModel):
full_name: str | None = None
email: str | None = None
email: EmailStr | None = None


class UpdatePassword(SQLModel):
Expand Down