Skip to content

Commit c4b0aac

Browse files
NH-4061 - test case for pointless take causing failures with Oracle dialect.
1 parent bbcdbc5 commit c4b0aac

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/NHibernate.Test/Linq/MiscellaneousTextFixture.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Linq;
33
using System.Linq.Expressions;
4+
using NHibernate.Dialect;
45
using NHibernate.Linq;
56
using NHibernate.DomainModel.Northwind.Entities;
67
using NUnit.Framework;
@@ -92,8 +93,8 @@ where p.ProductId > 1
9293
orderby p.ProductId
9394
select p;
9495

95-
// ToList required otherwise the First call alters the paging and test something else than paging three pages.
96-
// (And Skip().Take().First() causes a bug with Oracle.)
96+
// ToList required otherwise the First call alters the paging and test something else than paging three pages,
97+
// contrary o the test above description.
9798
var page2 = q.Skip(5).Take(5).ToList();
9899
var page3 = q.Skip(10).Take(5).ToList();
99100
var page4 = q.Skip(15).Take(5).ToList();
@@ -107,7 +108,30 @@ orderby p.ProductId
107108
Assert.AreNotEqual(firstResultOnPage2.ProductId, firstResultOnPage4.ProductId);
108109
}
109110

110-
[Test]
111+
[Category("Paging")]
112+
[Test(Description = "NH-4061 - This sample uses a where clause and the Skip and Take operators to select " +
113+
"the second, third and fourth pages of products, but then add a First causing the Take to be pointless.")]
114+
public void TriplePageSelectionWithFirst()
115+
{
116+
if (Dialect is Oracle8iDialect)
117+
Assert.Ignore("Not fixed: NH-4061 - Pointless Take calls screw Oracle dialect paging.");
118+
119+
var q =
120+
from p in db.Products
121+
where p.ProductId > 1
122+
orderby p.ProductId
123+
select p;
124+
125+
var firstResultOnPage2 = q.Skip(5).Take(5).First();
126+
var firstResultOnPage3 = q.Skip(10).Take(5).First();
127+
var firstResultOnPage4 = q.Skip(15).Take(5).First();
128+
129+
Assert.AreNotEqual(firstResultOnPage2.ProductId, firstResultOnPage3.ProductId);
130+
Assert.AreNotEqual(firstResultOnPage3.ProductId, firstResultOnPage4.ProductId);
131+
Assert.AreNotEqual(firstResultOnPage2.ProductId, firstResultOnPage4.ProductId);
132+
}
133+
134+
[Test]
111135
public void SelectFromObject()
112136
{
113137
using (var s = OpenSession())

0 commit comments

Comments
 (0)