Skip to content

Conversation

@FlaviusRaducu
Copy link
Contributor

@FlaviusRaducu FlaviusRaducu commented Sep 26, 2025

For developers unfamiliar with SQLModel ( might be just me though :) ) creating a nullable primary key can be quite confusing when reading this tutorial section.
I believe, adding a bit more information resolves that initial confusion.
The extra comments have been taken from the official SQLModel docs.

@github-actions github-actions bot added the docs Documentation about how to use FastAPI label Sep 26, 2025
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@simone-trubian
Copy link

Hi @FlaviusRaducu thank you for taking the time to submit the improvement. I think you're right in saying that section should be more explicit in why that type signature is required. I feel however you could reword the submission to make it read less "staccato" that is less of an edit and more like something that was always there. As an example, Copilot suggest re-wording the paragraph likes so:

Declaring the type as int | None tells SQLModel that the column should be an INTEGER in the SQL database and that it can be NULL. However, in practice, the id column is always required and cannot be NULL—so why use int | None?

The reason is that although the id is mandatory in the database, it's not provided by our code. Instead, it's automatically generated by the database itself.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2025

@github-actions github-actions bot removed the waiting label Oct 1, 2025
Copy link
Member

@YuriiMotov YuriiMotov left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

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

Nice, thanks! 🚀

@tiangolo tiangolo changed the title 📝 Update Primary Key notes for the sql databases tutorial to avoid confusion 📝 Update Primary Key notes for the SQL databases tutorial to avoid confusion Dec 2, 2025
@tiangolo tiangolo merged commit bb05007 into fastapi:master Dec 2, 2025
43 checks passed
nilslindemann added a commit to nilslindemann/fastapi that referenced this pull request Dec 2, 2025
YuriiMotov added a commit that referenced this pull request Dec 2, 2025
* Sync with #14217

* Sync with #14359

* Sync with #13786

* Sync with #14070

* Sync with #14120

* Sync with #14211

* Sync with #14405

* "to deploy" -> "deployen"

The LLM used that translation a lot ithis convinced me that "deployen" it is the better word. "bereitstellen" (or "ausliefern") is still used for "to serve".

---------

Co-authored-by: Motov Yurii <[email protected]>
Co-authored-by: Yurii Motov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation about how to use FastAPI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants