次のモデル/スキーマがあります。
class UserBase(SQLModel):
full_name: str
email: EmailStr
is_active: bool = True
is_superuser: bool = False
class UserRead(UserBase):
id: uuid.UUID
class UserCreate(UserBase, extra=Extra.forbid):
password: str
class UserUpdate(UserBase):
password: Optional[str] = None
class User(UserBase, table=True):
id: uuid.UUID = Field(
default_factory=uuid.uuid4,
primary_key=True,
index=True,
nullable=False,
)
hashed_password: Optional[str] = None
私のpostgresクライアントでは、テーブルはフィールドがモデル/スキーマにリストされている順序で列を示しています:
また、openapi のドキュメントには、User
モデルで指定されているのと同じ順序で応答オブジェクト フィールドが一覧表示されています (画像の下部にある応答オブジェクトに注目してください)。
id
テーブル/応答オブジェクトに表示する最初の列/フィールドにしたいと思います。一般に、列/フィールドの特定の順序を強制するにはどうすればよいですか?