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:
@@ -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})>"
|
||||
|
||||
Reference in New Issue
Block a user