mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
Prevent deleting databases that have attached tables (#5749)
* Prevent deleting databases that have attached tables Similar to logic preventing deleting tables that have charts attached. * Addressing comments
This commit is contained in:
parent
bd1f36d345
commit
6cc52c614c
@ -256,6 +256,13 @@ class DatabaseView(SupersetModelView, DeleteMixin, YamlExportMixin): # noqa
|
|||||||
def pre_update(self, db):
|
def pre_update(self, db):
|
||||||
self.pre_add(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):
|
def _delete(self, pk):
|
||||||
DeleteMixin._delete(self, pk)
|
DeleteMixin._delete(self, pk)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user