Add support for passing a custom SQLAlchemy type to Field() with sa_type (#505)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Maruo.S
2023-10-29 17:10:39 +09:00
committed by GitHub
parent c557cf6d18
commit cbaf172c63
2 changed files with 25 additions and 2 deletions

View File

@@ -39,6 +39,17 @@ def test_sa_column_no_sa_kargs() -> None:
)
def test_sa_column_no_type() -> None:
with pytest.raises(RuntimeError):
class Item(SQLModel, table=True):
id: Optional[int] = Field(
default=None,
sa_type=Integer,
sa_column=Column(Integer, primary_key=True),
)
def test_sa_column_no_primary_key() -> None:
with pytest.raises(RuntimeError):