]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
Rename `Weapon.hero` field to `Weapon.owner` in code example to better reflect meaning fix-hero-weapon-code-example 1718/head
authorYurii Motov <yurii.motov.monte@gmail.com>
Thu, 22 Jan 2026 13:59:01 +0000 (14:59 +0100)
committerYurii Motov <yurii.motov.monte@gmail.com>
Thu, 22 Jan 2026 13:59:01 +0000 (14:59 +0100)
docs_src/tutorial/relationship_attributes/back_populates/tutorial003_py310.py
docs_src/tutorial/relationship_attributes/back_populates/tutorial003_py39.py

index aa850b3f695bb18a6ac05718761085700364fff1..a759c83965bcdf9c7a7c9e499ddc584b408e37a9 100644 (file)
@@ -5,7 +5,7 @@ class Weapon(SQLModel, table=True):
     id: int | None = Field(default=None, primary_key=True)
     name: str = Field(index=True)
 
-    hero: "Hero" = Relationship(back_populates="weapon")
+    owner: "Hero" = Relationship(back_populates="weapon")
 
 
 class Power(SQLModel, table=True):
@@ -34,7 +34,7 @@ class Hero(SQLModel, table=True):
     team: Team | None = Relationship(back_populates="heroes")
 
     weapon_id: int | None = Field(default=None, foreign_key="weapon.id")
-    weapon: Weapon | None = Relationship(back_populates="hero")
+    weapon: Weapon | None = Relationship(back_populates="owner")
 
     powers: list[Power] = Relationship(back_populates="hero")
 
index fc0d08df522e605d0169e2b3d3a7b4929eaf9546..3cb510ebafe3f14b088f1da67852f7adb895c843 100644 (file)
@@ -7,7 +7,7 @@ class Weapon(SQLModel, table=True):
     id: Optional[int] = Field(default=None, primary_key=True)
     name: str = Field(index=True)
 
-    hero: "Hero" = Relationship(back_populates="weapon")
+    owner: "Hero" = Relationship(back_populates="weapon")
 
 
 class Power(SQLModel, table=True):
@@ -36,7 +36,7 @@ class Hero(SQLModel, table=True):
     team: Optional[Team] = Relationship(back_populates="heroes")
 
     weapon_id: Optional[int] = Field(default=None, foreign_key="weapon.id")
-    weapon: Optional[Weapon] = Relationship(back_populates="hero")
+    weapon: Optional[Weapon] = Relationship(back_populates="owner")
 
     powers: list[Power] = Relationship(back_populates="hero")