HHH-8301 - SQLServer2005LimitHandler skips column alias generation
This commit is contained in:
parent
f2d435ddc1
commit
6a71cbb991
|
@ -186,8 +186,10 @@ public class SQLServer2005LimitHandler extends AbstractLimitHandler {
|
||||||
// Inserting alias. It is unlikely that we would have to add alias, but just in case.
|
// Inserting alias. It is unlikely that we would have to add alias, but just in case.
|
||||||
alias = StringHelper.generateAlias( "page", unique );
|
alias = StringHelper.generateAlias( "page", unique );
|
||||||
sb.insert( nextComa, " as " + alias );
|
sb.insert( nextComa, " as " + alias );
|
||||||
|
int aliasExprLength = ( " as " + alias ).length();
|
||||||
++unique;
|
++unique;
|
||||||
nextComa += ( " as " + alias ).length();
|
nextComa += aliasExprLength;
|
||||||
|
endPos += aliasExprLength;
|
||||||
}
|
}
|
||||||
aliases.add( alias );
|
aliases.add( alias );
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,19 @@ public class SQLServer2005DialectTestCase extends BaseUnitTestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-8301")
|
||||||
|
public void testGetLimitStringAliasGeneration() {
|
||||||
|
final String notAliasedSQL = "select column1, column2, column3, column4 from table1";
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"WITH query AS (SELECT inner_query.*, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __hibernate_row_nr__ FROM ( " +
|
||||||
|
"select column1 as page0_, column2 as page1_, column3 as page2_, column4 as page3_ from table1 ) inner_query ) " +
|
||||||
|
"SELECT page0_, page1_, page2_, page3_ FROM query WHERE __hibernate_row_nr__ >= ? AND __hibernate_row_nr__ < ?",
|
||||||
|
dialect.buildLimitHandler( notAliasedSQL, toRowSelection( 3, 5 ) ).getProcessedSql()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-7019")
|
@TestForIssue(jiraKey = "HHH-7019")
|
||||||
public void testGetLimitStringWithSubselect() {
|
public void testGetLimitStringWithSubselect() {
|
||||||
|
|
Loading…
Reference in New Issue