Skip to content

Commit 6080660

Browse files
authored
Merge branch 'master' into bug-2552
2 parents b229332 + 7f60bc3 commit 6080660

File tree

97 files changed

+2251
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2251
-232
lines changed

releasenotes.txt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1-
Build 5.3.5
1+
Build 5.3.6
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.3.6
5+
6+
12 issues were resolved in this release.
7+
8+
** Bug
9+
10+
* #2659 IQueryable<T> filter by subquery gives "Item with Same Key has already been added"
11+
* #2649 Invalid parameter conversion for enums mapped in sub-classes
12+
* #2646 Invalid generated sql with linq any in select and composite keys
13+
* #2642 Linq expression parser removes required Convert nodes
14+
* #2631 IndexOutOfRange exception with One-to-One mapping
15+
* #2627 Null reference on Merge for detached unsaved entity
16+
* #2626 WHERE IN SELECT uses wrong column
17+
* #2608 Delay entity insert may fail with Merge
18+
* #2544 Recognition error occurs using System.Linq.Queryable.Contains
19+
20+
** Improvement
21+
22+
* #2677 Missing ConfigureAwait in FutureEnumerable.GetEnumerableAsync
23+
* #2656 Make sure dbcommand is disposed
24+
25+
** Task
26+
27+
* #2676 Release 5.3.6
28+
29+
As part of releasing 5.3.6, one missing 5.3.0 possible breaking change has been added, about
30+
Merge no more triggering immediate generation of identifier. See 5.3.0 possible breaking changes.
31+
32+
Build 5.3.5
233
=============================
334

435
Release notes - NHibernate - Version 5.3.5
@@ -121,7 +152,7 @@ Release notes - NHibernate - Version 5.3.0
121152
* `update` and `delete` statements will now take into account any enabled filter on the entities
122153
they update or delete, while previously they were ignoring them. (`insert` statements will also take
123154
them into account, but previously they were failing instead of ignoring enabled filters.)
124-
* ISession.Persist will no more trigger immediate generation of identifier.
155+
* ISession.Persist and ISession.Merge will no more trigger immediate generation of identifier.
125156
* Bags will no more be loaded with "null" entities, they will be filtered out.
126157
* Setting the value of an uninitialized lazy property will no more trigger loading of all the lazy
127158
properties of the entity.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class Animal
1919
public abstract class Reptile : Animal
2020
{
2121
public virtual double BodyTemperature { get; set; }
22+
23+
public virtual EnumStoredAsString Enum1 { get; set; }
2224
}
2325

2426
public class Lizard : Reptile { }

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public virtual DateTime? OrderDate
4747
set { _orderDate = value; }
4848
}
4949

50+
public virtual DateTime RequiredOrderDate { get; set; }
51+
5052
public virtual DateTime? RequiredDate
5153
{
5254
get { return _requiredDate; }
@@ -106,4 +108,4 @@ public virtual void RemoveOrderLine(OrderLine orderLine)
106108
}
107109
}
108110
}
109-
}
111+
}

src/NHibernate.DomainModel/Northwind/Mappings/Animal.hbm.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<joined-subclass name="Reptile">
2020
<key column="Animal"/>
2121
<property name="BodyTemperature"/>
22+
<property name="Enum1" type="NHibernate.DomainModel.Northwind.Entities.EnumStoredAsStringType, NHibernate.DomainModel"
23+
formula="('Unspecified')" insert="false" update="false">
24+
</property>
2225

2326
<joined-subclass name="Lizard">
2427
<key column="Reptile"/>
@@ -39,4 +42,4 @@
3942
</joined-subclass>
4043
</joined-subclass>
4144
</class>
42-
</hibernate-mapping>
45+
</hibernate-mapping>

src/NHibernate.DomainModel/Northwind/Mappings/Order.hbm.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<property name="OrderDate" column="OrderDate" type="DateTime"
1818
access="field.camelcase-underscore"/>
1919

20+
21+
<property name="RequiredOrderDate" formula="OrderDate" insert="false" update="false" />
22+
2023
<property name="RequiredDate" column="RequiredDate" type="DateTime"
2124
access="field.camelcase-underscore"/>
2225

@@ -60,4 +63,4 @@
6063

6164
</class>
6265

63-
</hibernate-mapping>
66+
</hibernate-mapping>

src/NHibernate.Test/Async/CompositeId/CompositeIdFixture.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010

1111
using System;
1212
using System.Collections;
13+
using System.Linq;
1314
using NHibernate.Dialect;
1415
using NUnit.Framework;
16+
using NHibernate.Linq;
1517

1618
namespace NHibernate.Test.CompositeId
1719
{
@@ -296,5 +298,15 @@ public async Task QueryAsync()
296298
await (t.CommitAsync());
297299
s.Close();
298300
}
301+
302+
[Test(Description = "GH-2646")]
303+
public async Task AnyOnCompositeIdAsync()
304+
{
305+
using (var s = OpenSession())
306+
{
307+
await (s.Query<Order>().Where(o => o.LineItems.Any()).ToListAsync());
308+
await (s.Query<Order>().Select(o => o.LineItems.Any()).ToListAsync());
309+
}
310+
}
299311
}
300312
}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ public async Task CanExecuteAnyWithArgumentsAsync()
3535
Assert.IsFalse(result);
3636
}
3737

38+
[Test]
39+
public async Task CanExecuteContainsAsync()
40+
{
41+
var user = await (db.Users.FirstOrDefaultAsync());
42+
var result = db.Users.Contains(user);
43+
Assert.That(result, Is.True);
44+
45+
user = new User("test", DateTime.Now);
46+
result = db.Users.Contains(user);
47+
Assert.That(result, Is.False);
48+
}
49+
3850
[Test]
3951
public async Task CanExecuteCountWithOrderByArgumentsAsync()
4052
{
@@ -163,4 +175,4 @@ public async Task CanSelectPropertiesIntoNestedObjectArraysAsync()
163175
Assert.That(nestedNestedObjectArray[1], Is.EqualTo("ayende"));
164176
}
165177
}
166-
}
178+
}

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,64 @@ public async Task UsingParameterInEvaluatableExpressionAsync()
616616
await (db.Users.Where(x => names.Length == 0 || names.Contains(x.Name)).ToListAsync());
617617
}
618618

619+
[Test]
620+
public async Task UsingParameterWithImplicitOperatorAsync()
621+
{
622+
var id = new GuidImplicitWrapper(new Guid("{356E4A7E-B027-4321-BA40-E2677E6502CF}"));
623+
Assert.That(await (db.Shippers.Where(o => o.Reference == id).ToListAsync()), Has.Count.EqualTo(1));
624+
625+
id = new GuidImplicitWrapper(new Guid("{356E4A7E-B027-4321-BA40-E2677E6502FF}"));
626+
Assert.That(await (db.Shippers.Where(o => o.Reference == id).ToListAsync()), Is.Empty);
627+
628+
await (AssertTotalParametersAsync(
629+
db.Shippers.Where(o => o.Reference == id && id == o.Reference),
630+
1));
631+
}
632+
633+
private struct GuidImplicitWrapper
634+
{
635+
public readonly Guid Id;
636+
637+
public GuidImplicitWrapper(Guid id)
638+
{
639+
Id = id;
640+
}
641+
642+
public static implicit operator Guid(GuidImplicitWrapper idWrapper)
643+
{
644+
return idWrapper.Id;
645+
}
646+
}
647+
648+
[Test]
649+
public async Task UsingParameterWithExplicitOperatorAsync()
650+
{
651+
var id = new GuidExplicitWrapper(new Guid("{356E4A7E-B027-4321-BA40-E2677E6502CF}"));
652+
Assert.That(await (db.Shippers.Where(o => o.Reference == (Guid) id).ToListAsync()), Has.Count.EqualTo(1));
653+
654+
id = new GuidExplicitWrapper(new Guid("{356E4A7E-B027-4321-BA40-E2677E6502FF}"));
655+
Assert.That(await (db.Shippers.Where(o => o.Reference == (Guid) id).ToListAsync()), Is.Empty);
656+
657+
await (AssertTotalParametersAsync(
658+
db.Shippers.Where(o => o.Reference == (Guid) id && (Guid) id == o.Reference),
659+
1));
660+
}
661+
662+
private struct GuidExplicitWrapper
663+
{
664+
public readonly Guid Id;
665+
666+
public GuidExplicitWrapper(Guid id)
667+
{
668+
Id = id;
669+
}
670+
671+
public static explicit operator Guid(GuidExplicitWrapper idWrapper)
672+
{
673+
return idWrapper.Id;
674+
}
675+
}
676+
619677
[Test]
620678
public async Task UsingParameterOnSelectorsAsync()
621679
{

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,27 @@ public async Task ContainsOnPersistedCollectionAsync()
848848
Assert.That(result.SerialNumber, Is.EqualTo("1121"));
849849
}
850850

851+
[Test]
852+
public async Task CanCompareAggregateResultAsync()
853+
{
854+
if (!Dialect.SupportsScalarSubSelects)
855+
{
856+
Assert.Ignore(Dialect.GetType().Name + " does not support scalar sub-queries");
857+
}
858+
859+
await (session.Query<Customer>()
860+
.Select(o => new AggregateDate { Id = o.CustomerId, MaxDate = o.Orders.Max(l => l.RequiredOrderDate)})
861+
.Where(o => o.MaxDate <= DateTime.Today && o.MaxDate >= DateTime.Today)
862+
.ToListAsync());
863+
}
864+
865+
private class AggregateDate
866+
{
867+
public string Id { get; set; }
868+
869+
public DateTime? MaxDate { get; set; }
870+
}
871+
851872
private static List<object[]> CanUseCompareInQueryDataSource()
852873
{
853874
return new List<object[]>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 NUnit.Framework;
12+
13+
namespace NHibernate.Test.NHSpecificTest.GH2608
14+
{
15+
using System.Threading.Tasks;
16+
[TestFixture]
17+
public class FixtureAsync : BugTestCase
18+
{
19+
protected override void OnTearDown()
20+
{
21+
using (var session = OpenSession())
22+
using (var transaction = session.BeginTransaction())
23+
{
24+
session.CreateQuery("delete from PersonalDetails").ExecuteUpdate();
25+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
26+
27+
transaction.Commit();
28+
}
29+
}
30+
31+
[Test]
32+
public async Task MergeBidiPrimaryKeyOneToOneAsync()
33+
{
34+
using (var s = OpenSession())
35+
using (var tx = s.BeginTransaction())
36+
{
37+
var p = new Person { Name = "steve" };
38+
p.Details = new PersonalDetails { SomePersonalDetail = "I have big feet", Person = p };
39+
await (s.MergeAsync(p));
40+
await (tx.CommitAsync());
41+
}
42+
}
43+
44+
[Test]
45+
public async Task PersistBidiPrimaryKeyOneToOneAsync()
46+
{
47+
using (var s = OpenSession())
48+
using (var tx = s.BeginTransaction())
49+
{
50+
var p = new Person { Name = "steve" };
51+
p.Details = new PersonalDetails { SomePersonalDetail = "I have big feet", Person = p };
52+
await (s.PersistAsync(p));
53+
await (tx.CommitAsync());
54+
}
55+
}
56+
}
57+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 NUnit.Framework;
12+
13+
namespace NHibernate.Test.NHSpecificTest.GH2614
14+
{
15+
using System.Threading.Tasks;
16+
[TestFixture]
17+
public class FixtureAsync : BugTestCase
18+
{
19+
protected override void OnSetUp()
20+
{
21+
using (var s = OpenSession())
22+
using (var t = s.BeginTransaction())
23+
{
24+
s.Save(new ConcreteClass1 {Name = "C1"});
25+
s.Save(new ConcreteClass2 {Name = "C2"});
26+
t.Commit();
27+
}
28+
}
29+
30+
protected override void OnTearDown()
31+
{
32+
using (var s = OpenSession())
33+
using (var t = s.BeginTransaction())
34+
{
35+
s.CreateQuery("delete from System.Object").ExecuteUpdate();
36+
t.Commit();
37+
}
38+
}
39+
40+
[Test]
41+
public async Task PolymorphicListReturnsCorrectResultsAsync()
42+
{
43+
using (var s = OpenSession())
44+
using (s.BeginTransaction())
45+
{
46+
var query = s.CreateQuery(
47+
@"SELECT Name FROM NHibernate.Test.NHSpecificTest.GH2614.BaseClass ROOT");
48+
query.SetMaxResults(5);
49+
var list = await (query.ListAsync());
50+
Assert.That(list.Count, Is.EqualTo(2));
51+
}
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)