Skip to content

docs: add warning that table=True disables Pydantic validation#1880

Open
shubhamyx wants to merge 1 commit intofastapi:mainfrom
shubhamyx:docs/fix-table-true-validation-warning
Open

docs: add warning that table=True disables Pydantic validation#1880
shubhamyx wants to merge 1 commit intofastapi:mainfrom
shubhamyx:docs/fix-table-true-validation-warning

Conversation

@shubhamyx
Copy link
Copy Markdown

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=True do not perform
Pydantic data validation. This was reported as confusing and undocumented.

@github-actions github-actions Bot added the docs Improvements or additions to documentation label Apr 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

@shubhamyx
Copy link
Copy Markdown
Author

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.

@Jamim
Copy link
Copy Markdown

Jamim commented May 6, 2026

Hello @shubhamyx,

Thanks for your effort!
Please take a look at a modified page in the docs preview.
Your text doesn't look like a proper warning there.

Comment on lines +120 to +125
!!! 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.

Copy link
Copy Markdown

@Jamim Jamim May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how warnings work in this documentation.

Here is a proper example:

Suggested change
!!! 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.
///

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why does a SQLModel class with table=True not validate data ?

4 participants