How to add dialect specific index (postgres)? #571
-
First Check
Commit to Help
Example Codefrom sqlmodel import Field, SQLModel, Column
from sqlalchemy import Text, Index
import datetime
class Hero(SQLModel, table=True):
date_of_birth: datetime.date = Field(nullable=False, primary_key=True)
universe_time: datetime.datetime
likes_banana: bool = Field(nullable=True, index=Index('ix_hero_likes_banana', 'likes_banana', postgresql_using='hash'))
name: str = Field(sa_column=Column(Text())) DescriptionThe likes_banana index is using BTREE, not HASH type. Operating SystemLinux Operating System DetailsNo response SQLModel Version0.0.8 Python VersionPython 3.10.6 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
fishfacegit
Mar 16, 2023
Replies: 1 comment
-
Defining the index via SQLAlchemy separate from class will do the trick.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
fishfacegit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Defining the index via SQLAlchemy separate from class will do the trick.