Procházet zdrojové kódy

HUE-9367 [phoenix] Handle empty DB as ' ' (not 'NULL'?)

Romain před 5 roky
rodič
revize
7ff706e96e

+ 5 - 4
desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

@@ -341,21 +341,22 @@ class SqlAlchemyApi(Api):
     assist = Assist(inspector, engine, backticks=self.backticks)
     response = {'status': -1}
 
+    if database is not None:
+      database = self._fix_phoenix_empty_database(database)
+
     if operation == 'functions':
       response['functions'] = []
     elif operation == 'function':
       response['function'] = {}
     elif database is None:
-      response['databases'] = [db or 'NULL' for db in assist.get_databases()]
+      response['databases'] = [db or ' ' for db in assist.get_databases()]
     elif table is None:
       tables_meta = []
-      database = self._fix_phoenix_empty_database(database)
       for t in assist.get_tables(database):
         t = self._fix_bigquery_db_prefixes(t)
         tables_meta.append({'name': t, 'type': 'Table', 'comment': ''})
       response['tables_meta'] = tables_meta
     elif column is None:
-      database = self._fix_phoenix_empty_database(database)
       columns = assist.get_columns(database, table)
 
       response['columns'] = [col['name'] for col in columns]
@@ -433,7 +434,7 @@ class SqlAlchemyApi(Api):
 
 
   def _fix_phoenix_empty_database(self, database):
-    return None if self.options['url'].startswith('phoenix://') and database == 'NULL' else database
+    return '' if self.options['url'].startswith('phoenix://') and database == ' ' else database
 
 
   def _fix_bigquery_db_prefixes(self, table_or_column):

+ 1 - 1
desktop/libs/notebook/src/notebook/connectors/sql_alchemy_tests.py

@@ -336,7 +336,7 @@ class TestAutocomplete(object):
 
           data = SqlAlchemyApi(self.user, interpreter).autocomplete(snippet)
 
-          assert_equal(data['databases'], ['SYSTEM', 'NULL'])
+          assert_equal(data['databases'], ['SYSTEM', ' '])
 
   def test_columns_with_null_type(self):
     interpreter = {