Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

✨ 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
eumiro wants to merge1 commit intofastapi:main
base:main
Choose a base branch
Loading
fromeumiro:field-description-is-comment

Conversation

eumiro
Copy link

I have fields withdescription attributes 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 thesqlite:// with a proper Postgresql connect string to my local database, the test passes.

There's#1293, but also without working test.

@iloveitaly
Copy link

iloveitaly commentedMar 31, 2025
edited
Loading

Great minds think alike :)

#1293

eumiro reacted with thumbs up emoji

@eumiro
Copy link
Author

So in the meantime I patched the current version of SQLModel and it works for Postgres as expected:

def patch_get_column_from_field():    original_get_column_from_field = sqlmodel.main.get_column_from_field    def patched_get_column_from_field(field: typing.Any) -> sqlmodel.Column:        column = original_get_column_from_field(field)        if hasattr(field, "description"):            column.comment = field.description        return column    sqlmodel.main.get_column_from_field = patched_get_column_from_field

@iloveitaly
Copy link

Yeah, I have a similar patch implemented in this project:https://github.com/iloveitaly/activemodel

Supports table-level comments as well.

@svlandegsvlandeg changed the titleMake field's description interpret as column's comment✨ Make field's description interpret as column's commentApr 4, 2025
@svlandegsvlandeg added the featureNew feature or request labelApr 4, 2025
Copy link
Member

@svlandegsvlandeg left a 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 🙏

@svlandegsvlandeg marked this pull request as draftApril 4, 2025 08:04
@eumiro
Copy link
Author

@svlandeg The test suite will be falling until we find a way how to add postgresql functionality to the test suite.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@svlandegsvlandegsvlandeg left review comments

Assignees
No one assigned
Labels
featureNew feature or request
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@eumiro@iloveitaly@svlandeg

[8]ページ先頭

©2009-2025 Movatter.jp