From 567e7db90a217d4ed9a19d38f38b2f2982e4ea5c Mon Sep 17 00:00:00 2001 From: User Date: Fri, 5 Jul 2024 18:52:38 -0500 Subject: [PATCH 1/5] Update docs --- docs/tutorial/automatic-id-none-refresh.md | 2 +- docs/tutorial/create-db-and-table.md | 2 +- docs/tutorial/where.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/tutorial/automatic-id-none-refresh.md b/docs/tutorial/automatic-id-none-refresh.md index 1f98a76cfe..1963492359 100644 --- a/docs/tutorial/automatic-id-none-refresh.md +++ b/docs/tutorial/automatic-id-none-refresh.md @@ -4,7 +4,7 @@ In the previous chapter, we saw how to add rows to the database using **SQLModel Now let's talk a bit about why the `id` field **can't be `NULL`** on the database because it's a **primary key**, and we declare it using `Field(primary_key=True)`. -But the same `id` field actually **can be `None`** in the Python code, so we declare the type with `Optional[int]`, and set the default value to `Field(default=None)`: +But the same `id` field actually **can be `None`** in the Python code, so we declare the type with `int | None (or Optional[int])`, and set the default value to `Field(default=None)`: //// tab | Python 3.10+ diff --git a/docs/tutorial/create-db-and-table.md b/docs/tutorial/create-db-and-table.md index d87b935a1c..19d695be45 100644 --- a/docs/tutorial/create-db-and-table.md +++ b/docs/tutorial/create-db-and-table.md @@ -145,7 +145,7 @@ Let's now see with more detail these field/column declarations. ### Optional Fields, Nullable Columns -Let's start with `age`, notice that it has a type of `Optional[int]`. +Let's start with `age`, notice that it has a type of `int | None (or Optional[int])`. And we import that `Optional` from the `typing` standard module. diff --git a/docs/tutorial/where.md b/docs/tutorial/where.md index 46306561b4..5bc3139b57 100644 --- a/docs/tutorial/where.md +++ b/docs/tutorial/where.md @@ -1250,7 +1250,7 @@ It would be an error telling you that > `Hero.age` is potentially `None`, and you cannot compare `None` with `>` -This is because as we are using pure and plain Python annotations for the fields, `age` is indeed annotated as `Optional[int]`, which means `int` or `None`. +This is because as we are using pure and plain Python annotations for the fields, `age` is indeed annotated as `int | None (or Optional[int])`. By using this simple and standard Python type annotations we get the benefit of the extra simplicity and the inline error checks when creating or using instances. ✨ From ffce380ea3a586f957ed86de09fca2c07da1c8b8 Mon Sep 17 00:00:00 2001 From: User Date: Sun, 7 Jul 2024 21:51:13 -0500 Subject: [PATCH 2/5] typo --- docs/tutorial/connect/create-connected-rows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/connect/create-connected-rows.md b/docs/tutorial/connect/create-connected-rows.md index d72c0b2247..164aea208a 100644 --- a/docs/tutorial/connect/create-connected-rows.md +++ b/docs/tutorial/connect/create-connected-rows.md @@ -119,7 +119,7 @@ Let's start by creating two teams: /// -This would hopefully look already familiar. +This would hopefully looks already familiar. We start a **session** in a `with` block using the same **engine** we created above. From c1cdc6c639ed2961802c14e8d4dacfe276c8fa21 Mon Sep 17 00:00:00 2001 From: User Date: Mon, 8 Jul 2024 11:35:44 -0500 Subject: [PATCH 3/5] Tweak --- .../relationship-attributes/create-and-update-relationships.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/relationship-attributes/create-and-update-relationships.md b/docs/tutorial/relationship-attributes/create-and-update-relationships.md index 8b34f0cb53..ce2f4d87d4 100644 --- a/docs/tutorial/relationship-attributes/create-and-update-relationships.md +++ b/docs/tutorial/relationship-attributes/create-and-update-relationships.md @@ -134,7 +134,7 @@ Now let's do all that, but this time using the new, shiny `Relationship` attribu Now we can create the `Team` instances and pass them directly to the new `team` argument when creating the `Hero` instances, as `team=team_preventers` instead of `team_id=team_preventers.id`. -And thanks to SQLAlchemy and how it works underneath, these teams don't even have to have an ID yet, but because we are assigning the whole object to each hero, those teams **will be automatically created** in the database, the automatic ID will be generated, and will be set in the `team_id` column for each of the corresponding hero rows. +And thanks to SQLAlchemy and how it works underneath, these teams don't even need to have an ID yet, but because we are assigning the whole object to each hero, those teams **will be automatically created** in the database, the automatic ID will be generated, and will be set in the `team_id` column for each of the corresponding hero rows. In fact, now we don't even have to put the teams explicitly in the session with `session.add(team)`, because these `Team` instances are **already associated** with heroes that **we do** `add` to the session. From a85175b2bda2d90cf22032d529e7ee9d41770cbd Mon Sep 17 00:00:00 2001 From: Alejandra <90076947+alejsdev@users.noreply.github.com> Date: Tue, 16 Jul 2024 21:56:07 -0500 Subject: [PATCH 4/5] Update create-connected-rows.md --- docs/tutorial/connect/create-connected-rows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/connect/create-connected-rows.md b/docs/tutorial/connect/create-connected-rows.md index 164aea208a..d72c0b2247 100644 --- a/docs/tutorial/connect/create-connected-rows.md +++ b/docs/tutorial/connect/create-connected-rows.md @@ -119,7 +119,7 @@ Let's start by creating two teams: /// -This would hopefully looks already familiar. +This would hopefully look already familiar. We start a **session** in a `with` block using the same **engine** we created above. From 49f8a8fa2ee3c8dec7b071d5065718449e14ef37 Mon Sep 17 00:00:00 2001 From: User Date: Tue, 3 Sep 2024 16:02:56 +0200 Subject: [PATCH 5/5] Remove highlight in indexes.md --- docs/tutorial/indexes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorial/indexes.md b/docs/tutorial/indexes.md index d0854720cf..7a24dd9435 100644 --- a/docs/tutorial/indexes.md +++ b/docs/tutorial/indexes.md @@ -24,7 +24,7 @@ Fine, in that case, you can **sneak peek** the final code to create indexes here //// tab | Python 3.10+ -```Python hl_lines="8 10" +```Python {!./docs_src/tutorial/indexes/tutorial002_py310.py!} ``` @@ -32,7 +32,7 @@ Fine, in that case, you can **sneak peek** the final code to create indexes here //// tab | Python 3.7+ -```Python hl_lines="8 10" +```Python {!./docs_src/tutorial/indexes/tutorial002.py!} ```