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
  • Loading branch information
mistercrunch authored and betodealmeida committed Aug 28, 2018
1 parent bd1f36d commit 6cc52c6
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 @@ -256,6 +256,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 6cc52c6

Please sign in to comment.