Browse Source

HUE-6188 [editor] Only convert table locations to complex type when a database reference was found

Johan Ahlen 8 years ago
parent
commit
eb8e600966
1 changed files with 16 additions and 11 deletions
  1. 16 11
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

+ 16 - 11
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3412,6 +3412,17 @@
         });
 
         var AceRange = ace.require('ace/range').Range;
+
+        var lastKnownLocations = [];
+
+        var locationsSub = huePubSub.subscribe('get.active.editor.locations', function () {
+          huePubSub.publish('editor.active.locations', lastKnownLocations);
+        });
+
+        disposeFunctions.push(function () {
+          locationsSub.remove();
+        });
+
         aceSqlWorker.onmessage = function(e) {
           workerIsReady = true;
           if (e.data.ping) {
@@ -3437,16 +3448,6 @@
           }
 
           var lastKnownLocations = { id: $el.attr("id"), type: snippet.type(), defaultDatabase: snippet.database(), locations: e.data.locations };
-          huePubSub.publish('editor.active.locations', lastKnownLocations);
-
-          var locationsSub = huePubSub.subscribe('get.active.editor.locations', function () {
-            huePubSub.publish('editor.active.locations', lastKnownLocations);
-          });
-
-          disposeFunctions.push(function () {
-            locationsSub.remove();
-          });
-
 
           // Clear out old parse locations to prevent them from being shown when there's a syntax error in the statement
           while(activeTokens.length > 0) {
@@ -3459,10 +3460,12 @@
             }
             if ((location.type === 'table' && location.identifierChain.length > 1) || (location.type === 'column' && location.identifierChain.length > 2)) {
               var clonedChain = location.identifierChain.concat();
+              var dbFound = false;
               if (apiHelper.containsDatabase(snippet.type(), clonedChain[0].name)) {
                 clonedChain.shift();
+                dbFound = true;
               }
-              if (clonedChain.length > 1) {
+              if (dbFound && clonedChain.length > 1) {
                 location.type = 'complex';
               }
             }
@@ -3508,6 +3511,8 @@
               }
             }
           });
+
+          huePubSub.publish('editor.active.locations', lastKnownLocations);
         };
 
         var whenWorkerIsReady = function (callback) {