HHH-11324 - Added test cases.

(cherry picked from commit db1dfd6908)
(cherry picked from commit 6b928f9379)
This commit is contained in:
Chris Cranford 2016-12-16 12:51:22 -05:00 committed by Gail Badner
parent 9f57935d7f
commit 88a2029a5a
1 changed files with 24 additions and 0 deletions

View File

@ -296,6 +296,30 @@ public class SQLServer2005DialectTestCase extends BaseUnitTestCase {
);
}
@Test
@TestForIssue(jiraKey = "HHH-11324")
public void testGetLimitStringWithSelectClauseNestedQueryUsingParenthesis() {
final String query = "select t1.c1 as col_0_0, (select case when count(t2.c1)>0 then 'ADDED' else 'UNMODIFIED' end from table2 t2 WHERE (t2.c1 in (?))) as col_1_0 from table1 t1 WHERE 1=1 ORDER BY t1.c1 ASC";
assertEquals(
"WITH query AS (SELECT inner_query.*, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __hibernate_row_nr__ FROM ( " +
"select TOP(?) t1.c1 as col_0_0, (select case when count(t2.c1)>0 then 'ADDED' else 'UNMODIFIED' end from table2 t2 WHERE (t2.c1 in (?))) as col_1_0 from table1 t1 WHERE 1=1 ORDER BY t1.c1 ASC ) inner_query ) " +
"SELECT col_0_0, col_1_0 FROM query WHERE __hibernate_row_nr__ >= ? AND __hibernate_row_nr__ < ?",
dialect.getLimitHandler().processSql( query, toRowSelection( 1, 5 ) )
);
}
@Test
@TestForIssue(jiraKey = "HHH-11324")
public void testGetLimitStringWithSelectClauseNestedQueryUsingParenthesisOnlyTop() {
final String query = "select t1.c1 as col_0_0, (select case when count(t2.c1)>0 then 'ADDED' else 'UNMODIFIED' end from table2 t2 WHERE (t2.c1 in (?))) as col_1_0 from table1 t1 WHERE 1=1 ORDER BY t1.c1 ASC";
assertEquals(
"select TOP(?) t1.c1 as col_0_0, (select case when count(t2.c1)>0 then 'ADDED' else 'UNMODIFIED' end from table2 t2 WHERE (t2.c1 in (?))) as col_1_0 from table1 t1 WHERE 1=1 ORDER BY t1.c1 ASC",
dialect.getLimitHandler().processSql( query, toRowSelection( 0, 5 ) )
);
}
@Test
@TestForIssue(jiraKey = "HHH-9635")
public void testAppendLockHintReadPastLocking() {