Skip to content

Commit

Permalink
Fix HHH-11352 - the Pattern at buildShallowIndexPattern where "wordBo…
Browse files Browse the repository at this point in the history
…undary==true" should wrap the pattern properly with '\b'
  • Loading branch information
lsiu authored and Naros committed Dec 22, 2016
1 parent dd9c68a commit 56f7466
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -361,14 +361,15 @@ private static int shallowIndexOfPattern(final StringBuilder sb, final Pattern p
* based on the search pattern that is not enclosed in parenthesis. * based on the search pattern that is not enclosed in parenthesis.
* *
* @param pattern String search pattern. * @param pattern String search pattern.
* @param wordBoundardy whether to apply a word boundary restriction. * @param wordBoundary whether to apply a word boundary restriction.
* @return Compiled {@link Pattern}. * @return Compiled {@link Pattern}.
*/ */
private static Pattern buildShallowIndexPattern(String pattern, boolean wordBoundardy) { private static Pattern buildShallowIndexPattern(String pattern, boolean wordBoundary) {
return Pattern.compile( return Pattern.compile(
"(" + "(" +
( wordBoundardy ? "\\b" : "" ) + ( wordBoundary ? "\\b" : "" ) +
pattern + pattern +
( wordBoundary ? "\\b" : "" ) +
")(?![^\\(|\\[]*(\\)|\\]))", ")(?![^\\(|\\[]*(\\)|\\]))",
Pattern.CASE_INSENSITIVE Pattern.CASE_INSENSITIVE
); );
Expand Down
Expand Up @@ -128,6 +128,16 @@ public void testGetLimitStringAliasGenerationWithAliasesNoAs() {
); );
} }


@Test
@TestForIssue(jiraKey = "HHH-11352")
public void testPagingWithColumnNameStartingWithFrom() {
final String sql = "select column1 c1, from_column c2 from table1";
assertEquals( "WITH query AS (SELECT inner_query.*, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __hibernate_row_nr__ FROM ( " +
"select column1 c1, from_column c2 from table1 ) inner_query ) " +
"SELECT c1, c2 FROM query WHERE __hibernate_row_nr__ >= ? AND __hibernate_row_nr__ < ?",
dialect.getLimitHandler().processSql(sql, toRowSelection(3, 5)));
}

@Test @Test
@TestForIssue(jiraKey = "HHH-7019") @TestForIssue(jiraKey = "HHH-7019")
public void testGetLimitStringWithSubselect() { public void testGetLimitStringWithSubselect() {
Expand Down

0 comments on commit 56f7466

Please sign in to comment.