Commit b345214e authored by Tristan Cavelier's avatar Tristan Cavelier

Release 3.31.0

jIO Query fix
parent 7e9921a4
...@@ -6060,9 +6060,9 @@ var arrayExtend = function () { ...@@ -6060,9 +6060,9 @@ var arrayExtend = function () {
if (query.operator === "NOT") { if (query.operator === "NOT") {
return query.query_list[0]; return query.query_list[0];
} }
return {"type": "complex", "operator": "NOT", "query_list": [query]}; return {"type": "complex", "key": "", "operator": "NOT", "query_list": [query]};
}, mkComplexQuery = function (operator, query_list) { }, mkComplexQuery = function (key, operator, query_list) {
var i, query_list2 = []; var i, query_list2 = [];
for (i = 0; i < query_list.length; i += 1) { for (i = 0; i < query_list.length; i += 1) {
if (query_list[i].operator === operator) { if (query_list[i].operator === operator) {
...@@ -6071,17 +6071,10 @@ var arrayExtend = function () { ...@@ -6071,17 +6071,10 @@ var arrayExtend = function () {
query_list2.push(query_list[i]); query_list2.push(query_list[i]);
} }
} }
return {type:"complex",operator:operator,query_list:query_list2}; return {type:"complex",key:key,operator:operator,query_list:query_list2};
}, simpleQuerySetKey = function (query, key) { }, querySetKey = function (query, key) {
var i; if (({simple: 1, complex: 1})[query.type] && !query.key) {
if (query.type === "complex") {
for (i = 0; i < query.query_list.length; ++i) {
simpleQuerySetKey (query.query_list[i],key);
}
return true;
}
if (query.type === "simple" && !query.key) {
query.key = key; query.key = key;
return true; return true;
} }
...@@ -6183,13 +6176,13 @@ case 5: case 8: case 11: case 14: case 16: ...@@ -6183,13 +6176,13 @@ case 5: case 8: case 11: case 14: case 16:
this.$ = $$[$0]; this.$ = $$[$0];
break; break;
case 6: case 6:
this.$ = mkComplexQuery('AND', [$$[$0-1], $$[$0]]); this.$ = mkComplexQuery('', 'AND', [$$[$0-1], $$[$0]]);
break; break;
case 7: case 7:
this.$ = mkComplexQuery('OR', [$$[$0-2], $$[$0]]); this.$ = mkComplexQuery('', 'OR', [$$[$0-2], $$[$0]]);
break; break;
case 9: case 9:
this.$ = mkComplexQuery('AND', [$$[$0-2], $$[$0]]); this.$ = mkComplexQuery('', 'AND', [$$[$0-2], $$[$0]]);
break; break;
case 10: case 10:
this.$ = mkNotQuery($$[$0]); this.$ = mkNotQuery($$[$0]);
...@@ -6198,7 +6191,7 @@ case 12: ...@@ -6198,7 +6191,7 @@ case 12:
this.$ = $$[$0-1]; this.$ = $$[$0-1];
break; break;
case 13: case 13:
simpleQuerySetKey($$[$0], $$[$0-2]); this.$ = $$[$0]; querySetKey($$[$0], $$[$0-2]); this.$ = $$[$0];
break; break;
case 15: case 15:
$$[$0].operator = $$[$0-1] ; this.$ = $$[$0]; $$[$0].operator = $$[$0-1] ; this.$ = $$[$0];
...@@ -7254,6 +7247,8 @@ return new Parser; ...@@ -7254,6 +7247,8 @@ return new Parser;
*/ */
this.operator = spec.operator; this.operator = spec.operator;
this.key = spec.key || this.key;
/** /**
* The sub Query list which are used to query an item. * The sub Query list which are used to query an item.
* *
...@@ -7273,6 +7268,7 @@ return new Parser; ...@@ -7273,6 +7268,7 @@ return new Parser;
ComplexQuery.prototype.operator = "AND"; ComplexQuery.prototype.operator = "AND";
ComplexQuery.prototype.type = "complex"; ComplexQuery.prototype.type = "complex";
ComplexQuery.prototype.key = "";
/** /**
* #crossLink "Query/match:method" * #crossLink "Query/match:method"
...@@ -7289,21 +7285,8 @@ return new Parser; ...@@ -7289,21 +7285,8 @@ return new Parser;
* #crossLink "Query/toString:method" * #crossLink "Query/toString:method"
*/ */
ComplexQuery.prototype.toString = function () { ComplexQuery.prototype.toString = function () {
var str_list = [], this_operator = this.operator; /*global objectToSearchText */
if (this.operator === "NOT") { return objectToSearchText(this.toJSON());
str_list.push("NOT (");
str_list.push(this.query_list[0].toString());
str_list.push(")");
return str_list.join(" ");
}
this.query_list.forEach(function (query) {
str_list.push("(");
str_list.push(query.toString());
str_list.push(")");
str_list.push(this_operator);
});
str_list.length -= 1;
return str_list.join(" ");
}; };
/** /**
...@@ -7313,6 +7296,7 @@ return new Parser; ...@@ -7313,6 +7296,7 @@ return new Parser;
var s = { var s = {
"type": "complex", "type": "complex",
"operator": this.operator, "operator": this.operator,
"key": this.key,
"query_list": [] "query_list": []
}; };
this.query_list.forEach(function (query) { this.query_list.forEach(function (query) {
...@@ -7402,12 +7386,26 @@ return new Parser; ...@@ -7402,12 +7386,26 @@ return new Parser;
}; };
function objectToSearchText(query) { function objectToSearchText(query) {
var str_list = []; var str_list = [], operator = "", query_list = null;
if (query.type === "complex") { if (query.type === "complex") {
query_list = query.query_list || [];
if (query_list.length === 0) {
return "";
}
operator = query.operator;
if (operator === "NOT") {
str_list.push("NOT");
// fallback to AND operator if several queries are given
// i.e. `NOT ( a AND b )`
operator = "AND";
}
if (query.key) {
str_list.push(query.key + ":");
}
str_list.push("("); str_list.push("(");
(query.query_list || []).forEach(function (sub_query) { query_list.forEach(function (sub_query) {
str_list.push(objectToSearchText(sub_query)); str_list.push(objectToSearchText(sub_query));
str_list.push(query.operator); str_list.push(operator);
}); });
str_list.length -= 1; str_list.length -= 1;
str_list.push(")"); str_list.push(")");
...@@ -7584,8 +7582,7 @@ return new Parser; ...@@ -7584,8 +7582,7 @@ return new Parser;
* #crossLink "Query/toString:method" * #crossLink "Query/toString:method"
*/ */
SimpleQuery.prototype.toString = function () { SimpleQuery.prototype.toString = function () {
return (this.key ? this.key + ":" : "") + return objectToSearchText(this.toJSON());
(this.operator ? " " + this.operator : "") + ' "' + this.value + '"';
}; };
/** /**
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{ {
"name": "jio", "name": "jio",
"version": "v3.30.0", "version": "v3.31.0",
"license": "LGPLv3", "license": "LGPLv3",
"author": "Nexedi SA", "author": "Nexedi SA",
"contributors": [ "contributors": [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment