]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
πŸ“ Update docs for models for updating, `id` should not be updatable (#335)
authorkurtportelli <47539697+kurtportelli@users.noreply.github.com>
Sat, 27 Aug 2022 23:43:42 +0000 (01:43 +0200)
committerGitHub <noreply@github.com>
Sat, 27 Aug 2022 23:43:42 +0000 (01:43 +0200)
Co-authored-by: SebastiΓ‘n RamΓ­rez <tiangolo@gmail.com>
docs/tutorial/fastapi/relationships.md
docs/tutorial/fastapi/teams.md
docs_src/tutorial/fastapi/teams/tutorial001.py
tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py

index 78ef330fc1d115e487f4c73f23c33cb8c3aa5355..6921b5ac8524cd43d4c5b3cb355ab5eb94a75776 100644 (file)
@@ -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 πŸ‘‡
 ```
index 7a307b87f56ff0fec616e46cd80f3b6e7875d06a..0b19a95cb373b720aae78621acc6f453ff99aafb 100644 (file)
@@ -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 πŸ‘‡
 ```
index e8f88b8e9ef5c6e7ea911a885ef55fd488115bcf..2a0bd600fc94631a45c0ba326a7c05eececc3294 100644 (file)
@@ -24,7 +24,6 @@ class TeamRead(TeamBase):
 
 
 class TeamUpdate(SQLModel):
-    id: Optional[int] = None
     name: Optional[str] = None
     headquarters: Optional[str] = None
 
index 852839b2a18f7122da093df6366dae8b9d1e8830..6ac1cffc5ef67ab01fa948b2ce507df504eacc75 100644 (file)
@@ -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"},
                 },