Skip to content

Commit 421d8ff

Browse files
committed
Fix CanSelectConditional test
1 parent 1b65a97 commit 421d8ff

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

src/NHibernate.Test/Async/Linq/SelectionTests.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Linq;
1414
using NHibernate.DomainModel.NHSpecific;
1515
using NHibernate.DomainModel.Northwind.Entities;
16+
using NHibernate.Driver;
1617
using NHibernate.Exceptions;
1718
using NHibernate.Proxy;
1819
using NHibernate.Type;
@@ -277,15 +278,21 @@ public async Task CanSelectWithAnySubQueryAsync()
277278
[Test]
278279
public async Task CanSelectConditionalAsync()
279280
{
280-
using (var sqlLog = new SqlLogSpy())
281+
// SqlServerCeDriver and OdbcDriver have an issue matching the case statements inside select and order by statement,
282+
// when having one or more parameters inside them. Throws with the following error:
283+
// ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
284+
if (!(Sfi.ConnectionProvider.Driver is OdbcDriver) && !(Sfi.ConnectionProvider.Driver is SqlServerCeDriver))
281285
{
282-
var q = await (db.Orders.Where(o => o.Customer.CustomerId == "test")
283-
.Select(o => o.ShippedTo.Contains("test") ? o.ShippedTo : o.Customer.CompanyName)
284-
.OrderBy(o => o)
285-
.Distinct()
286-
.ToListAsync());
286+
using (var sqlLog = new SqlLogSpy())
287+
{
288+
var q = await (db.Orders.Where(o => o.Customer.CustomerId == "test")
289+
.Select(o => o.ShippedTo.Contains("test") ? o.ShippedTo : o.Customer.CompanyName)
290+
.OrderBy(o => o)
291+
.Distinct()
292+
.ToListAsync());
287293

288-
Assert.That(FindAllOccurrences(sqlLog.GetWholeLog(), "case"), Is.EqualTo(2));
294+
Assert.That(FindAllOccurrences(sqlLog.GetWholeLog(), "case"), Is.EqualTo(2));
295+
}
289296
}
290297

291298
using (var sqlLog = new SqlLogSpy())

src/NHibernate.Test/Linq/SelectionTests.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using NHibernate.DomainModel.NHSpecific;
55
using NHibernate.DomainModel.Northwind.Entities;
6+
using NHibernate.Driver;
67
using NHibernate.Exceptions;
78
using NHibernate.Proxy;
89
using NHibernate.Type;
@@ -306,15 +307,21 @@ public void CanSelectWithAggregateSubQuery()
306307
[Test]
307308
public void CanSelectConditional()
308309
{
309-
using (var sqlLog = new SqlLogSpy())
310+
// SqlServerCeDriver and OdbcDriver have an issue matching the case statements inside select and order by statement,
311+
// when having one or more parameters inside them. Throws with the following error:
312+
// ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
313+
if (!(Sfi.ConnectionProvider.Driver is OdbcDriver) && !(Sfi.ConnectionProvider.Driver is SqlServerCeDriver))
310314
{
311-
var q = db.Orders.Where(o => o.Customer.CustomerId == "test")
312-
.Select(o => o.ShippedTo.Contains("test") ? o.ShippedTo : o.Customer.CompanyName)
313-
.OrderBy(o => o)
314-
.Distinct()
315-
.ToList();
315+
using (var sqlLog = new SqlLogSpy())
316+
{
317+
var q = db.Orders.Where(o => o.Customer.CustomerId == "test")
318+
.Select(o => o.ShippedTo.Contains("test") ? o.ShippedTo : o.Customer.CompanyName)
319+
.OrderBy(o => o)
320+
.Distinct()
321+
.ToList();
316322

317-
Assert.That(FindAllOccurrences(sqlLog.GetWholeLog(), "case"), Is.EqualTo(2));
323+
Assert.That(FindAllOccurrences(sqlLog.GetWholeLog(), "case"), Is.EqualTo(2));
324+
}
318325
}
319326

320327
using (var sqlLog = new SqlLogSpy())

0 commit comments

Comments
 (0)