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