docs: add warning that table=True disables Pydantic validation#1880
docs: add warning that table=True disables Pydantic validation#1880shubhamyx wants to merge 1 commit into
Conversation
📝 Docs previewLast commit 5f2d106 at: https://9dc34265.sqlmodel.pages.dev Modified Pages |
|
Hi, this PR is ready for review. It adds a warning in the docs to inform users that table=True disables Pydantic validation, which is a common source of confusion (as seen in issue #453). Happy to make any changes if needed. |
|
Hello @shubhamyx, Thanks for your effort! |
| !!! warning | ||
| When using `table=True`, SQLModel disables Pydantic's data validation. | ||
| This means invalid data (e.g. passing a `str` where a `bool` is expected) | ||
| will **not** raise a validation error. Use models without `table=True` | ||
| (like `HeroCreate`) for data validation at the API layer. | ||
|
|
There was a problem hiding this comment.
This is not how warnings work in this documentation.
Here is a proper example:
sqlmodel/docs/tutorial/code-structure.md
Lines 146 to 152 in 14ff908
- https://sqlmodel.tiangolo.com/tutorial/code-structure/
| !!! warning | |
| When using `table=True`, SQLModel disables Pydantic's data validation. | |
| This means invalid data (e.g. passing a `str` where a `bool` is expected) | |
| will **not** raise a validation error. Use models without `table=True` | |
| (like `HeroCreate`) for data validation at the API layer. | |
| /// warning | |
| When using `table=True`, SQLModel disables Pydantic's data validation. | |
| This means invalid data (e.g. passing a `str` where a `bool` is expected) | |
| will **not** raise a validation error. Use models without `table=True` | |
| (like `HeroCreate`) for data validation at the API layer. | |
| /// |
|
This has been waiting for the original user for a while and seems to be inactive, so it will be closed now. If there's still interest, feel free to start a new conversation. |
Closes #453
What this PR does
Adds a warning admonition in the Multiple Models with FastAPI tutorial
to inform users that SQLModel models with
table=Truedo not performPydantic data validation. This was reported as confusing and undocumented.