Add support for cascade delete relationships: cascade_delete, ondelete, and passive_deletes (#983)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Esteban Maya
2024-07-20 21:08:06 -05:00
committed by GitHub
parent 19c736766e
commit 86ab09f7ec
37 changed files with 4501 additions and 2 deletions

View File

@@ -108,3 +108,14 @@ def test_sa_column_no_index() -> None:
index=True,
sa_column=Column(Integer, primary_key=True),
)
def test_sa_column_no_ondelete() -> None:
with pytest.raises(RuntimeError):
class Item(SQLModel, table=True):
id: Optional[int] = Field(
default=None,
sa_column=Column(Integer, primary_key=True),
ondelete="CASCADE",
)