TypeAdapter don't work with table=True #905
Unanswered
davisylvestre
asked this question in
Questions
Replies: 1 comment
-
Well it looks like TypeAdapter default validation does not take care of To make your code works I changed the following, forcing the call of daily_adapter = TypeAdapter(list[Annotated[Daily, BeforeValidator(Daily.model_validate)]]) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
TypeAdapter does not invoke validators when a model is created with the
table=True
argument.I carried out some tests, and it works perfectly with the
model_validate
method.When using the TypeAdapter, validations are only invoked when the object is not a dict, but an exception occurs when saving to the database.
When I use the TypeAdapter with dict, the validators are not invoked.
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.16
Python Version
Python 3.12.0
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions