Skip to content

Commit

Permalink
Use 'lower' for all ignoreCase operations.
Browse files Browse the repository at this point in the history
To avoid developers having to maintain multiples indices, use 'lower' for all ignoreCase operations (JSqlParser, QueryByExample, Querydsl).

Resolves #2420.
  • Loading branch information
gregturn committed Mar 22, 2022
1 parent aa52ffe commit c6d1c95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,20 @@ public static Function getJSqlLower(String column) {
.withName("lower") //
.withParameters(lowerParamExpression);
}

/**
* Generates a upper function call, based on the {@code column}.
*
* @param column the non-empty column to use as param for upper
* @return the generated upper function call
*/
public static Function getJSqlUpper(String column) {

List<Expression> expressions = Collections.singletonList(new Column(column));
ExpressionList upperParamExpression = new ExpressionList(expressions);

return new Function() //
.withName("upper") //
.withParameters(upperParamExpression);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,8 @@ private static javax.persistence.criteria.Order toJpaOrder(Order order, From<?,
Expression<?> expression = toExpressionRecursively(from, property);

if (order.isIgnoreCase() && String.class.equals(expression.getJavaType())) {
Expression<String> lower = cb.lower((Expression<String>) expression);
return order.isAscending() ? cb.asc(lower) : cb.desc(lower);
Expression<String> upper = cb.lower((Expression<String>) expression);
return order.isAscending() ? cb.asc(upper) : cb.desc(upper);
} else {
return order.isAscending() ? cb.asc(expression) : cb.desc(expression);
}
Expand Down

0 comments on commit c6d1c95

Please sign in to comment.