[hotfix] delete DAR when datasource requested does not exist anymore (#2040)

This commit is contained in:
vera-liu 2017-01-24 21:49:02 -08:00 committed by GitHub
parent 1f2126f463
commit 5715f52fef
2 changed files with 4 additions and 2 deletions

View File

@ -20,7 +20,7 @@ class SourceRegistry(object):
return (
session.query(cls.sources[datasource_type])
.filter_by(id=datasource_id)
.one()
.first()
)
@classmethod

View File

@ -1295,7 +1295,9 @@ class Superset(BaseSupersetView):
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')