Browse Source

HUE-4576 [editor] Fix autocompletion before OR in value expressions

Johan Ahlen 9 years ago
parent
commit
4158ab4

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_valueExpression.jison

@@ -369,7 +369,7 @@ ValueExpression_EDIT
    }
  | ValueExpression_EDIT 'OR' ValueExpression
    {
-     addColRefIfExists();
+     addColRefIfExists($3);
      $$ = { types: [ 'BOOLEAN' ] }
    }
  | ValueExpression 'OR' PartialBacktickedOrAnyCursor

+ 2 - 8
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js

@@ -869,9 +869,9 @@ case 901: case 903: case 905: case 907:
      this.$ = { types: [ 'BOOLEAN' ] };
    
 break;
-case 902:
+case 902: case 906:
 
-     addColRefIfExists();
+     addColRefIfExists($$[$0]);
      this.$ = { types: [ 'BOOLEAN' ] }
    
 break;
@@ -880,12 +880,6 @@ case 904: case 908:
      addColRefIfExists($$[$0-2]);
      this.$ = { types: [ 'BOOLEAN' ] }
    
-break;
-case 906:
-
-     addColRefIfExists($$[$0]);
-     this.$ = { types: [ 'BOOLEAN' ] }
-   
 break;
 case 909: case 910:
 

+ 14 - 0
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js

@@ -3698,6 +3698,20 @@ define([
         });
       });
 
+      it('should suggest identifiers for "SELECT 1 = | OR false FROM tableOne boo, tableTwo baa;"', function() {
+        assertAutoComplete({
+          beforeCursor: 'SELECT 1 = ',
+          afterCursor: ' OR false FROM tableOne boo, tableTwo baa;',
+          containsKeywords: ['CASE'],
+          hasLocations: true,
+          expectedResult: {
+            lowerCase: false,
+            suggestFunctions: { types: ['NUMBER'] },
+            suggestIdentifiers: [{ name: 'boo.', type: 'alias'}, { name: 'baa.', type: 'alias'}]
+          }
+        });
+      });
+
       it('should suggest columns for "SELECT * FROM tbl1, tbl2 atbl2, tbl3 WHERE id = atbl2.|"', function() {
         assertAutoComplete({
           beforeCursor: 'SELECT * FROM tbl1, tbl2 atbl2, tbl3 WHERE id = atbl2.',