| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Thanks! I would rather allow people to pass the full SQLAlchemy type if they want to customize it further. It is now possible with sa_type, in: #505 It will be available in the next version, 0.0.11 🎉 Given that, I'll close this one, but thanks for the effort! ☕ |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR adds an argument to Field to specify arguments for SQLAlchemy types. It also moves Enum above str when determining the SQLAlchemy type so that classes that extend both Enum and str are identified as Enum. A minimal example for using enums is provided below. It avoids needing to wrap the Enum in a Column and feels more unified with the other column types.
from enum import Enum from sqlmodel import Field, SQLModel class MyEnum(str, Enum): A = 'A' B = 'B' C = 'C' class MyTable(SQLModel, table=True): my_enum: MyEnum = Field(sa_type_kwargs={'create_constraint': True})