diff --git a/apps/volunteer/schedule.py b/apps/volunteer/schedule.py index 175d343e3..039b565f8 100644 --- a/apps/volunteer/schedule.py +++ b/apps/volunteer/schedule.py @@ -6,7 +6,7 @@ from flask import current_app as app from collections import defaultdict from flask_login import current_user -from sqlalchemy.orm import joinedload, defer +from sqlalchemy.orm import joinedload from main import db from models import event_year @@ -121,7 +121,6 @@ def schedule_ical(): .select_from(ShiftEntry) .join(Shift.entries.and_(ShiftEntry.user == user)) .options( - defer(Shift.current_count), # the subquery for that column breaks this query joinedload(Shift.venue), joinedload(Shift.role) )).all() diff --git a/models/volunteer/shift.py b/models/volunteer/shift.py index 33f70e292..2325a2430 100644 --- a/models/volunteer/shift.py +++ b/models/volunteer/shift.py @@ -71,7 +71,7 @@ class Shift(BaseModel): proposal = db.relationship("Proposal", backref="shift") current_count = db.column_property( - select([func.count(ShiftEntry.shift_id)]).where(ShiftEntry.shift_id == id).scalar_subquery() # type: ignore[attr-defined] + select([func.count(ShiftEntry.shift_id)]).where(ShiftEntry.shift_id == id).correlate_except(ShiftEntry).scalar_subquery() # type: ignore[attr-defined] ) duration = db.column_property(end - start)