From 5715f52fef633473d5e7e1d554a7be97c0840fa8 Mon Sep 17 00:00:00 2001 From: vera-liu Date: Tue, 24 Jan 2017 21:49:02 -0800 Subject: [PATCH] [hotfix] delete DAR when datasource requested does not exist anymore (#2040) --- superset/source_registry.py | 2 +- superset/views.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/superset/source_registry.py b/superset/source_registry.py index 012d151053478..ff64265d4788c 100644 --- a/superset/source_registry.py +++ b/superset/source_registry.py @@ -20,7 +20,7 @@ def get_datasource(cls, datasource_type, datasource_id, session): return ( session.query(cls.sources[datasource_type]) .filter_by(id=datasource_id) - .one() + .first() ) @classmethod diff --git a/superset/views.py b/superset/views.py index ec428043571ec..524e3a20e7c61 100755 --- a/superset/views.py +++ b/superset/views.py @@ -1295,7 +1295,9 @@ def clean_fulfilled_requests(session): datasource = SourceRegistry.get_datasource( r.datasource_type, r.datasource_id, session) user = sm.get_user_by_id(r.created_by_fk) - if self.datasource_access(datasource, user): + if not datasource or \ + self.datasource_access(datasource, user): + # datasource doesnot exist anymore session.delete(r) session.commit() datasource_type = request.args.get('datasource_type')