DATAJPA-798 - Alias detection now also works for JPQL strings containing line breaks.

We tweaked the regular expression to detect query aliases to correctly use the whitespace character class \s instead of a simple space to make sure we don't get fooled by other whitespace characters like tabs and line breaks.
This commit is contained in:
Oliver Gierke
2015-09-14 10:43:26 -04:00
parent fb8f9ae865
commit fda74889de
2 changed files with 12 additions and 4 deletions

View File

@@ -303,6 +303,14 @@ public class QueryUtilsUnitTests {
assertThat(createCountQueryFor("select u from Usèr u"), is("select count(u) from Usèr u"));
}
/**
* @see DATAJPA-798
*/
@Test
public void detectsAliasInQueryContainingLineBreaks() {
assertThat(detectAlias("select \n u \n from \n User \nu"), is("u"));
}
private void assertCountQuery(String originalQuery, String countQuery) {
assertThat(createCountQueryFor(originalQuery), is(countQuery));
}