DATAJPA-1696 - Undo reluctant parsing introduced with DATAJPA-1679.

This commit is contained in:
Jens Schauder
2020-03-12 15:09:32 +01:00
parent 9047fee45d
commit 40d0d54508
2 changed files with 12 additions and 3 deletions

View File

@@ -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+");

View File

@@ -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) {