Explorar o código

HUE-2032 [beeswax] Order by autocomplete should propose columns

Fixed order by autocomplete
Enrico Berti %!s(int64=11) %!d(string=hai) anos
pai
achega
f698a29712

+ 3 - 3
apps/beeswax/src/beeswax/templates/execute.mako

@@ -1441,7 +1441,7 @@ $(document).ready(function () {
         else {
           CodeMirror.possibleTable = false;
           CodeMirror.tableFieldMagic = false;
-          if ((_before.toUpperCase().indexOf(" FROM ") > -1 || _before.toUpperCase().indexOf(" TABLE ") > -1 || _before.toUpperCase().indexOf(" STATS ") > -1) && _before.toUpperCase().indexOf(" ON ") == -1 && _before.toUpperCase().indexOf(" WHERE ") == -1 ||
+          if ((_before.toUpperCase().indexOf(" FROM ") > -1 || _before.toUpperCase().indexOf(" TABLE ") > -1 || _before.toUpperCase().indexOf(" STATS ") > -1) && _before.toUpperCase().indexOf(" ON ") == -1 && _before.toUpperCase().indexOf(" ORDER BY ") == -1 && _before.toUpperCase().indexOf(" WHERE ") == -1 ||
               _before.toUpperCase().indexOf("REFRESH") > -1 || _before.toUpperCase().indexOf("METADATA") > -1 || _before.toUpperCase().indexOf("DESCRIBE") > -1) {
             CodeMirror.possibleTable = true;
           }
@@ -1456,7 +1456,7 @@ $(document).ready(function () {
             }
           }
           else {
-            if (_before.toUpperCase().indexOf("WHERE ") > -1 && !CodeMirror.fromDot && _before.toUpperCase().match(/ ON| LIMIT| GROUP| SORT/) == null) {
+            if ((_before.toUpperCase().indexOf("WHERE ") > -1 || _before.toUpperCase().indexOf("ORDER BY ") > -1) && !CodeMirror.fromDot && _before.toUpperCase().match(/ ON| LIMIT| GROUP| SORT/) == null) {
               fieldsAutocomplete(cm);
             }
             else {
@@ -1474,7 +1474,7 @@ $(document).ready(function () {
       var _value = getStatementAtCursor().statement;
       var _from = _value.toUpperCase().indexOf("FROM");
       if (_from > -1) {
-        var _match = _value.toUpperCase().substring(_from).match(/ ON| LIMIT| WHERE| GROUP| SORT|;/);
+        var _match = _value.toUpperCase().substring(_from).match(/ ON| LIMIT| WHERE| GROUP| SORT| ORDER BY|;/);
         var _to = _value.length;
         if (_match) {
           _to = _match.index;

+ 1 - 1
apps/beeswax/static/js/autocomplete.utils.js

@@ -47,7 +47,7 @@ function hac_getTableAliases(textScanned) {
   var _val = textScanned.split("\n").join(" ");
   var _from = _val.toUpperCase().indexOf("FROM ");
   if (_from > -1) {
-    var _match = _val.toUpperCase().substring(_from).match(/ ON| LIMIT| WHERE| GROUP| SORT|;/);
+    var _match = _val.toUpperCase().substring(_from).match(/ ON| LIMIT| WHERE| GROUP| SORT| ORDER BY|;/);
     var _to = _val.length;
     if (_match) {
       _to = _match.index;