Browse Source

HUE-7726 [editor] Prevent statement parser error on '-' and '/'

Johan Ahlen 8 years ago
parent
commit
36977b7

+ 3 - 2
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sqlStatementsParser.jison

@@ -54,13 +54,14 @@
                                                                         };
                                                                         return 'PART_OF_STATEMENT';
                                                                       }
-[-][^;-]                                                              { return 'PART_OF_STATEMENT'; }
-[/][^;*]                                                              { return 'PART_OF_STATEMENT'; }
+[-][^;-]?                                                             { return 'PART_OF_STATEMENT'; }
+[/][^;*]?                                                             { return 'PART_OF_STATEMENT'; }
 
 ';'                                                                   { return ';'; }
 
 <<EOF>>                                                               { return 'EOF'; }
 
+.                                                                     { /* To prevent console logging of unknown chars */ }
 /lex
 
 %start SqlStatementsParser

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

@@ -60,6 +60,20 @@
       }]);
     });
 
+    it('should handle "-" correctly', function () {
+      testParser('-', [{
+        statement: '-',
+        location: { first_line: 1, first_column: 0, last_line: 1, last_column: 1 }
+      }]);
+    });
+
+    it('should handle "/" correctly', function () {
+      testParser('/', [{
+        statement: '/',
+        location: { first_line: 1, first_column: 0, last_line: 1, last_column: 1 }
+      }]);
+    });
+
     it('should split ";   \\n;   \\r\\n;" correctly', function () {
       testParser(';   \n;   \r\n;', [{
         statement: ';',

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlStatementsParser.js


Some files were not shown because too many files changed in this diff