-
-
Notifications
You must be signed in to change notification settings - Fork 781
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the SQLModel documentation, with the integrated search.
- I already searched in Google "How to X in SQLModel" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to SQLModel but to Pydantic.
- I already checked if it is not related to SQLModel but to SQLAlchemy.
Commit to Help
- I commit to help with one of those options π
Example Code
class Contract(SQLModel, table=True):
"""A contract defines the business conditions of a project"""
id: Optional[int] = Field(default=None, primary_key=True)
title: str = Field(description="Short description of the contract.")
client: Client = Relationship(
back_populates="contracts",
)
signature_date: datetime.date = Field(
description="Date on which the contract was signed",
)
start_date: datetime.date = Field(
description="Date from which the contract is valid",
)
end_date: Optional[datetime.date] = Field(
description="Date until which the contract is valid",
)Description
I was happy to find out that every attribute of a SQLModel class can be documented with ... = Field(description="attribute meaning here"). Let's do more of that. However, I was confused when I tried to access and display the field description and didn't find a way to do that.
Given the example class Contract, accessing Contract.signature_date.description gives the following output: 'signature_date'
- This output is so counter-intuitive that it may be a bug
- How do I access the string I supplied with the
Field(description=...)argument? - Is there a neat way to show all the fields with their descriptions?
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
Python 3.9.7
Additional Context
No response
StLWallace and Exiled1
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested