DATAJPA-545 - Fixed regression in discovery of StringQuery parameters.
Special characters like french accents (e.g., abonnés) were not allowed anymore (was in SD JPA 1.2) in named parameter bindings. Adjusted regex in StringQuery to cover a broader list of characters. Original pull request: #93.
This commit is contained in:
committed by
Oliver Gierke
parent
f80af917df
commit
05137e8f77
@@ -165,7 +165,7 @@ class StringQuery {
|
||||
builder.append("(");
|
||||
builder.append("%?(\\?(\\d+))%?"); // position parameter
|
||||
builder.append("|"); // or
|
||||
builder.append("%?(:(\\w+))%?"); // named parameter;
|
||||
builder.append("%?(:([\\p{L}\\w]+))%?"); // named parameter;
|
||||
builder.append(")");
|
||||
builder.append("\\)?"); // optional braces around paramters
|
||||
|
||||
|
||||
@@ -246,6 +246,62 @@ public class StringQueryUnitTests {
|
||||
query.getBindingFor(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-545
|
||||
*/
|
||||
@Test
|
||||
public void detectsInBindingWithSpecialFrenchCharactersInParentheses() {
|
||||
|
||||
StringQuery query = new StringQuery("select * from MyEntity where abonnés in (:abonnés)");
|
||||
|
||||
List<ParameterBinding> bindings = query.getParameterBindings();
|
||||
|
||||
assertThat(bindings, hasSize(1));
|
||||
assertNamedBinding(InParameterBinding.class, "abonnés", bindings.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-545
|
||||
*/
|
||||
@Test
|
||||
public void detectsInBindingWithSpecialCharactersInParentheses() {
|
||||
|
||||
StringQuery query = new StringQuery("select * from MyEntity where øre in (:øre)");
|
||||
|
||||
List<ParameterBinding> bindings = query.getParameterBindings();
|
||||
|
||||
assertThat(bindings, hasSize(1));
|
||||
assertNamedBinding(InParameterBinding.class, "øre", bindings.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-545
|
||||
*/
|
||||
@Test
|
||||
public void detectsInBindingWithSpecialAsianCharactersInParentheses() {
|
||||
|
||||
StringQuery query = new StringQuery("select * from MyEntity where 생일 in (:생일)");
|
||||
|
||||
List<ParameterBinding> bindings = query.getParameterBindings();
|
||||
|
||||
assertThat(bindings, hasSize(1));
|
||||
assertNamedBinding(InParameterBinding.class, "생일", bindings.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-545
|
||||
*/
|
||||
@Test
|
||||
public void detectsInBindingWithSpecialCharactersAndWordCharactersMixedInParentheses() {
|
||||
|
||||
StringQuery query = new StringQuery("select * from MyEntity where foo in (:ab1babc생일233)");
|
||||
|
||||
List<ParameterBinding> bindings = query.getParameterBindings();
|
||||
|
||||
assertThat(bindings, hasSize(1));
|
||||
assertNamedBinding(InParameterBinding.class, "ab1babc생일233", bindings.get(0));
|
||||
}
|
||||
|
||||
private void assertPositionalBinding(Class<? extends ParameterBinding> bindingType, Integer position,
|
||||
ParameterBinding expectedBinding) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user