From 70228ad3fb68437357edd17751b57447a47fb4e7 Mon Sep 17 00:00:00 2001 From: serenajiang Date: Thu, 16 Dec 2021 11:49:40 -0800 Subject: [PATCH] fix(dashboard): commit update once (#17781) (cherry picked from commit 3657cbea7f5c37ccc06280b6c5230c1fdad76f9e) --- superset/dashboards/commands/update.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/superset/dashboards/commands/update.py b/superset/dashboards/commands/update.py index 5384e4590ca36..2065437cc3b31 100644 --- a/superset/dashboards/commands/update.py +++ b/superset/dashboards/commands/update.py @@ -34,6 +34,7 @@ ) from superset.dashboards.dao import DashboardDAO from superset.exceptions import SupersetSecurityException +from superset.extensions import db from superset.models.dashboard import Dashboard from superset.views.base import check_ownership @@ -51,13 +52,14 @@ def run(self) -> Model: self.validate() try: dashboard = DashboardDAO.update(self._model, self._properties, commit=False) - dashboard = DashboardDAO.update_charts_owners(dashboard, commit=True) + dashboard = DashboardDAO.update_charts_owners(dashboard, commit=False) if self._properties.get("json_metadata"): dashboard = DashboardDAO.set_dash_metadata( dashboard, data=json.loads(self._properties.get("json_metadata", "{}")), - commit=True, + commit=False, ) + db.session.commit() except DAOUpdateFailedError as ex: logger.exception(ex.exception) raise DashboardUpdateFailedError() from ex