Commit bba28750 authored by Tristan Cavelier's avatar Tristan Cavelier

erp5storage.js uses '=' operator when its possible

parent 89ba2620
...@@ -256,9 +256,8 @@ jIO.addStorageType("erp5", function (spec, my) { ...@@ -256,9 +256,8 @@ jIO.addStorageType("erp5", function (spec, my) {
*/ */
priv.convertToErp5Query = function (option) { priv.convertToErp5Query = function (option) {
option.query = complex_queries.QueryFactory.create(option.query || ""); option.query = complex_queries.QueryFactory.create(option.query || "");
if (option.wildcard_character === undefined || if (option.wildcard_character !== null &&
(option.wildcard_character !== null && typeof option.wildcard_character !== 'string') {
typeof option.wildcard_character !== 'string')) {
option.wildcard_character = '%'; option.wildcard_character = '%';
} else { } else {
option.wildcard_character = option.wildcard_character || ''; option.wildcard_character = option.wildcard_character || '';
...@@ -266,24 +265,14 @@ jIO.addStorageType("erp5", function (spec, my) { ...@@ -266,24 +265,14 @@ jIO.addStorageType("erp5", function (spec, my) {
option.query.onParseSimpleQuery = function (object) { option.query.onParseSimpleQuery = function (object) {
if (option.wildcard_character.length === 1 && if (option.wildcard_character.length === 1 &&
object.parsed.operator === '=') { object.parsed.operator === '=') {
object.parsed.operator = 'like';
if (option.wildcard_character === '%') { if (option.wildcard_character === '%') {
object.parsed.operator = 'like';
object.parsed.value = object.parsed.value =
object.parsed.value.replace(/_/g, '\\_'); object.parsed.value.replace(/_/g, '\\_');
} else if (option.wildcard_character === '_') { } else if (option.wildcard_character === '_') {
object.parsed.operator = 'like';
object.parsed.value = object.parsed.value =
object.parsed.value.replace(/%/g, '\\%').replace(/_/g, '%'); object.parsed.value.replace(/%/g, '\\%').replace(/_/g, '%');
} else {
object.parsed.value =
object.parsed.value.replace(
/([%_])/g,
'\\$1'
).replace(
new RegExp(complex_queries.stringEscapeRegexpCharacters(
option.wildcard_character
), 'g'),
'%'
);
} }
} }
}; };
......
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