Browse Source

HUE-4733 [editor] Autocompleter doesn't support arithmetic operations in in value list

Johan Ahlen 9 năm trước cách đây
mục cha
commit
93e3b1f

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

@@ -219,10 +219,10 @@ ValueExpression_EDIT
 // ------------------  IN ------------------
 
 ValueExpression
- : ValueExpression 'NOT' 'IN' '(' TableSubQueryInner ')'  -> { types: [ 'BOOLEAN' ] }
- | ValueExpression 'NOT' 'IN' '(' InValueList ')'         -> { types: [ 'BOOLEAN' ] }
- | ValueExpression 'IN' '(' TableSubQueryInner ')'        -> { types: [ 'BOOLEAN' ] }
- | ValueExpression 'IN' '(' InValueList ')'               -> { types: [ 'BOOLEAN' ] }
+ : ValueExpression 'NOT' 'IN' '(' TableSubQueryInner ')'   -> { types: [ 'BOOLEAN' ] }
+ | ValueExpression 'NOT' 'IN' '(' ValueExpressionList ')'  -> { types: [ 'BOOLEAN' ] }
+ | ValueExpression 'IN' '(' TableSubQueryInner ')'         -> { types: [ 'BOOLEAN' ] }
+ | ValueExpression 'IN' '(' ValueExpressionList ')'        -> { types: [ 'BOOLEAN' ] }
  ;
 
 ValueExpression_EDIT
@@ -248,15 +248,15 @@ ValueExpression_EDIT
      }
      $$ = { types: [ 'BOOLEAN' ] };
    }
- | ValueExpression_EDIT 'NOT' 'IN' '(' InValueList RightParenthesisOrError         -> { types: [ 'BOOLEAN' ] }
- | ValueExpression_EDIT 'NOT' 'IN' '(' TableSubQueryInner RightParenthesisOrError  -> { types: [ 'BOOLEAN' ] }
- | ValueExpression_EDIT 'IN' '(' InValueList RightParenthesisOrError               -> { types: [ 'BOOLEAN' ] }
- | ValueExpression_EDIT 'IN' '(' TableSubQueryInner RightParenthesisOrError        -> { types: [ 'BOOLEAN' ] }
+ | ValueExpression_EDIT 'NOT' 'IN' '(' ValueExpressionList RightParenthesisOrError  -> { types: [ 'BOOLEAN' ] }
+ | ValueExpression_EDIT 'NOT' 'IN' '(' TableSubQueryInner RightParenthesisOrError   -> { types: [ 'BOOLEAN' ] }
+ | ValueExpression_EDIT 'IN' '(' ValueExpressionList RightParenthesisOrError        -> { types: [ 'BOOLEAN' ] }
+ | ValueExpression_EDIT 'IN' '(' TableSubQueryInner RightParenthesisOrError         -> { types: [ 'BOOLEAN' ] }
  ;
 
 ValueExpressionInSecondPart_EDIT
  : '(' TableSubQueryInner_EDIT RightParenthesisOrError
- | '(' InValueList_EDIT RightParenthesisOrError         -> { inValueEdit: true }
+ | '(' ValueExpressionList_EDIT RightParenthesisOrError -> { inValueEdit: true }
  | '(' AnyCursor RightParenthesisOrError                -> { inValueEdit: true, cursorAtStart: true }
  ;
 

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js


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

@@ -619,6 +619,40 @@ define([
         });
       });
 
+      it('should handle "SELECT * FROM foo WHERE bar IN (1+1, 2+2);|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM foo WHERE bar IN (1+1, 2+2);',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: false,
+            locations: [
+              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 18 }, identifierChain: [{ name: 'foo' }]},
+              {type: 'column', location: { first_line: 1, last_line: 1, first_column: 25, last_column: 28 }, identifierChain:[{ name: 'foo' }, { name: 'bar'}]}
+            ]
+          }
+        });
+      });
+
+      it('should handle "SELECT * FROM foo WHERE bar IN (id+1-1, id+1-2);|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'SELECT * FROM foo WHERE bar IN (id+1-1, id+1-2);',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: false,
+            locations: [
+              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 18 }, identifierChain: [{ name: 'foo' }]},
+              {type: 'column', location: { first_line: 1, last_line: 1, first_column: 25, last_column: 28 }, identifierChain:[{ name: 'foo' }, { name: 'bar'}]},
+              {type: 'column', location: { first_line: 1, last_line: 1, first_column: 33, last_column: 35 }, identifierChain: [{ name: 'foo' }, { name: 'id'}]},
+              {type: 'column', location: { first_line: 1, last_line: 1, first_column: 41, last_column: 43 }, identifierChain: [{ name: 'foo' }, { name: 'id'}]}
+            ]
+          }
+        });
+      });
+
       it('should handle "SELECT CASE cos(boo.a) > baa.boo \\n' +
         '\\tWHEN baa.b THEN true \\n' +
         '\\tWHEN boo.c THEN false \\n' +

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác