First Check
Commit to Help
Example Code
class MyModel(DBModel, table=True):
id: Optional[int] = Field( primary_key=True)
Description
Thanks for the great library. I'm just
If I have a model like this:
class MyModel(DBModel, table=True):
id: Optional[int] = Field( primary_key=True)
Then when saving new records to the database, the ID is automatically assigned, which is great.
However, when I retrieve the model like this I get type errors
model = session.get(MyModel, 1)
id: int = model.id # ID may be None error
Is there a way to auto-assign my IDs but also have the ID type defined when retrieving saved records?
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
3.10.4
Additional Context
No response
First Check
Commit to Help
Example Code
Description
Thanks for the great library. I'm just
If I have a model like this:
Then when saving new records to the database, the ID is automatically assigned, which is great.
However, when I retrieve the model like this I get type errors
Is there a way to auto-assign my IDs but also have the ID type defined when retrieving saved records?
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
3.10.4
Additional Context
No response