Skip to content

Commit be4e7b2

Browse files
committed
fix: switch off lower(COLUMN_NAME) decoration on String equality check
1 parent f2d4756 commit be4e7b2

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/JpaPredicateBuilder.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,12 @@ protected Predicate addOrNull(Path<?> root, Predicate p) {
105105
* @return
106106
*/
107107
protected Predicate getStringPredicate(Path<String> root, PredicateFilter filter) {
108-
Expression<String> fieldValue;
109-
110108
// list or arrays only for in and not in, between and not between
111109
Predicate arrayValuePredicate = mayBeArrayValuePredicate(root, filter);
112110

113111
if(arrayValuePredicate == null) {
114112
String compareValue = filter.getValue().toString();
113+
Expression<String> fieldValue = root;
115114

116115
if (filter.getCriterias().contains(PredicateFilter.Criteria.IN)) {
117116
CriteriaBuilder.In<Object> in = cb.in(root);
@@ -120,14 +119,18 @@ protected Predicate getStringPredicate(Path<String> root, PredicateFilter filter
120119
if (filter.getCriterias().contains(PredicateFilter.Criteria.NIN)) {
121120
return cb.not(root.in(compareValue));
122121
}
123-
122+
124123
if (filter.getCriterias().contains(PredicateFilter.Criteria.CASE)) {
125124
fieldValue = root;
126125
}
127-
else {
126+
else if (filter.getCriterias().contains(PredicateFilter.Criteria.LOWER)) {
128127
fieldValue = cb.lower(root);
129128
compareValue = compareValue.toLowerCase();
130129
}
130+
else if (filter.getCriterias().contains(PredicateFilter.Criteria.UPPER)) {
131+
fieldValue = cb.upper(root);
132+
compareValue = compareValue.toUpperCase();
133+
}
131134

132135
if (filter.getCriterias().contains(PredicateFilter.Criteria.EQ)) {
133136
return cb.equal(fieldValue, compareValue);

graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/PredicateFilter.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public enum Criteria {
6060
* case sensitive (strings)
6161
*/
6262
CASE,
63+
/**
64+
* uppercase expression match (strings)
65+
*/
66+
UPPER,
67+
/**
68+
* lowercase expression match (strings)
69+
*/
70+
LOWER,
6371
/**
6472
* end of the string matches
6573
* <pre>LOWER(field) LIKE LOWER(SEARCH)</pre> if not set then case

0 commit comments

Comments
 (0)