diff --git a/CHANGELOG.md b/CHANGELOG.md index dd9f452faf2cdd522abed1149d7181389bf1e1f3..e79c06624c1929c5b334e694c20b520d42630640 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* [webui#170](https://gitlab.com/caosdb/caosdb-webui/-/issues/170) + Autocompletion for "IS REFERENCED BY" leads to query syntax error + ### Security ### Documentation diff --git a/src/core/js/ext_autocomplete.js b/src/core/js/ext_autocomplete.js index 2f6fa0dde729907f7248bd05367f26633872f39e..932a9466a83f17594894ad389f6535bcd6caffa2 100644 --- a/src/core/js/ext_autocomplete.js +++ b/src/core/js/ext_autocomplete.js @@ -159,7 +159,7 @@ var ext_autocomplete = new function () { var end = origJQElement[0].value.slice(cursorpos); var result = resultsFromServer.map(x => { var x_quoted = x; - if (x.indexOf(" ") > -1) { + if (ext_autocomplete.CQL_WORDS.indexOf(x) == -1 && x.indexOf(" ") > -1) { if(x.indexOf("\"") > -1) { x_quoted = `'${x}'`; } else { diff --git a/test/core/js/modules/ext_autocomplete.js.js b/test/core/js/modules/ext_autocomplete.js.js index 96cab766fb848b74b04677f9b3312b574b9a3844..aaefd228705e12a0c47bf47f1a4e1ce7936d58f6 100644 --- a/test/core/js/modules/ext_autocomplete.js.js +++ b/test/core/js/modules/ext_autocomplete.js.js @@ -88,6 +88,26 @@ QUnit.test("searchPost", async function(assert) { assert.propEqual(result, expected); }); +QUnit.test("searchPost webui#170", async function(assert) { + // https://gitlab.com/caosdb/caosdb-webui/-/issues/170 + // Autocompletion for "IS REFERENCED BY" leads to query syntax error + const resultsFromServer = ["REFERENCED BY"]; + const origJQElement = [{ + selectionEnd: 24, + value: "FIND Event WHICH IS REFE", + }]; + + const expected = [ + { + "html": "REFERENCED BY", + "text": "FIND Event WHICH IS REFERENCED BY" + }, + ]; + + const result = ext_autocomplete.searchPost(resultsFromServer, origJQElement); + assert.propEqual(result, expected); +}); + QUnit.test("class", function(assert) { assert.ok(ext_autocomplete.switch_on_completion , "toggle available"); assert.ok(ext_autocomplete.switch_on_completion() , "toggle runs");