Skip to content

Commit

Permalink
Set cascade_backrefs=False on History.jobs, add safeguard
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Dec 4, 2023
1 parent 5abd3e2 commit d275234
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2999,7 +2999,7 @@ class History(Base, HasTags, Dictifiable, UsesAnnotations, HasName, Serializable
galaxy_sessions = relationship("GalaxySessionToHistoryAssociation", back_populates="history")
workflow_invocations = relationship("WorkflowInvocation", back_populates="history", cascade_backrefs=False)
user = relationship("User", back_populates="histories")
jobs = relationship("Job", back_populates="history")
jobs = relationship("Job", back_populates="history", cascade_backrefs=False)

update_time = column_property(
select(func.max(HistoryAudit.update_time)).where(HistoryAudit.history_id == id).scalar_subquery(),
Expand Down
3 changes: 3 additions & 0 deletions test/integration/test_job_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import requests
from sqlalchemy import select
from sqlalchemy.orm import object_session

from galaxy import model
from galaxy.model.base import transaction
Expand Down Expand Up @@ -138,6 +139,8 @@ def create_static_job_with_state(self, state):
sa_session.commit()
job = model.Job()
job.history = history
# Safeguard: job was implicitly merged into this Session prior to SQLAlchemy 2.0.
object_session(history).add(job)
job.user = user
job.handler = "unknown-handler"
job.state = state
Expand Down

0 comments on commit d275234

Please sign in to comment.