Skip to content

Commit

Permalink
Prevent deleting databases that have attached tables (apache#5749)
Browse files Browse the repository at this point in the history
* Prevent deleting databases that have attached tables

Similar to logic preventing deleting tables that have charts attached.

* Addressing comments

(cherry picked from commit 6cc52c6)
  • Loading branch information
mistercrunch committed Sep 19, 2018
1 parent 50f3528 commit 5f12fc1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ def pre_add(self, db):
def pre_update(self, db):
self.pre_add(db)

def pre_delete(self, obj):
if obj.tables:
raise SupersetException(Markup(
'Cannot delete a database that has tables attached. '
"Here's the list of associated tables: " +
', '.join('{}'.format(o) for o in obj.tables)))

def _delete(self, pk):
DeleteMixin._delete(self, pk)

Expand Down

0 comments on commit 5f12fc1

Please sign in to comment.