From a2cda8377fa4c9e5a75d751571d715032bd5033e Mon Sep 17 00:00:00 2001 From: kurtportelli <47539697+kurtportelli@users.noreply.github.com> Date: Sun, 28 Aug 2022 01:43:42 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Update=20docs=20for=20models=20f?= =?UTF-8?q?or=20updating,=20`id`=20should=20not=20be=20updatable=20(#335)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: SebastiΓ‘n RamΓ­rez --- docs/tutorial/fastapi/relationships.md | 8 ++++---- docs/tutorial/fastapi/teams.md | 12 ++++++------ docs_src/tutorial/fastapi/teams/tutorial001.py | 1 - .../test_fastapi/test_teams/test_tutorial001.py | 1 - 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/tutorial/fastapi/relationships.md b/docs/tutorial/fastapi/relationships.md index 78ef330..6921b5a 100644 --- a/docs/tutorial/fastapi/relationships.md +++ b/docs/tutorial/fastapi/relationships.md @@ -55,11 +55,11 @@ And the same way, we declared the `TeamRead` with only the same base fields of t # Code here omitted πŸ‘ˆ -{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:32-37]!} +{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:31-36]!} # Code here omitted πŸ‘ˆ -{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:46-47]!} +{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:45-46]!} # Code below omitted πŸ‘‡ ``` @@ -80,11 +80,11 @@ In this case, we used `response_model=TeamRead` and `response_model=HeroRead`, s ```Python hl_lines="3 8 12 17" # Code above omitted πŸ‘† -{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:105-110]!} +{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:104-109]!} # Code here omitted πŸ‘ˆ -{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:160-165]!} +{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:159-164]!} # Code below omitted πŸ‘‡ ``` diff --git a/docs/tutorial/fastapi/teams.md b/docs/tutorial/fastapi/teams.md index 7a307b8..0b19a95 100644 --- a/docs/tutorial/fastapi/teams.md +++ b/docs/tutorial/fastapi/teams.md @@ -18,8 +18,8 @@ Then we also inherit from the `TeamBase` for the `TeamCreate` and `TeamRead` **d And we also create a `TeamUpdate` **data model**. -```Python hl_lines="7-9 12-15 18-19 22-23 26-29" -{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:1-29]!} +```Python hl_lines="7-9 12-15 18-19 22-23 26-28" +{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:1-28]!} # Code below omitted πŸ‘‡ ``` @@ -42,7 +42,7 @@ Let's now update the `Hero` models too. ```Python hl_lines="3-8 11-15 17-18 21-22 25-29" # Code above omitted πŸ‘† -{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:32-58]!} +{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:31-57]!} # Code below omitted πŸ‘‡ ``` @@ -66,10 +66,10 @@ And even though the `HeroBase` is *not* a **table model**, we can declare `team_ Notice that the **relationship attributes**, the ones with `Relationship()`, are **only** in the **table models**, as those are the ones that are handled by **SQLModel** with SQLAlchemy and that can have the automatic fetching of data from the database when we access them. -```Python hl_lines="11 39" +```Python hl_lines="11 38" # Code above omitted πŸ‘† -{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:7-58]!} +{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:7-57]!} # Code below omitted πŸ‘‡ ``` @@ -92,7 +92,7 @@ These are equivalent and very similar to the **path operations** for the **heroe ```Python hl_lines="3-9 12-20 23-28 31-47 50-57" # Code above omitted πŸ‘† -{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:140-194]!} +{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:139-193]!} # Code below omitted πŸ‘‡ ``` diff --git a/docs_src/tutorial/fastapi/teams/tutorial001.py b/docs_src/tutorial/fastapi/teams/tutorial001.py index e8f88b8..2a0bd60 100644 --- a/docs_src/tutorial/fastapi/teams/tutorial001.py +++ b/docs_src/tutorial/fastapi/teams/tutorial001.py @@ -24,7 +24,6 @@ class TeamRead(TeamBase): class TeamUpdate(SQLModel): - id: Optional[int] = None name: Optional[str] = None headquarters: Optional[str] = None diff --git a/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py index 852839b..6ac1cff 100644 --- a/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py @@ -442,7 +442,6 @@ openapi_schema = { "title": "TeamUpdate", "type": "object", "properties": { - "id": {"title": "Id", "type": "integer"}, "name": {"title": "Name", "type": "string"}, "headquarters": {"title": "Headquarters", "type": "string"}, },