فهرست منبع

HUE-6656 [editor] Fix js error in the statement parser with open backticked identifiers

Johan Ahlen 8 سال پیش
والد
کامیت
0e3ffeffbb

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

@@ -42,7 +42,7 @@
 
 '`'                                                                   { this.begin("backTick"); return 'PART_OF_STATEMENT'; }
 <backTick>[^`]+                                                       { return 'PART_OF_STATEMENT'; }
-<backTick><<EOF>>                                                     { this.popState(); return 'PART_OF_STATEMENT'; }
+<backTick><<EOF>>                                                     { this.popState(); return 'EOF'; }
 <backTick>'`'                                                         { this.popState(); return 'PART_OF_STATEMENT'; }
 
 [^"\/;'`-]+                                                           { return 'PART_OF_STATEMENT'; }

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlStatementsParser.js

@@ -706,7 +706,7 @@ case 17: this.begin("backTick"); return 8;
 break;
 case 18: return 8; 
 break;
-case 19: this.popState(); return 8; 
+case 19: this.popState(); return 5; 
 break;
 case 20: this.popState(); return 8; 
 break;

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

@@ -209,6 +209,27 @@
       }]);
     });
 
+    it('should split "SELECT `   " correctly', function () {
+      testParser('SELECT `   ', [{
+        statement: 'SELECT `   ',
+        location: { first_line: 1, first_column: 0, last_line: 1, last_column: 11 }
+      }]);
+    });
+
+    it('should split "SELECT "   " correctly', function () {
+      testParser('SELECT "   ', [{
+        statement: 'SELECT "   ',
+        location: { first_line: 1, first_column: 0, last_line: 1, last_column: 11 }
+      }]);
+    });
+
+    it('should split "SELECT \'   " correctly', function () {
+      testParser('SELECT \'   ', [{
+        statement: 'SELECT \'   ',
+        location: { first_line: 1, first_column: 0, last_line: 1, last_column: 11 }
+      }]);
+    });
+
     it('should split "SELECT " \\" ;; ", \'"\', \' ;\' from bla; /* \\n\\n"" ; \\n; */ FROM other;" correctly', function () {
       testParser('USE `db;`;\r\nSELECT " \\" ;; ", \'"\', \' ;\' from bla; /* \n\n"" ; \n;  FROM other;*/', [{
         statement: 'USE `db;`;',