DATAJPA-938 - Fixed constructor expression detection in QueryUtils.
Slightly loosened our regular expression to detect constructor expressions as previously it didn't match select expressions that contained a distinct clause.
This commit is contained in:
@@ -135,6 +135,7 @@ public abstract class QueryUtils {
|
||||
builder = new StringBuilder();
|
||||
builder.append("select");
|
||||
builder.append("\\s+"); // at least one space separating
|
||||
builder.append("(.*\\s+)?"); // anything in between (e.g. distinct) at least one space separating
|
||||
builder.append("new");
|
||||
builder.append("\\s+"); // at least one space separating
|
||||
builder.append(IDENTIFIER);
|
||||
|
||||
@@ -323,7 +323,15 @@ public class QueryUtilsUnitTests {
|
||||
assertThat(applySorting(query, sort, "c"), endsWith("order by c.dPropertyStartingWithJoinAlias asc"));
|
||||
}
|
||||
|
||||
private void assertCountQuery(String originalQuery, String countQuery) {
|
||||
/**
|
||||
* @see DATAJPA-938
|
||||
*/
|
||||
@Test
|
||||
public void detectsConstructorExpressionInDistinctQuery() {
|
||||
assertThat(hasConstructorExpression("select distinct new Foo() from Bar b"), is(true));
|
||||
}
|
||||
|
||||
private static void assertCountQuery(String originalQuery, String countQuery) {
|
||||
assertThat(createCountQueryFor(originalQuery), is(countQuery));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user