Skip to content

Commit c4174f9

Browse files
Merge 5.3.10
2 parents ae69a06 + 2452db8 commit c4174f9

35 files changed

+983
-92
lines changed

releasenotes.txt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
Build 5.3.9
1+
Build 5.3.10
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.3.10
5+
6+
11 issues were resolved in this release.
7+
8+
** Bug
9+
10+
* #2891 Fix nullable entity comparison with null and implicit/cross joins
11+
* #2885 Do not serialize unnecessary members in SessionFactory
12+
* #2882 Fix ArgumentNullException when provider is unable to open a connection
13+
* #2871 If DbTransaction.Dispose throws an exception, the AdoTransaction is left in an inconsistent state
14+
* #2860 Null reference when calling Trim() on interpolated string containing null property
15+
* #2858 Casting to object and back to interface in Subquery causes incorrect SQL
16+
* #2856 Distinct on Composite User Type property fails
17+
* #2855 Error log from ReflectHelper.TypeFromAssembly() on Linq query
18+
* #2611 One-to-zero-or-one relation not returning data when checking for null
19+
* #1962 Failing Linq query on element index
20+
21+
** Task
22+
23+
* #2915 Release 5.3.10
24+
25+
Build 5.3.9
226
=============================
327

428
Release notes - NHibernate - Version 5.3.9

src/NHibernate.DomainModel/Northwind/Entities/Animal.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ public class Animal
1616
public virtual Animal FatherOrMother => Father ?? Mother;
1717
}
1818

19-
public abstract class Reptile : Animal
19+
public interface IReptile
20+
{
21+
EnumStoredAsString Enum1 { get; }
22+
}
23+
24+
public abstract class Reptile : Animal, IReptile
2025
{
2126
public virtual double BodyTemperature { get; set; }
2227

src/NHibernate.Test/Associations/OneToOneFixture.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using NHibernate.Cfg.MappingSchema;
44
using NHibernate.Mapping.ByCode;
55
using NHibernate.Test.Associations.OneToOneFixtureEntities;
6+
using NHibernate.Util;
67
using NUnit.Framework;
78

89
namespace NHibernate.Test.Associations
@@ -127,19 +128,22 @@ public void OneToOneCompositeQueryOverCompareWithJoinById()
127128
Assert.That(loadedEntity, Is.Not.Null);
128129
}
129130
}
130-
131+
131132
//GH-2064
132133
[Test]
133134
public void OneToOneCompositeQuerySelectProjection()
134135
{
136+
using(var logSpy = new LogSpy(typeof(ReflectHelper)))
135137
using (var session = OpenSession())
136138
{
137139
var loadedProjection = session.Query<Parent>().Select(x => new {x.OneToOneComp, x.Key}).FirstOrDefault();
138140

139141
Assert.That(loadedProjection.OneToOneComp, Is.Not.Null);
142+
// GH-2855 Error is logged
143+
Assert.That(logSpy.GetWholeLog(), Is.Empty);
140144
}
141145
}
142-
146+
143147
//NH-3178 (GH-1125)
144148
[Test]
145149
public void OneToOneQueryOverSelectProjection()

src/NHibernate.Test/Async/Associations/OneToOneFixture.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using NHibernate.Cfg.MappingSchema;
1414
using NHibernate.Mapping.ByCode;
1515
using NHibernate.Test.Associations.OneToOneFixtureEntities;
16+
using NHibernate.Util;
1617
using NUnit.Framework;
1718
using NHibernate.Linq;
1819

@@ -139,19 +140,22 @@ public async Task OneToOneCompositeQueryOverCompareWithJoinByIdAsync()
139140
Assert.That(loadedEntity, Is.Not.Null);
140141
}
141142
}
142-
143+
143144
//GH-2064
144145
[Test]
145146
public async Task OneToOneCompositeQuerySelectProjectionAsync()
146147
{
148+
using(var logSpy = new LogSpy(typeof(ReflectHelper)))
147149
using (var session = OpenSession())
148150
{
149151
var loadedProjection = await (session.Query<Parent>().Select(x => new {x.OneToOneComp, x.Key}).FirstOrDefaultAsync());
150152

151153
Assert.That(loadedProjection.OneToOneComp, Is.Not.Null);
154+
// GH-2855 Error is logged
155+
Assert.That(logSpy.GetWholeLog(), Is.Empty);
152156
}
153157
}
154-
158+
155159
//NH-3178 (GH-1125)
156160
[Test]
157161
public async Task OneToOneQueryOverSelectProjectionAsync()

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace NHibernate.Test.Hql
2626
[TestFixture]
2727
public class EntityJoinHqlTestAsync : TestCaseMappingByCode
2828
{
29-
private const string _customEntityName = "CustomEntityName";
29+
private const string _customEntityName = "CustomEntityName.Test";
3030
private EntityWithCompositeId _entityWithCompositeId;
3131
private EntityWithNoAssociation _noAssociation;
3232
private EntityCustomEntityName _entityWithCustomEntityName;
@@ -51,6 +51,46 @@ public async Task CanJoinNotAssociatedEntityAsync()
5151
}
5252
}
5353

54+
[Test]
55+
public async Task CanJoinNotAssociatedEntityFullNameAsync()
56+
{
57+
using (var sqlLog = new SqlLogSpy())
58+
using (var session = OpenSession())
59+
{
60+
EntityComplex entityComplex =
61+
await (session
62+
.CreateQuery("select ex " +
63+
"from EntityWithNoAssociation root " +
64+
$"left join {typeof(EntityComplex).FullName} ex with root.Complex1Id = ex.Id")
65+
.SetMaxResults(1)
66+
.UniqueResultAsync<EntityComplex>());
67+
68+
Assert.That(entityComplex, Is.Not.Null);
69+
Assert.That(NHibernateUtil.IsInitialized(entityComplex), Is.True);
70+
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
71+
}
72+
}
73+
74+
[Test]
75+
public async Task CanJoinNotAssociatedInterfaceFullNameAsync()
76+
{
77+
using (var sqlLog = new SqlLogSpy())
78+
using (var session = OpenSession())
79+
{
80+
EntityComplex entityComplex =
81+
await (session
82+
.CreateQuery("select ex " +
83+
"from EntityWithNoAssociation root " +
84+
$"left join {typeof(IEntityComplex).FullName} ex with root.Complex1Id = ex.Id")
85+
.SetMaxResults(1)
86+
.UniqueResultAsync<EntityComplex>());
87+
88+
Assert.That(entityComplex, Is.Not.Null);
89+
Assert.That(NHibernateUtil.IsInitialized(entityComplex), Is.True);
90+
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
91+
}
92+
}
93+
5494
[Test]
5595
public async Task CanJoinNotAssociatedEntity_OnKeywordAsync()
5696
{
@@ -302,8 +342,18 @@ public async Task NullableEntityProjectionAsync()
302342

303343
var fullList = await (session.Query<NullableOwner>().Select(x => new {x.Name, ManyToOneId = (Guid?) x.ManyToOne.Id}).ToListAsync());
304344
var withValidManyToOneList = await (session.Query<NullableOwner>().Where(x => x.ManyToOne != null).Select(x => new {x.Name, ManyToOneId = (Guid?) x.ManyToOne.Id}).ToListAsync());
345+
var withValidManyToOneList2 = await (session.CreateQuery("from NullableOwner ex where not ex.ManyToOne is null").ListAsync<NullableOwner>());
346+
var withNullManyToOneList = await (session.Query<NullableOwner>().Where(x => x.ManyToOne == null).ToListAsync());
347+
var withNullManyToOneJoinedList =
348+
await ((from x in session.Query<NullableOwner>()
349+
from x2 in session.Query<NullableOwner>()
350+
where x == x2 && x.ManyToOne == null && x.OneToOne.Name == null
351+
select x2).ToListAsync());
305352
Assert.That(fullList.Count, Is.EqualTo(2));
306353
Assert.That(withValidManyToOneList.Count, Is.EqualTo(0));
354+
Assert.That(withValidManyToOneList2.Count, Is.EqualTo(0));
355+
Assert.That(withNullManyToOneList.Count, Is.EqualTo(2));
356+
Assert.That(withNullManyToOneJoinedList.Count, Is.EqualTo(2));
307357
}
308358
}
309359

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,5 +1412,15 @@ public void ReplaceFunctionWithNullArgumentAsync()
14121412
}, Throws.Nothing, "Expected REPLACE(FirstName, LastName, NULL) to be supported");
14131413
Assert.That(results, Is.Not.Null);
14141414
}
1415+
1416+
[Test(Description = "GH-2860")]
1417+
public async Task StringFormatWithTrimAsync()
1418+
{
1419+
var q =
1420+
from e in db.Employees
1421+
select new {Name = $"{e.FirstName} {e.LastName}".Trim(), Phone = e.Address.PhoneNumber};
1422+
var items = await (q.ToListAsync());
1423+
Assert.AreEqual(9, items.Count);
1424+
}
14151425
}
14161426
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ namespace NHibernate.Test.NHSpecificTest.GH1962
1919
public class FixtureAsync : BugTestCase
2020
{
2121
[Test]
22-
[KnownBug("#1962")]
2322
public async Task LinqShouldBeValidAsync()
2423
{
2524
using (var session = OpenSession())
26-
using (session.BeginTransaction())
2725
{
2826
var result =
2927
await (session
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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.Linq;
12+
using NUnit.Framework;
13+
using NHibernate.Linq;
14+
15+
namespace NHibernate.Test.NHSpecificTest.GH2856
16+
{
17+
using System.Threading.Tasks;
18+
[TestFixture]
19+
public class FixtureAsync : BugTestCase
20+
{
21+
protected override void OnSetUp()
22+
{
23+
using (var s = Sfi.OpenSession())
24+
using (var t = s.BeginTransaction())
25+
{
26+
s.Save(new Entity {Name = "Company", Phone = new PhoneNumber("745-555-1234"),});
27+
s.Save(new Entity {Name = "Bob", Phone = new PhoneNumber("745-555-1234", "x123"),});
28+
s.Save(new Entity {Name = "Jane", Phone = new PhoneNumber("745-555-1235"),});
29+
s.Flush();
30+
t.Commit();
31+
}
32+
}
33+
34+
protected override void OnTearDown()
35+
{
36+
using (var s = Sfi.OpenSession())
37+
using (var t = s.BeginTransaction())
38+
{
39+
s.Delete("from Entity");
40+
s.Flush();
41+
t.Commit();
42+
}
43+
}
44+
45+
[Test]
46+
public async Task CanDistinctOnCompositeUserTypeAsync()
47+
{
48+
using (var s = OpenSession())
49+
{
50+
var numbers = await (s.Query<Entity>().Select(x => x.Phone.Ext).Distinct().ToListAsync());
51+
Assert.That(numbers.Count, Is.EqualTo(2));
52+
}
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)