Convert all fields to optional
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 HeroBase(SQLModel): name: str secret_name: str age: Optional[int] = None class HeroUpdate(HeroBase, all_optional=True): pass
Description
Is it possible to add the ability to modify the fields of a base class to convert them to all optional with a parameter like the table=True but in this case all_optional=True? This would help eliminate the duplication when creating a class for making updates.
Wanted Solution
Set all base fields to Optional based on keyword argument.
Wanted Code
class HeroBase(SQLModel): name: str secret_name: str age: Optional[int] = None class HeroUpdate(HeroBase, all_optional=True): pass
Alternatives
No response
Operating System
Linux, Windows
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.8.5
Additional Context
No response