Skip to content

Commit

Permalink
fix: Ensure consistent rollback logic (#20811)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley committed Jul 25, 2022
1 parent 0945d4a commit 7a1aa79
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions superset/annotation_layers/annotations/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def bulk_delete(models: Optional[List[Annotation]], commit: bool = True) -> None
if commit:
db.session.commit()
except SQLAlchemyError as ex:
if commit:
db.session.rollback()
db.session.rollback()
raise DAODeleteFailedError() from ex

@staticmethod
Expand Down
3 changes: 1 addition & 2 deletions superset/annotation_layers/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def bulk_delete(
if commit:
db.session.commit()
except SQLAlchemyError as ex:
if commit:
db.session.rollback()
db.session.rollback()
raise DAODeleteFailedError() from ex

@staticmethod
Expand Down
3 changes: 1 addition & 2 deletions superset/charts/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def bulk_delete(models: Optional[List[Slice]], commit: bool = True) -> None:
if commit:
db.session.commit()
except SQLAlchemyError as ex:
if commit:
db.session.rollback()
db.session.rollback()
raise ex

@staticmethod
Expand Down
3 changes: 1 addition & 2 deletions superset/dashboards/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ def bulk_delete(models: Optional[List[Dashboard]], commit: bool = True) -> None:
if commit:
db.session.commit()
except SQLAlchemyError as ex:
if commit:
db.session.rollback()
db.session.rollback()
raise ex

@staticmethod
Expand Down
3 changes: 1 addition & 2 deletions superset/queries/saved_queries/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ def bulk_delete(models: Optional[List[SavedQuery]], commit: bool = True) -> None
if commit:
db.session.commit()
except SQLAlchemyError as ex:
if commit:
db.session.rollback()
db.session.rollback()
raise DAODeleteFailedError() from ex
6 changes: 2 additions & 4 deletions superset/reports/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ def bulk_delete(
if commit:
db.session.commit()
except SQLAlchemyError as ex:
if commit:
db.session.rollback()
db.session.rollback()
raise DAODeleteFailedError(str(ex)) from ex

@staticmethod
Expand Down Expand Up @@ -324,6 +323,5 @@ def bulk_delete_logs(
session.commit()
return row_count
except SQLAlchemyError as ex:
if commit:
session.rollback()
session.rollback()
raise DAODeleteFailedError(str(ex)) from ex

0 comments on commit 7a1aa79

Please sign in to comment.