Commit 02f928b918c681d09f95cc7afa9d2db5ef6c0489

Authored by zbeacon
Committed by Andrew Shvayka
1 parent 5cee3ba9

Fix for OR operation in complex filter.

... ... @@ -329,10 +329,10 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository {
329 329 String entityFieldsQuery = EntityKeyMapping.buildQuery(ctx, entityFieldsFilters, entityFilter.getType());
330 330 String result = permissionQuery;
331 331 if (!entityFilterQuery.isEmpty()) {
332   - result += " and " + entityFilterQuery;
  332 + result += " and (" + entityFilterQuery + ")";
333 333 }
334 334 if (!entityFieldsQuery.isEmpty()) {
335   - result += " and " + entityFieldsQuery;
  335 + result += " and (" + entityFieldsQuery + ")";
336 336 }
337 337 return result;
338 338 }
... ...
... ... @@ -481,13 +481,13 @@ public class EntityKeyMapping {
481 481 stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '%%')", operationField, paramName, operationField, paramName);
482 482 break;
483 483 case CONTAINS:
484   - if (value.length()>1) {
  484 + if (value.length()>0) {
485 485 value = "%" + value + "%";
486 486 }
487 487 stringOperationQuery = String.format("%s like :%s) or (%s is null and :%s = '')", operationField, paramName, operationField, paramName);
488 488 break;
489 489 case NOT_CONTAINS:
490   - if (value.length()>1) {
  490 + if (value.length()>0) {
491 491 value = "%" + value + "%";
492 492 }
493 493 stringOperationQuery = String.format("%s not like :%s) or (%s is null and :%s != '')", operationField, paramName, operationField, paramName);
... ...