You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When specifying the ondelete cascade at one-to-many's one side (here the Hero class), with sa_relationship_kwargs, it's working, and ORM can handle the cascade delete well.
But if I tried to defined the ondelete cascade at one-to-many's many side to enable the SQL level cascade delete (here the Test class), with sa_column_kwargs, it doesn't work any more:
File "/home/xiang/git/fastapi-demo/.venv/lib/python3.11/site-packages/sqlmodel/main.py", line 474, in __new__ col = get_column_from_field(v) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xiang/git/fastapi-demo/.venv/lib/python3.11/site-packages/sqlmodel/main.py", line 661, in get_column_from_field return Column(sa_type, *args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xiang/git/fastapi-demo/.venv/lib/python3.11/site-packages/sqlalchemy/sql/schema.py", line 2152, in __init__ self._extra_kwargs(**dialect_kwargs) File "/home/xiang/git/fastapi-demo/.venv/lib/python3.11/site-packages/sqlalchemy/sql/schema.py", line 2234, in _extra_kwargs self._validate_dialect_kwargs(kwargs) File "/home/xiang/git/fastapi-demo/.venv/lib/python3.11/site-packages/sqlalchemy/sql/base.py", line 596, in _validate_dialect_kwargs raise TypeError(TypeError: Additional arguments should be named <dialectname>_<argument>, got 'ondelete'
But if we used the above issue's method, by using sa_column, it's working.
Cannot find any information about sa_column_kwargs, maybe it's not supported at all, but as we have sa_relationship_kwargs for one side, I suppose we should have also sa_column_kwargs for many side ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
The above example is from this issue:
#213 (comment)
When specifying the ondelete cascade at one-to-many's
one
side (here theHero
class), withsa_relationship_kwargs
, it's working, and ORM can handle the cascade delete well.But if I tried to defined the ondelete cascade at one-to-many's
many
side to enable the SQL level cascade delete (here theTest
class), withsa_column_kwargs
, it doesn't work any more:with error:
But if we used the above issue's method, by using
sa_column
, it's working.Cannot find any information about
sa_column_kwargs
, maybe it's not supported at all, but as we havesa_relationship_kwargs
forone
side, I suppose we should have alsosa_column_kwargs
formany
side ?Operating System
Linux, Windows
Operating System Details
Windows WSL
SQLModel Version
0.0.16
Python Version
Python 3.11.7
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions