Skip to content

Commit efbe88d

Browse files
committed
Merge branch '3.3.x'
2 parents 5278180 + 690c47a commit efbe88d

File tree

10 files changed

+119
-4
lines changed

10 files changed

+119
-4
lines changed

releasenotes.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,29 @@ Build vNext
2525
* ISession.SaveOrUpdateCopy removed: Use Merge instead
2626
* Oracle: The atan2 and power functions now return double (instead of single) for consistency with other dialects.
2727
* Removed FirebirdDriver. It was the same as FirebirdClientDriver since 3.2, and the latter have been the default since then.
28-
* Removed bunch of unused methods on *Helper classes
28+
* Removed bunch of unused methods on *Helper classes
29+
30+
Build 3.3.3.GA
31+
=============================
32+
33+
BEWARE: In versions prior to 3.3.3.CR1, the handling of the LINQ Take() method
34+
was flawed - no matter where in the query Take() was placed it was
35+
always applied as if it had been placed at the end. 3.3.3 fixes this,
36+
so that Take() now correctly follows the .Net semantics. That is, in
37+
3.3.3, the following queries might now give different results:
38+
39+
session.Query<Foo>.OrderBy(...).Take(5).Where(...);
40+
session.Query<Foo>.Where(...).OrderBy(...).Take(5);
41+
42+
Starting with 3.3.3, the first query will generate a subquery to correctly
43+
apply the row limit before the where-clause.
44+
45+
** Bug
46+
* [NH-2408] - SQL Server pessimistic locking syntax incorrect for union-subclass
47+
* [NH-3109] - Rounding float values in aggregate functions with group by statements (MySQL).
48+
* [NH-3324] - HQL: ArgumentNullException when using LEFT OUTER JOIN and SetMaxResults
49+
* [NH-3408] - System.IndexOutOfRangeException when using Contains on a List<byte[]>
50+
* [NH-3413] - Clearing a list used by Contains causes subsequent queries to fail
2951

3052
Build 3.3.3.CR1
3153
=============================

src/NHibernate.Test/DialectTest/LockHintAppenderFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void SetUp()
1717
_appender = new MsSql2000Dialect.LockHintAppender(new MsSql2000Dialect(), new Dictionary<string, LockMode> { {"person", LockMode.Upgrade} });
1818
}
1919

20-
[Test]
20+
[Test]
2121
public void AppendHintToSingleTableAlias()
2222
{
2323
const string expectedQuery1 = "select * from Person person with (updlock, rowlock)";
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Linq;
2+
using NUnit.Framework;
3+
4+
namespace NHibernate.Test.Linq.ByMethod
5+
{
6+
[TestFixture]
7+
public class GetValueOrDefaultTests : LinqTestCase
8+
{
9+
[Test]
10+
public void CoalesceInWhere()
11+
{
12+
var orders = db.Orders
13+
.Where(x => (x.Freight ?? 100) > 0)
14+
.ToList();
15+
16+
Assert.AreEqual(830, orders.Count);
17+
}
18+
19+
[Test]
20+
public void GetValueOrDefaultInWhere()
21+
{
22+
var orders = db.Orders
23+
.Where(x => x.Freight.GetValueOrDefault(100) > 0)
24+
.ToList();
25+
26+
Assert.AreEqual(830, orders.Count);
27+
}
28+
29+
[Test]
30+
public void GetValueOrDefaultWithSingleArgumentInWhere()
31+
{
32+
var orders = db.Orders
33+
.Where(x => x.Freight.GetValueOrDefault() > 0)
34+
.ToList();
35+
36+
Assert.AreEqual(830, orders.Count);
37+
}
38+
}
39+
}

src/NHibernate.Test/NHSpecificTest/NH3074/Fixture.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ protected override void OnSetUp()
3535
}
3636
}
3737

38-
[Test, Ignore("Not fixed yet")]
38+
[Test]
39+
[Ignore("Fails on at least Oracle and PostgreSQL. See NH-3074 and NH-2408.")]
3940
public void HqlCanSetLockMode()
4041
{
4142
using (var s = OpenSession())

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@
502502
<Compile Include="Linq\ByMethod\CastTests.cs" />
503503
<Compile Include="Linq\ByMethod\GroupByHavingTests.cs" />
504504
<Compile Include="Linq\ByMethod\GroupByTests.cs" />
505+
<Compile Include="Linq\ByMethod\GetValueOrDefaultTests.cs" />
505506
<Compile Include="Linq\CasingTest.cs" />
506507
<Compile Include="Linq\CharComparisonTests.cs" />
507508
<Compile Include="Linq\DateTimeTests.cs" />

src/NHibernate/Linq/Functions/DefaultLinqToHqlGeneratorsRegistry.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public DefaultLinqToHqlGeneratorsRegistry()
2020
RegisterGenerator(new GenericDictionaryContainsKeyRuntimeHqlGenerator());
2121
RegisterGenerator(new ToStringRuntimeMethodHqlGenerator());
2222
RegisterGenerator(new LikeGenerator());
23+
RegisterGenerator(new GetValueOrDefaultGenerator());
2324

2425
RegisterGenerator(new CompareGenerator());
2526
this.Merge(new CompareGenerator());
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Linq.Expressions;
5+
using System.Reflection;
6+
using NHibernate.Hql.Ast;
7+
using NHibernate.Linq.Visitors;
8+
using NHibernate.Util;
9+
10+
namespace NHibernate.Linq.Functions
11+
{
12+
internal class GetValueOrDefaultGenerator : IHqlGeneratorForMethod, IRuntimeMethodHqlGenerator
13+
{
14+
public bool SupportsMethod(MethodInfo method)
15+
{
16+
return method != null && String.Equals(method.Name, "GetValueOrDefault", StringComparison.OrdinalIgnoreCase) && method.IsMethodOf(typeof (Nullable<>));
17+
}
18+
19+
public IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
20+
{
21+
return this;
22+
}
23+
24+
public IEnumerable<MethodInfo> SupportedMethods
25+
{
26+
get { throw new NotSupportedException("This is an runtime method generator"); }
27+
}
28+
29+
public HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
30+
{
31+
return treeBuilder.Coalesce(visitor.Visit(targetObject).AsExpression(), GetRhs(method, arguments, treeBuilder, visitor));
32+
}
33+
34+
private static HqlExpression GetRhs(MethodInfo method, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
35+
{
36+
if (arguments.Count > 0)
37+
return visitor.Visit(arguments[0]).AsExpression();
38+
39+
var returnType = method.ReturnType;
40+
var instance = returnType.IsValueType ? Activator.CreateInstance(returnType) : null;
41+
return treeBuilder.Constant(instance);
42+
}
43+
}
44+
}

src/NHibernate/NHibernate.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@
284284
<Compile Include="Linq\Clauses\NhWithClause.cs" />
285285
<Compile Include="Linq\ExpressionTransformers\RemoveCharToIntConversion.cs" />
286286
<Compile Include="Linq\ExpressionTransformers\RemoveRedundantCast.cs" />
287+
<Compile Include="Linq\Functions\GetValueOrDefaultGenerator.cs" />
287288
<Compile Include="Linq\Functions\MathGenerator.cs" />
288289
<Compile Include="Linq\Functions\DictionaryGenerator.cs" />
289290
<Compile Include="Linq\Functions\EqualsGenerator.cs" />

src/NHibernate/NHibernate.nuspec.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
<description>
1111
NHibernate is a mature, open source object-relational mapper for the .NET framework. It is actively developed, fully featured and used in thousands of successful projects.
1212
</description>
13+
<releaseNotes>
14+
Many bug fixes and some new features. Beware that the processing of LINQ's Take() has been corrected, which may give different results for some queries.
15+
See the full release notes at https://github.com/nhibernate/nhibernate-core/blob/3.3.x/releasenotes.txt.
16+
</releaseNotes>
1317
<language>en-US</language>
1418
<tags>ORM, DataBase, DAL, ObjectRelationalMapping</tags>
1519
<dependencies>

teamcity.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323

2424
<target name="verify-test-results">
2525
<if test="${property::exists('NHibernate.Test.IgnoreFail')}">
26-
<copy file="${teamcity.last.result}" todir="${testresults.dir}" />
26+
<!-- Process the current results first, so that these will be available in build artifacts even
27+
if the last-result files is missing. -->
2728
<property name="teamcity.current.result" value="${testResult::StripTimings(testresults.dir + '/NHibernate.Test.dll-results.xml', 'NHibernate.Test.current-results.xml')}" />
29+
<copy file="${teamcity.last.result}" todir="${testresults.dir}" />
2830
<property name="teamcity.report" value="${testResult::CompareResults(teamcity.current.result, teamcity.last.result)}" />
2931
</if>
3032
</target>

0 commit comments

Comments
 (0)