Skip to content

primary_key=True in Field not work when sa_column argument exists #573

Answered by YuriiMotov
honglei asked this question in Questions
Discussion options

You must be logged in to vote

Yes, if you specify sa_column you should then pass primary_key=True, index=True and other column-related parameters as parameters to Column:

class ResourceTypeOK(SQLModel, table=True):
    resourceTypeID: int = Field(
        sa_column=Column(SmallInteger, primary_key=True, index=True),
    )

Replies: 2 comments

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