diff --git a/augur/application/db/models/augur_data.py b/augur/application/db/models/augur_data.py index 606236df21..bdbdb8f8a6 100644 --- a/augur/application/db/models/augur_data.py +++ b/augur/application/db/models/augur_data.py @@ -878,7 +878,13 @@ class Repo(Base): @staticmethod def get_by_id(session, repo_id): - return session.query(Repo).filter(Repo.repo_id == repo_id).first() + try: + return session.query(Repo).filter(Repo.repo_id == repo_id).first() + except Exception as e: + session.rollback() + raise e + + @staticmethod def get_by_repo_git(session, repo_git): diff --git a/augur/application/db/models/augur_operations.py b/augur/application/db/models/augur_operations.py index 47f28b12f2..029444215e 100644 --- a/augur/application/db/models/augur_operations.py +++ b/augur/application/db/models/augur_operations.py @@ -329,6 +329,9 @@ def get_user(session, username: str): return user except NoResultFound: return None + except Exception as e: + session.rollback() + raise e @staticmethod def get_by_id(session, user_id: int): @@ -1073,7 +1076,13 @@ def __eq__(self, other): @staticmethod def get_by_id(session, client_id): - return session.query(ClientApplication).filter(ClientApplication.id == client_id).first() + + try: + return session.query(ClientApplication).filter(ClientApplication.id == client_id).first() + except Exception as e: + session.rollback() + raise e + class Subscription(Base): __tablename__ = "subscriptions"