You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2018/08/28 18:09:57 UTC
[incubator-superset] branch master updated: Prevent deleting
databases that have attached tables (#5749)
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 6cc52c6 Prevent deleting databases that have attached tables (#5749)
6cc52c6 is described below
commit 6cc52c614c5ace60e94e5d88d9f7a499e5d70cfe
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Tue Aug 28 11:08:12 2018 -0700
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
---
superset/views/core.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/superset/views/core.py b/superset/views/core.py
index 3b22a49..2cb7bf4 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -256,6 +256,13 @@ class DatabaseView(SupersetModelView, DeleteMixin, YamlExportMixin): # noqa
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)