-
-
Notifications
You must be signed in to change notification settings - Fork 688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sqlalchemy.Column
parameters are not passed forward when set on sqlmodel.Field
and a column is provided via sa_column
#314
Comments
@JLHasson I agree that this functionality doesn't really work as expected. I've seen a few other issues where people have run into similar issues, but I'm not sure there is a perfect solution to fix the problem. Maybe like you suggest a warning should be added, the docs could definitely use some improvement, as I don't think the "sa_column" parameter is even documented at the moment. For more complex projects I'd probably suggest people stick with vanilla SQLAlchemy. |
same issue, i hope they will fix it :( |
same issue, i hope they will fix it , hope sa_column will be more descriptions in the documentation,thanks |
I spent quite some time, figuring out why indexes were not being set. |
Yep, when you pass a Column you are overriding all the SQLAlchemy part, and those fields end up only used by Pydantic. I still have to document that, but that's the intention. |
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs. |
First Check
Commit to Help
Example Code
Description
sqlmodel.Field
exposes some but not all fields fromsqlalchemy.Column
. This means in some cases it is necessary to provide aColumn
via thesa_column=
param onsqlmodel.Field
. However, when this is the case the parameters set onsqlmodel.Field
are not forwarded to the newsa_column
object.I think the expected behavior here is that parameters set on
Field
would be combined with those from thesa_column
object. Either this or setting a parameter that will be ignored should trigger a warning/exception along the lines of"You have set index but also provided a sqlalchemy.Column object, index will be ignored"
.Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
3.9.5
Additional Context
No response
The text was updated successfully, but these errors were encountered: