Skip to content

sa_column(ForeignKey) not working #1480

Answered by zhangbc97
adpmhel24 asked this question in Questions
Discussion options

You must be logged in to vote

The branch_id Field should be set in the model which "table=True"

class Model(SQLModel, table=True):
    branch_id: Optional[int] = Field(
        sa_column=Column("branch_id", Integer, ForeignKey("branch.id")),
    )

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #326 on August 11, 2025 18:15.