superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From christ...@apache.org
Subject [incubator-superset] branch master updated: Fix database typeahead in SQL Lab (#6917)
Date Wed, 20 Feb 2019 00:10:23 GMT
This is an automated email from the ASF dual-hosted git repository.

christine 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 25ec00b  Fix database typeahead in SQL Lab (#6917)
25ec00b is described below

commit 25ec00b3c6717a1800199b685ed160b38bc0ee17
Author: Beto Dealmeida <roberto@dealmeida.net>
AuthorDate: Tue Feb 19 16:10:17 2019 -0800

    Fix database typeahead in SQL Lab (#6917)
    
    * Fix database typeahead in SQL Lab
    
    * Fix lint
    
    * Use string interpolation
---
 superset/assets/src/components/TableSelector.jsx |  6 +++++-
 superset/views/core.py                           | 15 ++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/superset/assets/src/components/TableSelector.jsx b/superset/assets/src/components/TableSelector.jsx
index 6130fc6..0452854 100644
--- a/superset/assets/src/components/TableSelector.jsx
+++ b/superset/assets/src/components/TableSelector.jsx
@@ -111,7 +111,11 @@ export default class TableSelector extends React.PureComponent {
     if (data.result.length === 0) {
       this.props.handleError(t("It seems you don't have access to any database"));
     }
-    return data.result;
+    return data.result.map(row => ({
+      ...row,
+      // label is used for the typeahead
+      label: `${row.backend} ${row.database_name}`,
+    }));
   }
   fetchTables(force, substr) {
     // This can be large so it shouldn't be put in the Redux store
diff --git a/superset/views/core.py b/superset/views/core.py
index fa70498..03e352f 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -1524,12 +1524,17 @@ class Superset(BaseSupersetView):
             db.session
             .query(models.Database)
             .filter_by(id=db_id)
-            .one()
+            .first()
         )
-        schemas = database.all_schema_names(cache=database.schema_cache_enabled,
-                                            cache_timeout=database.schema_cache_timeout,
-                                            force=force_refresh)
-        schemas = security_manager.schemas_accessible_by_user(database, schemas)
+        if database:
+            schemas = database.all_schema_names(
+                cache=database.schema_cache_enabled,
+                cache_timeout=database.schema_cache_timeout,
+                force=force_refresh)
+            schemas = security_manager.schemas_accessible_by_user(database, schemas)
+        else:
+            schemas = []
+
         return Response(
             json.dumps({'schemas': schemas}),
             mimetype='application/json')


Mime
View raw message