Skip to content

Commit

Permalink
Merge pull request #2777 from chaoss/fix-session-rollback
Browse files Browse the repository at this point in the history
Rollback transaction when query throws exception
  • Loading branch information
sgoggins authored Apr 28, 2024
2 parents b6286f8 + a6253f0 commit eb97403
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion augur/application/db/models/augur_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 10 additions & 1 deletion augur/application/db/models/augur_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit eb97403

Please sign in to comment.