Skip to content
\n

Description

\n

is_common is not a field.

\n

Operating System

\n

macOS

\n

Operating System Details

\n

No response

\n

SQLModel Version

\n

0.0.24

\n

Python Version

\n

Python 3.12.10

\n

Additional Context

\n

No response

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"
class TOrder(SQLModel, table=True):\n  user: str\n  is_common: bool = Field(sa_column=Boolean)\n\n  __table_args__ = (\n    Index('ix_user_common', 'user', postgresql_where=(is_common.sa_column.is_(True)))\n  )
\n

this works

","upvoteCount":1,"url":"https://github.com/fastapi/sqlmodel/discussions/1411#discussioncomment-13550575"}}}

How to reference field in __table_args__ #1411

Answered by yihuang
yihuang asked this question in Questions
Discussion options

You must be logged in to vote
class TOrder(SQLModel, table=True):
  user: str
  is_common: bool = Field(sa_column=Boolean)

  __table_args__ = (
    Index('ix_user_common', 'user', postgresql_where=(is_common.sa_column.is_(True)))
  )

this works

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yihuang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
1 participant