浏览代码

[core] Fix autocomplete issue with started entry of 'from' in select statement

Johan Ahlen 10 年之前
父节点
当前提交
80059eb

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

@@ -166,9 +166,10 @@ Autocompleter.prototype.autocomplete = function(beforeCursor, afterCursor, callb
         } else {
           fromKeyword = "from";
         }
-        if (!beforeCursor.match(/\*\s*$/)) {
+        if (beforeCursor.match(/select\s*$/i)) {
           fromKeyword = "? " + fromKeyword;
-        } else if (!beforeCursor.match(/\s+$/)) {
+        }
+        if (!beforeCursor.match(/(\s+|f|fr|fro|from)$/)) {
           fromKeyword = " " + fromKeyword;
         }
         fromKeyword += " ";

+ 2 - 3
desktop/core/src/desktop/static/desktop/spec/autocompleteSpec.js

@@ -126,8 +126,7 @@ describe("autocomplete.js", function() {
       });
     });
 
-    // TODO: Fix me
-    xit("should suggest table names with started FROM", function() {
+    it("should suggest table names with started FROM", function() {
       assertAutoComplete({
         serverResponses: {
           "http://baseUrl/testDb" : {
@@ -136,7 +135,7 @@ describe("autocomplete.js", function() {
         },
         beforeCursor: "SELECT * fr",
         afterCursor: "",
-        expectedSuggestions: [" FROM testTable1", " FROM testTable2"]
+        expectedSuggestions: ["FROM testTable1", "FROM testTable2"]
       });
     });