You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs
+80-2Lines changed: 80 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ public void OnlyOffsetLimit()
75
75
vard=newMsSql2005Dialect();
76
76
77
77
SqlStringstr=d.GetLimitString(newSqlString("select distinct c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_ from dbo.Contact c where COALESCE(c.Rating, 0) > 0 order by c.Rating desc , c.Last_Name , c.First_Name"),null,newSqlString("10"));
78
-
Assert.That(str.ToString(),Is.EqualTo("select distinct TOP (10) c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_ from dbo.Contact c where COALESCE(c.Rating, 0) > 0 order by c.Rating desc , c.Last_Name , c.First_Name"));
78
+
Assert.That(str.ToString(),Is.EqualTo("select distinct TOP (10) c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_ from dbo.Contact c where COALESCE(c.Rating, 0) > 0 order by c.Rating desc , c.Last_Name , c.First_Name"));
79
79
}
80
80
81
81
[Test]
@@ -222,7 +222,85 @@ public void GetIfExistsDropConstraintTest_For_Schema_other_than_dbo()
222
222
publicvoidGetLimitStringWithSqlComments()
223
223
{
224
224
vard=newMsSql2005Dialect();
225
-
Assert.Throws<NotSupportedException>(()=>d.GetLimitString(newSqlString(" /* criteria query */ SELECT p from lcdtm"),null,newSqlString("2")));
225
+
varlimitSqlQuery=d.GetLimitString(newSqlString(" /* criteria query */ SELECT p from lcdtm"),null,newSqlString("2"));
226
+
Assert.That(limitSqlQuery,Is.Not.Null);
227
+
Assert.That(limitSqlQuery.ToString(),Is.EqualTo(" /* criteria query */ SELECT TOP (2) p from lcdtm"));
SqlStringstr=d.GetLimitString(newSqlString("select distinct c.Contact_Id as Contact1_19_0_, c.Rating as Rating2_19_0_, c.Last_Name as Last_Name3_19_0, c.First_Name as First_Name4_19_0 from dbo.Contact c where COALESCE(c.Rating, 0) > 0 order by c.Rating desc , c.Last_Name , c.First_Name"),newSqlString("111"),newSqlString("222"));
16
+
Assert.AreEqual(
17
+
"select distinct c.Contact_Id as Contact1_19_0_, c.Rating as Rating2_19_0_, c.Last_Name as Last_Name3_19_0, c.First_Name as First_Name4_19_0 from dbo.Contact c where COALESCE(c.Rating, 0) > 0 order by c.Rating desc , c.Last_Name , c.First_Name OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
18
+
str.ToString());
19
+
20
+
str=d.GetLimitString(newSqlString("SELECT fish.id FROM fish"),newSqlString("111"),newSqlString("222"));
21
+
Assert.AreEqual(
22
+
"SELECT fish.id FROM fish ORDER BY CURRENT_TIMESTAMP OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
23
+
str.ToString());
24
+
25
+
str=d.GetLimitString(newSqlString("SELECT DISTINCT fish_.id FROM fish fish_"),newSqlString("111"),newSqlString("222"));
26
+
Assert.AreEqual(
27
+
"SELECT DISTINCT fish_.id FROM fish fish_ ORDER BY CURRENT_TIMESTAMP OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
28
+
str.ToString());
29
+
30
+
str=d.GetLimitString(newSqlString("SELECT DISTINCT fish_.id as ixx9_ FROM fish fish_"),newSqlString("111"),newSqlString("222"));
31
+
Assert.AreEqual(
32
+
"SELECT DISTINCT fish_.id as ixx9_ FROM fish fish_ ORDER BY CURRENT_TIMESTAMP OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
33
+
str.ToString());
34
+
35
+
str=d.GetLimitString(newSqlString("SELECT * FROM fish ORDER BY name"),newSqlString("111"),newSqlString("222"));
36
+
Assert.AreEqual(
37
+
"SELECT * FROM fish ORDER BY name OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
38
+
str.ToString());
39
+
40
+
str=d.GetLimitString(newSqlString("SELECT fish.id, fish.name FROM fish ORDER BY name DESC"),newSqlString("111"),newSqlString("222"));
41
+
Assert.AreEqual(
42
+
"SELECT fish.id, fish.name FROM fish ORDER BY name DESC OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
43
+
str.ToString());
44
+
45
+
str=d.GetLimitString(newSqlString("SELECT * FROM fish LEFT JOIN (SELECT * FROM meat ORDER BY weight) AS t ORDER BY name DESC"),newSqlString("111"),newSqlString("222"));
46
+
Assert.AreEqual(
47
+
"SELECT * FROM fish LEFT JOIN (SELECT * FROM meat ORDER BY weight) AS t ORDER BY name DESC OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
48
+
str.ToString());
49
+
50
+
str=d.GetLimitString(newSqlString("SELECT *, (SELECT COUNT(1) FROM fowl WHERE fish_id = fish.id) AS some_count FROM fish"),newSqlString("111"),newSqlString("222"));
51
+
Assert.AreEqual(
52
+
"SELECT *, (SELECT COUNT(1) FROM fowl WHERE fish_id = fish.id) AS some_count FROM fish ORDER BY CURRENT_TIMESTAMP OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
53
+
str.ToString());
54
+
55
+
str=d.GetLimitString(newSqlString("SELECT * FROM fish WHERE scales = ",Parameter.Placeholder),newSqlString("111"),newSqlString("222"));
56
+
Assert.AreEqual(
57
+
"SELECT * FROM fish WHERE scales = ? ORDER BY CURRENT_TIMESTAMP OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
58
+
str.ToString());
59
+
60
+
str=d.GetLimitString(newSqlString("SELECT f.Type, COUNT(DISTINCT f.Name) AS Name FROM Fish f GROUP BY f.Type ORDER BY COUNT(DISTINCT f.Name)"),newSqlString("111"),newSqlString("222"));
61
+
Assert.AreEqual(
62
+
"SELECT f.Type, COUNT(DISTINCT f.Name) AS Name FROM Fish f GROUP BY f.Type ORDER BY COUNT(DISTINCT f.Name) OFFSET 111 ROWS FETCH FIRST 222 ROWS ONLY",
63
+
str.ToString());
64
+
}
65
+
66
+
[Test]
67
+
publicvoidOnlyOffsetLimit()
68
+
{
69
+
vard=newMsSql2012Dialect();
70
+
71
+
SqlStringstr=d.GetLimitString(newSqlString("select distinct c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_ from dbo.Contact c where COALESCE(c.Rating, 0) > 0 order by c.Rating desc , c.Last_Name , c.First_Name"),null,newSqlString("10"));
72
+
Assert.That(str.ToString(),Is.EqualTo("select distinct c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_ from dbo.Contact c where COALESCE(c.Rating, 0) > 0 order by c.Rating desc , c.Last_Name , c.First_Name OFFSET 0 ROWS FETCH FIRST 10 ROWS ONLY"));
73
+
}
74
+
75
+
[Test]
76
+
publicvoidGetLimitStringWithSqlComments()
77
+
{
78
+
vard=newMsSql2012Dialect();
79
+
varlimitSqlQuery=d.GetLimitString(newSqlString(" /* criteria query */ SELECT p from lcdtm"),null,newSqlString("2"));
80
+
Assert.That(limitSqlQuery,Is.Not.Null);
81
+
Assert.That(limitSqlQuery.ToString(),Is.EqualTo(" /* criteria query */ SELECT p from lcdtm ORDER BY CURRENT_TIMESTAMP OFFSET 0 ROWS FETCH FIRST 2 ROWS ONLY"));
0 commit comments