mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Load all template model relationships when archiving a service
Since the version classes hinge on delicately preserving the session, we need to take lots of care to ensure that we don't accidentally flush half-way through. By joinedloading the template_redacted beforehand, we prevent a flush which would inadvertantly remove the Service object from the session, while it's still waiting in line to be versioned.
This commit is contained in:
@@ -111,6 +111,7 @@ def dao_archive_service(service_id):
|
||||
# to ensure that db.session still contains the models when it comes to creating history objects
|
||||
service = Service.query.options(
|
||||
joinedload('templates'),
|
||||
joinedload('templates.template_redacted'),
|
||||
joinedload('api_keys'),
|
||||
).filter(Service.id == service_id).one()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user