-
-
Notifications
You must be signed in to change notification settings - Fork 792
✨ Make field's description interpret as column's comment #1335
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
base: main
Are you sure you want to change the base?
Conversation
|
Great minds think alike :) |
|
So in the meantime I patched the current version of SQLModel and it works for Postgres as expected: |
|
Yeah, I have a similar patch implemented in this project: https://github.com/iloveitaly/activemodel Supports table-level comments as well. |
svlandeg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the contribution! I'll put this PR in draft as long as the test suite is failing 🙏
|
@svlandeg The test suite will be falling until we find a way how to add postgresql functionality to the test suite. |
| } | ||
| description = getattr(field_info, "description", Undefined) | ||
| if description is not Undefined: | ||
| kwargs["comment"] = description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| kwargs["comment"] = description | |
| kwargs["postgresql_comment"] = description |
It might be worth trying with this to make the tests work to take advantage of dialect specific arguments. Then the tests should pass when using SQLite (after updating them as they currently only check for the comment kwarg).
I have fields with
descriptionattributes I'd like to use ascomments on columns in Postgresql tables.All tests in sqlmodel use sqlite that does not support column comments. So my test in this PR does not work. What would be the best way to test it for Postgres (and other RDBMs supporting column comments)?
When I locally replace the
sqlite://with a proper Postgresql connect string to my local database, the test passes.There's #1293, but also without working test.