DATAJPA-1696 - Undo reluctant parsing introduced with DATAJPA-1679.
This commit is contained in:
@@ -104,7 +104,7 @@ public abstract class QueryUtils {
|
||||
|
||||
private static final Pattern ALIAS_MATCH;
|
||||
private static final Pattern COUNT_MATCH;
|
||||
private static final Pattern PROJECTION_CLAUSE = Pattern.compile("select\\s+(?:distinct\\s+)?(.+?)\\s+from", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern PROJECTION_CLAUSE = Pattern.compile("select\\s+(?:distinct\\s+)?(.+)\\s+from", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private static final Pattern NO_DIGITS = Pattern.compile("\\D+");
|
||||
|
||||
|
||||
@@ -495,9 +495,18 @@ public class QueryUtilsUnitTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test // DATAJPA-1679
|
||||
@Test // DATAJPA-1696
|
||||
public void findProjectionClauseWithSubselect() {
|
||||
assertThat(QueryUtils.getProjection("select * from (select x from y)")).isEqualTo("*");
|
||||
|
||||
// This is not a required behavior, in fact the opposite is,
|
||||
// but it documents a current limitation.
|
||||
// to fix this without breaking findProjectionClauseWithIncludedFrom we need a more sophisticated parser.
|
||||
assertThat(QueryUtils.getProjection("select * from (select x from y)")).isNotEqualTo("*");
|
||||
}
|
||||
|
||||
@Test // DATAJPA-1696
|
||||
public void findProjectionClauseWithIncludedFrom() {
|
||||
assertThat(QueryUtils.getProjection("select x, frommage, y from t")).isEqualTo("x, frommage, y");
|
||||
}
|
||||
|
||||
private static void assertCountQuery(String originalQuery, String countQuery) {
|
||||
|
||||
Reference in New Issue
Block a user