Skip to content

Commit 518f2e0

Browse files
committed
Fix CanSelectConditional test
1 parent c88b369 commit 518f2e0

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
@@ -12,6 +12,7 @@
1212
using System.Collections.Generic;
1313
using System.Linq;
1414
using NHibernate.DomainModel.Northwind.Entities;
15+
using NHibernate.Driver;
1516
using NHibernate.Exceptions;
1617
using NHibernate.Proxy;
1718
using NUnit.Framework;
@@ -275,15 +276,21 @@ public async Task CanSelectWithAnySubQueryAsync()
275276
[Test]
276277
public async Task CanSelectConditionalAsync()
277278
{
278-
using (var sqlLog = new SqlLogSpy())
279+
// SqlServerCeDriver and OdbcDriver have an issue matching the case statements inside select and order by statement,
280+
// when having one or more parameters inside them. Throws with the following error:
281+
// ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
282+
if (!(Sfi.ConnectionProvider.Driver is OdbcDriver) && !(Sfi.ConnectionProvider.Driver is SqlServerCeDriver))
279283
{
280-
var q = await (db.Orders.Where(o => o.Customer.CustomerId == "test")
281-
.Select(o => o.ShippedTo.Contains("test") ? o.ShippedTo : o.Customer.CompanyName)
282-
.OrderBy(o => o)
283-
.Distinct()
284-
.ToListAsync());
284+
using (var sqlLog = new SqlLogSpy())
285+
{
286+
var q = await (db.Orders.Where(o => o.Customer.CustomerId == "test")
287+
.Select(o => o.ShippedTo.Contains("test") ? o.ShippedTo : o.Customer.CompanyName)
288+
.OrderBy(o => o)
289+
.Distinct()
290+
.ToListAsync());
285291

286-
Assert.That(FindAllOccurrences(sqlLog.GetWholeLog(), "case"), Is.EqualTo(2));
292+
Assert.That(FindAllOccurrences(sqlLog.GetWholeLog(), "case"), Is.EqualTo(2));
293+
}
287294
}
288295

289296
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
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using NHibernate.DomainModel.Northwind.Entities;
5+
using NHibernate.Driver;
56
using NHibernate.Exceptions;
67
using NHibernate.Proxy;
78
using NUnit.Framework;
@@ -304,15 +305,21 @@ public void CanSelectWithAggregateSubQuery()
304305
[Test]
305306
public void CanSelectConditional()
306307
{
307-
using (var sqlLog = new SqlLogSpy())
308+
// SqlServerCeDriver and OdbcDriver have an issue matching the case statements inside select and order by statement,
309+
// when having one or more parameters inside them. Throws with the following error:
310+
// ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
311+
if (!(Sfi.ConnectionProvider.Driver is OdbcDriver) && !(Sfi.ConnectionProvider.Driver is SqlServerCeDriver))
308312
{
309-
var q = db.Orders.Where(o => o.Customer.CustomerId == "test")
310-
.Select(o => o.ShippedTo.Contains("test") ? o.ShippedTo : o.Customer.CompanyName)
311-
.OrderBy(o => o)
312-
.Distinct()
313-
.ToList();
313+
using (var sqlLog = new SqlLogSpy())
314+
{
315+
var q = db.Orders.Where(o => o.Customer.CustomerId == "test")
316+
.Select(o => o.ShippedTo.Contains("test") ? o.ShippedTo : o.Customer.CompanyName)
317+
.OrderBy(o => o)
318+
.Distinct()
319+
.ToList();
314320

315-
Assert.That(FindAllOccurrences(sqlLog.GetWholeLog(), "case"), Is.EqualTo(2));
321+
Assert.That(FindAllOccurrences(sqlLog.GetWholeLog(), "case"), Is.EqualTo(2));
322+
}
316323
}
317324

318325
using (var sqlLog = new SqlLogSpy())

0 commit comments

Comments
 (0)