diff --git a/backend/backend/models/stop.py b/backend/backend/models/stop.py index f75e1ea..d286878 100644 --- a/backend/backend/models/stop.py +++ b/backend/backend/models/stop.py @@ -130,12 +130,12 @@ class StopArea(_Stop): id = mapped_column(BigInteger, ForeignKey("_stops.id"), primary_key=True) type = mapped_column(Enum(StopAreaType), nullable=False) - stops: Mapped[list["_Stop"]] = relationship( - "_Stop", + + stops: Mapped[list["Stop"]] = relationship( + "Stop", secondary=stop_area_stop_association_table, back_populates="areas", lazy="selectin", - # lazy="joined", ) __tablename__ = "stop_areas" @@ -157,17 +157,17 @@ class StopArea(_Stop): stop_area_ids.add(stop_area_id) stop_ids.add(stop_id) - stop_areas_res = await session.execute( + stop_areas_res = await session.scalars( select(StopArea) .where(StopArea.id.in_(stop_area_ids)) .options(selectinload(StopArea.stops)) ) stop_areas: dict[int, StopArea] = { - stop_area.id: stop_area for stop_area in stop_areas_res.scalars() + stop_area.id: stop_area for stop_area in stop_areas_res.all() } - stop_res = await session.execute(select(_Stop).where(_Stop.id.in_(stop_ids))) - stops: dict[int, _Stop] = {stop.id: stop for stop in stop_res.scalars()} + stop_res = await session.execute(select(Stop).where(Stop.id.in_(stop_ids))) + stops: dict[int, Stop] = {stop.id: stop for stop in stop_res.scalars()} found = 0 for stop_area_id, stop_id in stop_area_to_stop_ids: