Skip to content

Commit f182962

Browse files
fredericDelaportebahusoid
authored andcommitted
Merge 5.3.9
# Conflicts: # .travis.yml # build-common/NHibernate.props # src/NHibernate.Test/NHibernate.Test.csproj # src/NHibernate/Linq/Visitors/QueryModelVisitor.cs # Adjusted: # .github/workflows/NetCoreTest.yml
2 parents ef597b0 + e5fcd13 commit f182962

37 files changed

+441
-94
lines changed

.github/workflows/NetCoreTests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: .NET Core
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
db:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
include:
11+
- DB: SqlServer2008
12+
CONNECTION_STRING: "Server=localhost;initial catalog=nhibernate;User Id=sa;Password=P@ssw0rd;packet size=4096;"
13+
- DB: PostgreSQL
14+
CONNECTION_STRING: "Host=localhost;Username=nhibernate;Password=nhibernate;Database=nhibernate;Enlist=true;"
15+
- DB: Firebird
16+
CONNECTION_STRING: "DataSource=localhost;Database=nhibernate;User=SYSDBA;Password=nhibernate;charset=utf8;"
17+
- DB: MySQL
18+
CONNECTION_STRING: "Server=localhost;Uid=root;Password=nhibernate;Database=nhibernate;Old Guids=True;"
19+
- DB: SQLite
20+
runs-on: ubuntu-latest
21+
continue-on-error: ${{matrix.ALLOW_FAILURE == true}}
22+
env:
23+
LANG: en-US.UTF-8 #default POSIX locale doesn't support ignore case comparisons
24+
name: ${{matrix.DB}}
25+
26+
steps:
27+
- name: Set up SqlServer
28+
if: matrix.DB == 'SqlServer2008'
29+
run: |
30+
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=P@ssw0rd" -e "MSSQL_PID=Express" -p 1433:1433 -d --name sqlexpress mcr.microsoft.com/mssql/server:2019-latest;
31+
32+
- name: Set up MySQL
33+
if: matrix.DB == 'MySQL'
34+
run: |
35+
sudo service mysql stop
36+
docker run --name mysql -e MYSQL_ROOT_PASSWORD=nhibernate -e MYSQL_USER=nhibernate -e MYSQL_PASSWORD=nhibernate -e MYSQL_DATABASE=nhibernate -p 3306:3306 --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -d mysql:5.7 mysqld --lower_case_table_names=1 --character-set-server=utf8 --collation-server=utf8_general_ci
37+
38+
- name: Set up PostgreSQL
39+
if: matrix.DB == 'PostgreSQL'
40+
run: |
41+
docker run -d -e POSTGRES_USER=nhibernate -e POSTGRES_PASSWORD=nhibernate -e POSTGRES_DB=nhibernate -p 5432:5432 postgres:13
42+
43+
- name: Set up Firebird
44+
if: matrix.DB == 'Firebird'
45+
run: |
46+
docker run --name firebird -e EnableWireCrypt=true -e FIREBIRD_USER=nhibernate -e FIREBIRD_PASSWORD=nhibernate -e ISC_PASSWORD=nhibernate -e FIREBIRD_DATABASE=nhibernate -p 3050:3050 -d jacobalberty/firebird:v3.0
47+
48+
- uses: actions/checkout@v2
49+
- name: Setup .NET
50+
uses: actions/setup-dotnet@v1.8.0
51+
with:
52+
dotnet-version: 2.1.x
53+
54+
- name: Build and Test
55+
run: |
56+
pwsh -noprofile -command "& ./build.ps1 -TaskList Set-Configuration,Test -properties @{'Database' = '${{matrix.DB}}';'ConnectionString'='${{matrix.CONNECTION_STRING}}'}"

.travis.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

releasenotes.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1-
Build 5.3.8
1+
Build 5.3.9
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.3.9
5+
6+
11 issues were resolved in this release.
7+
8+
** Bug
9+
10+
* #2835 Fix ExecuteWorkInIsolation ignores MultiTenancy configuration
11+
* #2811 Remove session finalizer
12+
* #2805 Model not mapped Exception
13+
* #2802 ArgumentException on session Flush
14+
* #2792 Arithmetic operations adding casts to SQLite that cause incorrect results
15+
* #2791 Custom Equality Fails
16+
* #2772 LINQ query returns NULL instead of expected result
17+
18+
** Test
19+
20+
* #2841 Fix possible test failure for SqlServer 2019
21+
* #2814 Fix intermittent Firebird test errors
22+
* #2812 Replace Travis CI with GitHub Actions
23+
24+
** Task
25+
26+
* #2837 Release 5.3.9
27+
28+
Build 5.3.8
229
=============================
330

431
Release notes - NHibernate - Version 5.3.8

src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99

1010

1111
using System;
12+
using System.Linq;
1213
using System.Text.RegularExpressions;
1314
using NHibernate.Cfg.MappingSchema;
1415
using NHibernate.Mapping.ByCode;
1516
using NHibernate.Test.Hql.EntityJoinHqlTestEntities;
1617
using NUnit.Framework;
18+
using NHibernate.Linq;
1719

1820
namespace NHibernate.Test.Hql
1921
{
@@ -287,6 +289,24 @@ public async Task NullableOneToOneFetchQueryIsNotAffected2Async()
287289
}
288290
}
289291

292+
[Test(Description = "GH-2772")]
293+
public async Task NullableEntityProjectionAsync()
294+
{
295+
using (var session = OpenSession())
296+
using (session.BeginTransaction())
297+
{
298+
var nullableOwner1 = new NullableOwner {Name = "1", ManyToOne = await (session.LoadAsync<OneToOneEntity>(Guid.NewGuid()))};
299+
var nullableOwner2 = new NullableOwner {Name = "2"};
300+
await (session.SaveAsync(nullableOwner1));
301+
await (session.SaveAsync(nullableOwner2));
302+
303+
var fullList = await (session.Query<NullableOwner>().Select(x => new {x.Name, ManyToOneId = (Guid?) x.ManyToOne.Id}).ToListAsync());
304+
var withValidManyToOneList = await (session.Query<NullableOwner>().Where(x => x.ManyToOne != null).Select(x => new {x.Name, ManyToOneId = (Guid?) x.ManyToOne.Id}).ToListAsync());
305+
Assert.That(fullList.Count, Is.EqualTo(2));
306+
Assert.That(withValidManyToOneList.Count, Is.EqualTo(0));
307+
}
308+
}
309+
290310
[Test]
291311
public async Task EntityJoinWithEntityComparisonInWithClausShouldNotAddJoinAsync()
292312
{

src/NHibernate.Test/Async/Linq/ByMethod/JoinTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,14 @@ public async Task CanInnerJoinOnSubclassWithBaseTableReferenceInOnClauseAsync()
156156
join o2 in db.Mammals on o.BodyWeight equals o2.BodyWeight
157157
select new { o, o2 }).Take(1).ToListAsync());
158158
}
159+
160+
[Test(Description = "GH-2805")]
161+
public async Task CanJoinOnInterfaceAsync()
162+
{
163+
var result = await (db.IUsers.Join(db.IUsers,
164+
u => u.Id,
165+
iu => iu.Id,
166+
(u, iu) => iu.Name).Take(1).ToListAsync());
167+
}
159168
}
160169
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Reflection;
1515
using System.Text.RegularExpressions;
1616
using NHibernate.Cfg;
17+
using NHibernate.DomainModel.Northwind.Entities;
1718
using NHibernate.Hql.Ast;
1819
using NHibernate.Linq.Functions;
1920
using NHibernate.Linq.Visitors;
@@ -33,6 +34,14 @@ protected override void Configure(NHibernate.Cfg.Configuration configuration)
3334
configuration.LinqToHqlGeneratorsRegistry<MyLinqToHqlGeneratorsRegistry>();
3435
}
3536

37+
[Test]
38+
public async Task CanUseObjectEqualsAsync()
39+
{
40+
var users = await (db.Users.Where(o => ((object) EnumStoredAsString.Medium).Equals(o.NullableEnum1)).ToListAsync());
41+
Assert.That(users.Count, Is.EqualTo(2));
42+
Assert.That(users.All(c => c.NullableEnum1 == EnumStoredAsString.Medium), Is.True);
43+
}
44+
3645
[Test]
3746
public async Task CanUseMyCustomExtensionAsync()
3847
{

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using NHibernate.Hql.Ast.ANTLR;
1717
using NHibernate.Linq;
1818
using NSubstitute;
19+
using NSubstitute.ExceptionExtensions;
1920
using NUnit.Framework;
2021

2122
namespace NHibernate.Test.Linq
@@ -1397,5 +1398,19 @@ from s2 in sup2.DefaultIfEmpty()
13971398
Assert.That(GetTotalOccurrences(sql, "left outer join"), Is.EqualTo(2));
13981399
}
13991400
}
1401+
1402+
[Test]
1403+
public void ReplaceFunctionWithNullArgumentAsync()
1404+
{
1405+
var query = from e in db.Employees
1406+
select e.FirstName.Replace(e.LastName, null);
1407+
List<string> results = null;
1408+
Assert.That(
1409+
async () =>
1410+
{
1411+
results = await (query.ToListAsync());
1412+
}, Throws.Nothing, "Expected REPLACE(FirstName, LastName, NULL) to be supported");
1413+
Assert.That(results, Is.Not.Null);
1414+
}
14001415
}
14011416
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ public async Task UnaryMinusAsync()
3535
Assert.AreEqual(1, await (session.Query<TimesheetEntry>().CountAsync(a => -a.NumberOfHours == -7)));
3636
}
3737

38+
[Test]
39+
public async Task DecimalAddAsync()
40+
{
41+
decimal offset = 5.5m;
42+
decimal test = 10248 + offset;
43+
var result = await (session.Query<Order>().Where(e => offset + e.OrderId == test).ToListAsync());
44+
Assert.That(result, Has.Count.EqualTo(1));
45+
46+
offset = 5.5m;
47+
test = 32.38m + offset;
48+
result = await (session.Query<Order>().Where(e => offset + e.Freight == test).ToListAsync());
49+
Assert.That(result, Has.Count.EqualTo(1));
50+
}
51+
3852
[Test]
3953
public async Task UnaryPlusAsync()
4054
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public async Task CompareFloatingPointParametersAndColumnsAsync()
320320
totalParameters,
321321
sql =>
322322
{
323-
Assert.That(sql, Does.Not.Contain("cast"));
323+
Assert.That(sql, pair.Value == "Decimal" && Dialect.IsDecimalStoredAsFloatingPointNumber ? Does.Contain("cast") : Does.Not.Contain("cast"));
324324
Assert.That(GetTotalOccurrences(sql, $"Type: {pair.Value}"), Is.EqualTo(totalParameters));
325325
}));
326326
}

src/NHibernate.Test/Async/MultiTenancy/DatabaseStrategyNoDbSpecificFixture.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using NHibernate.Dialect;
2020
using NHibernate.Driver;
2121
using NHibernate.Engine;
22+
using NHibernate.Engine.Transaction;
2223
using NHibernate.Linq;
2324
using NHibernate.Mapping.ByCode;
2425
using NHibernate.MultiTenancy;
@@ -28,6 +29,7 @@
2829
namespace NHibernate.Test.MultiTenancy
2930
{
3031
using System.Threading.Tasks;
32+
using System.Threading;
3133
[TestFixture]
3234
public class DatabaseStrategyNoDbSpecificFixtureAsync : TestCaseMappingByCode
3335
{
@@ -160,6 +162,18 @@ public async Task TenantSessionIsSerializableAndCanBeReconnectedAsync()
160162
Assert.That(Sfi.Statistics.SecondLevelCacheHitCount, Is.EqualTo(1));
161163
}
162164

165+
[Test]
166+
public async Task TenantIsolatedWorkOpensTenantConnectionAsync()
167+
{
168+
if (!IsSqlServerDialect)
169+
Assert.Ignore("MSSqlServer specific test");
170+
171+
using (var ses = OpenTenantSession("tenant1"))
172+
{
173+
await (Isolater.DoIsolatedWorkAsync(new TenantIsolatatedWork("tenant1"), ses.GetSessionImplementation(), CancellationToken.None));
174+
}
175+
}
176+
163177
private static string GetTenantId(ISession session)
164178
{
165179
return session.GetSessionImplementation().GetTenantIdentifier();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System.Data.Common;
12+
using System.Data.SqlClient;
13+
using NHibernate.Engine.Transaction;
14+
15+
namespace NHibernate.Test.MultiTenancy
16+
{
17+
using System.Threading.Tasks;
18+
using System.Threading;
19+
public partial class TenantIsolatatedWork : IIsolatedWork
20+
{
21+
22+
public Task DoWorkAsync(DbConnection connection, DbTransaction transaction, CancellationToken cancellationToken)
23+
{
24+
var builder = new SqlConnectionStringBuilder(connection.ConnectionString);
25+
if (builder.ApplicationName != _tenantName)
26+
return Task.FromException<object>(new HibernateException("Invalid tenant connection"));
27+
return Task.CompletedTask;
28+
}
29+
}
30+
}

src/NHibernate.Test/Async/NHSpecificTest/GH1300/Fixture.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ public void InsertWithTooLongValuesShouldThrowAsync()
114114

115115
var sqlEx = ex.InnerException as SqlException;
116116
Assert.That(sqlEx, Is.Not.Null);
117-
Assert.That(sqlEx.Number, Is.EqualTo(8152));
117+
// Error code is different if verbose truncation warning is enabled
118+
// See details: https://www.brentozar.com/archive/2019/03/how-to-fix-the-error-string-or-binary-data-would-be-truncated/
119+
Assert.That(sqlEx.Number, Is.EqualTo(8152).Or.EqualTo(2628));
118120
}
119121
}
120122

src/NHibernate.Test/Hql/EntityJoinHqlTest.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using System.Text.RegularExpressions;
34
using NHibernate.Cfg.MappingSchema;
45
using NHibernate.Mapping.ByCode;
@@ -276,6 +277,24 @@ public void NullableOneToOneFetchQueryIsNotAffected2()
276277
}
277278
}
278279

280+
[Test(Description = "GH-2772")]
281+
public void NullableEntityProjection()
282+
{
283+
using (var session = OpenSession())
284+
using (session.BeginTransaction())
285+
{
286+
var nullableOwner1 = new NullableOwner {Name = "1", ManyToOne = session.Load<OneToOneEntity>(Guid.NewGuid())};
287+
var nullableOwner2 = new NullableOwner {Name = "2"};
288+
session.Save(nullableOwner1);
289+
session.Save(nullableOwner2);
290+
291+
var fullList = session.Query<NullableOwner>().Select(x => new {x.Name, ManyToOneId = (Guid?) x.ManyToOne.Id}).ToList();
292+
var withValidManyToOneList = session.Query<NullableOwner>().Where(x => x.ManyToOne != null).Select(x => new {x.Name, ManyToOneId = (Guid?) x.ManyToOne.Id}).ToList();
293+
Assert.That(fullList.Count, Is.EqualTo(2));
294+
Assert.That(withValidManyToOneList.Count, Is.EqualTo(0));
295+
}
296+
}
297+
279298
[Test]
280299
public void EntityJoinWithEntityComparisonInWithClausShouldNotAddJoin()
281300
{

src/NHibernate.Test/Linq/ByMethod/JoinTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,14 @@ public void CanInnerJoinOnSubclassWithBaseTableReferenceInOnClause()
145145
join o2 in db.Mammals on o.BodyWeight equals o2.BodyWeight
146146
select new { o, o2 }).Take(1).ToList();
147147
}
148+
149+
[Test(Description = "GH-2805")]
150+
public void CanJoinOnInterface()
151+
{
152+
var result = db.IUsers.Join(db.IUsers,
153+
u => u.Id,
154+
iu => iu.Id,
155+
(u, iu) => iu.Name).Take(1).ToList();
156+
}
148157
}
149158
}

0 commit comments

Comments
 (0)