Skip to content

Commit

Permalink
fix: dashboard cache invalid join query (#11369)
Browse files Browse the repository at this point in the history
* bugfix: dashboard cache invalid join query

* Use engine instead of session
  • Loading branch information
ktmud committed Oct 22, 2020
1 parent 633355a commit b89a5d6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions superset/models/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -312,13 +312,13 @@ 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):
for (dashboard_id,) in db.engine.execute(filter_query):
cls(id=dashboard_id).clear_cache()

@classmethod
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit b89a5d6

Please sign in to comment.