Fix ambiguous foreign keys on Pokemon.encounters relationship

Encounter has two FKs to pokemon (pokemon_id and current_pokemon_id),
so the reverse relationship needs an explicit foreign_keys argument.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 19:20:19 +01:00
parent 001ee98bb5
commit c8d8e4b445

View File

@@ -17,7 +17,9 @@ class Pokemon(Base):
route_encounters: Mapped[list["RouteEncounter"]] = relationship(
back_populates="pokemon"
)
encounters: Mapped[list["Encounter"]] = relationship(back_populates="pokemon")
encounters: Mapped[list["Encounter"]] = relationship(
foreign_keys="[Encounter.pokemon_id]", back_populates="pokemon"
)
def __repr__(self) -> str:
return f"<Pokemon(id={self.id}, name='{self.name}', dex={self.national_dex})>"