Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use class-bound attribute directly in SA joinedload #39198

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions airflow/models/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,16 @@ def from_object(cls, trigger: BaseTrigger) -> Trigger:
@provide_session
def bulk_fetch(cls, ids: Iterable[int], session: Session = NEW_SESSION) -> dict[int, Trigger]:
"""Fetch all the Triggers by ID and return a dict mapping ID -> Trigger instance."""
query = session.scalars(
stmt = (
select(cls)
.where(cls.id.in_(ids))
.options(
joinedload("task_instance"),
joinedload("task_instance.trigger"),
joinedload("task_instance.trigger.triggerer_job"),
joinedload(cls.task_instance)
.joinedload(TaskInstance.trigger)
.joinedload(Trigger.triggerer_job)
)
)
return {obj.id: obj for obj in query}
return {obj.id: obj for obj in session.scalars(stmt)}

@classmethod
@internal_api_call
Expand Down