mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
New strategy for transaction management.
Introduce a contextmanger function to handle exceptions and nested transactions. Using the nested_transaction will start a nested transaction with `db.session.begin_nested`, once the nested transaction is complete the commit will happen. `@transactional` has been updated to commit unless in a nested transaction.
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
from sqlalchemy.sql.expression import func
|
||||
|
||||
from app import db
|
||||
from app.dao.dao_utils import (
|
||||
VersionOptions,
|
||||
nested_transactional,
|
||||
transactional,
|
||||
version_class,
|
||||
)
|
||||
from app.dao.dao_utils import VersionOptions, transactional, version_class
|
||||
from app.models import Domain, Organisation, Service, User
|
||||
|
||||
|
||||
@@ -110,7 +105,7 @@ def _update_organisation_services(organisation, attribute, only_where_none=True)
|
||||
db.session.add(service)
|
||||
|
||||
|
||||
@nested_transactional
|
||||
@transactional
|
||||
@version_class(Service)
|
||||
def dao_add_service_to_organisation(service, organisation_id):
|
||||
organisation = Organisation.query.filter_by(
|
||||
|
||||
Reference in New Issue
Block a user