From 6e433d5f85b55b5086488c9b01972ae039eb8d07 Mon Sep 17 00:00:00 2001 From: Hardy Ferentschik Date: Fri, 25 Nov 2011 17:24:44 +0100 Subject: [PATCH] HHH-6849 Fixing assert in SQLServer2005DialectTestCase#testGetLimitString since order of column has changes. Also got rif of additional unnecessary whitespace --- .../main/java/org/hibernate/dialect/SQLServer2005Dialect.java | 2 +- .../org/hibernate/dialect/SQLServer2005DialectTestCase.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2005Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2005Dialect.java index 5a91d4fc07..70972281f4 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2005Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServer2005Dialect.java @@ -194,6 +194,6 @@ public class SQLServer2005Dialect extends SQLServerDialect { int selectEndIndex = sql.indexOf( FROM ); // Insert after the select statement the row_number() function: - sql.insert( selectEndIndex, ", ROW_NUMBER() OVER (" + orderby + ") as __hibernate_row_nr__ " ); + sql.insert( selectEndIndex - 1, ", ROW_NUMBER() OVER (" + orderby + ") as __hibernate_row_nr__" ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/SQLServer2005DialectTestCase.java b/hibernate-core/src/test/java/org/hibernate/dialect/SQLServer2005DialectTestCase.java index 816a4d099e..9f9dbe98c5 100644 --- a/hibernate-core/src/test/java/org/hibernate/dialect/SQLServer2005DialectTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/dialect/SQLServer2005DialectTestCase.java @@ -64,6 +64,6 @@ public class SQLServer2005DialectTestCase extends BaseUnitTestCase { String input = "select distinct f1 as f53245 from table849752 order by f234, f67 desc"; Dialect sqlDialect = new SQLServer2005Dialect(); - assertEquals( "with query as (select row_number() over (order by f234, f67 desc) as __hibernate_row_nr__, f1 as f53245 from table849752 group by f1) select * from query where __hibernate_row_nr__ >= ? and __hibernate_row_nr__ < ?", sqlDialect.getLimitString(input, 10, 15).toLowerCase() ); + assertEquals( "with query as (select f1 as f53245, row_number() over (order by f234, f67 desc) as __hibernate_row_nr__ from table849752 group by f1) select * from query where __hibernate_row_nr__ >= ? and __hibernate_row_nr__ < ?", sqlDialect.getLimitString(input, 10, 15).toLowerCase() ); } }