From 73f5cc04bc9d190b8b77fc02c5ba214630912170 Mon Sep 17 00:00:00 2001 From: Jesse Yang Date: Wed, 21 Oct 2020 11:15:28 -0700 Subject: [PATCH 1/2] bugfix: dashboard cache invalid join query --- superset/models/dashboard.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py index e505b9274133..f13d0b21a38b 100644 --- a/superset/models/dashboard.py +++ b/superset/models/dashboard.py @@ -312,10 +312,10 @@ def clear_cache_for_datasource(cls, datasource_id: int) -> None: [dashboard_slices.c.dashboard_id], distinct=True, ).select_from( join( - Slice, dashboard_slices, - Slice.id == dashboard_slices.c.slice_id, - Slice.datasource_id == datasource_id, + Slice, + (Slice.id == dashboard_slices.c.slice_id) + & (Slice.datasource_id == datasource_id), ) ) for (dashboard_id,) in db.session.execute(filter_query): @@ -598,7 +598,7 @@ def clear_dashboard_cache( sqla.event.listen(Slice, "after_update", clear_dashboard_cache) sqla.event.listen(Slice, "after_delete", clear_dashboard_cache) sqla.event.listen( - BaseDatasource, "after_update", clear_dashboard_cache, propagage=True + BaseDatasource, "after_update", clear_dashboard_cache, propagate=True ) # also clear cache on column/metric updates since updates to these will not # trigger update events for BaseDatasource. From 37582fc3cde032ac215b319472afce5e57cd1bde Mon Sep 17 00:00:00 2001 From: Jesse Yang Date: Wed, 21 Oct 2020 19:30:40 -0700 Subject: [PATCH 2/2] Use engine instead of session --- superset/models/dashboard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py index f13d0b21a38b..777953880cc3 100644 --- a/superset/models/dashboard.py +++ b/superset/models/dashboard.py @@ -302,7 +302,7 @@ def clear_cache_for_slice(cls, slice_id: int) -> None: filter_query = select([dashboard_slices.c.dashboard_id], distinct=True).where( dashboard_slices.c.slice_id == slice_id ) - for (dashboard_id,) in db.session.execute(filter_query): + for (dashboard_id,) in db.engine.execute(filter_query): cls(id=dashboard_id).clear_cache() @classmethod @@ -318,7 +318,7 @@ def clear_cache_for_datasource(cls, datasource_id: int) -> None: & (Slice.datasource_id == datasource_id), ) ) - for (dashboard_id,) in db.session.execute(filter_query): + for (dashboard_id,) in db.engine.execute(filter_query): cls(id=dashboard_id).clear_cache() @classmethod