First Check
Commit to Help
Example Code
from pydantic import BaseModel
class Parent(SQLModel, table=True):
id: UUID = sm.Field(UUID, primary_key=True)
childs:List[Child]= sm.Relationship(
back_populates="parent"
)
class Child(SQLModel, table=True):
parent_id:UUID=sm.Field()
sa_column=sm.Column(
sm.ForeignKey("parentr.id")
)
parent: "Parent" = sm.Relationship(
back_populates="childs"
)
#read schemas
class IChildRead(BaseModel):
id:UUID
class IParentReadWithChilds(BaseModel):
childs:List[IChildRead]
Description
What i want to get from pydantic response schema ? I want to get a query with select lazy options, using the schema of response, because this information already contains in relationships of pydantic models.
For example:
select(Parent).options(selectinload(Parent.Childs)),
The existance of property in pydantic model gives information about the need to use selectinload. Is there any solutions for it?
Operating System
Linux
Operating System Details
any
SQLModel Version
any
Python Version
any
Additional Context
any
First Check
Commit to Help
Example Code
Description
What i want to get from pydantic response schema ? I want to get a query with select lazy options, using the schema of response, because this information already contains in relationships of pydantic models.
For example:
select(Parent).options(selectinload(Parent.Childs)),
The existance of property in pydantic model gives information about the need to use selectinload. Is there any solutions for it?
Operating System
Linux
Operating System Details
any
SQLModel Version
any
Python Version
any
Additional Context
any