Skip to content

Commit 6cd7b55

Browse files
committed
Merge branch '3.4.x'
2 parents 7231c85 + 488485e commit 6cd7b55

File tree

12 files changed

+131
-14
lines changed

12 files changed

+131
-14
lines changed

releasenotes.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
Build 4.0.0.XXXX
22
=============================
33

4-
** Known BREAKING CHANGES from NH4.0.0.Alpha2 to 4.0.0.Alpha1
4+
** Known BREAKING CHANGES from NH4.0.0.Alpha2 to 4.0.0.GA
55

66
The interface IEnhancedProjection was removed and its methods moved to IProjection.
77
Two other overloads of the GetColumnAliases() methods was removed from IProjection.
88

9+
##### Possible Breaking Changes #####
10+
* [NH-2290] Invalid hql parenthesis expansion in generated sql
11+
Unary minus before parentheses in HQL lost the parentheses when translated
12+
to SQL and therefore the wrong value was returned. This use of unary minus is now
13+
implemented in the mathematically correct way.
14+
915
Build 4.0.0.Alpha2
1016
=============================
1117

@@ -170,6 +176,14 @@ Build 4.0.0.Alpha1
170176

171177
Build 3.4.0.CR1
172178
=============================
179+
** Known BREAKING CHANGES from NH3.3.0.GA to NH3.4.0.GA
180+
181+
##### Possible Breaking Changes #####
182+
* [NH-2290] Invalid hql parenthesis expansion in generated sql
183+
Unary minus before parentheses in HQL lost the parentheses when translated
184+
to SQL and therefore the wrong value was returned. This use of unary minus is now
185+
implemented in the mathematically correct way.
186+
173187

174188
** Sub-task
175189
* [NH-3434] - Need to be sure NH-3428 is resolved in 3.Next.

src/NHibernate.Test/Hql/Ast/HqlFixture.cs

Lines changed: 25 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.Collections;
34
using NHibernate.Criterion;
45
using NHibernate.Engine.Query;
@@ -311,5 +312,29 @@ public void InsertIntoFromSelect_WithSelectClauseParameters()
311312
}
312313
}
313314
}
315+
316+
317+
[Test]
318+
public void UnaryMinusBeforeParenthesesHandledCorrectly()
319+
{
320+
using (ISession s = OpenSession())
321+
using (ITransaction txn = s.BeginTransaction())
322+
{
323+
s.Save(new Animal {Description = "cat1", BodyWeight = 1});
324+
325+
// NH-2290: Unary minus before parentheses wasn't handled correctly (this query returned 0).
326+
int actual = s.CreateQuery("select -(1+1) from Animal as h")
327+
.List<int>().Single();
328+
Assert.That(actual, Is.EqualTo(-2));
329+
330+
// This was the workaround, which of course should still work.
331+
int actualWorkaround = s.CreateQuery("select -1*(1+1) from Animal as h")
332+
.List<int>().Single();
333+
Assert.That(actualWorkaround, Is.EqualTo(-2));
334+
335+
s.CreateQuery("delete from Animal").ExecuteUpdate();
336+
txn.Commit();
337+
}
338+
}
314339
}
315340
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace NHibernate.Test.NHSpecificTest.NH3401
4+
{
5+
class Entity
6+
{
7+
public virtual int Id { get; set; }
8+
public virtual string Name { get; set; }
9+
public virtual bool YesNo { get; set; }
10+
}
11+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System.Linq;
2+
using NHibernate.Linq;
3+
using NUnit.Framework;
4+
5+
namespace NHibernate.Test.NHSpecificTest.NH3401
6+
{
7+
[TestFixture]
8+
public class Fixture : BugTestCase
9+
{
10+
protected override void OnTearDown()
11+
{
12+
using (ISession session = OpenSession())
13+
using (ITransaction transaction = session.BeginTransaction())
14+
{
15+
session.Delete("from System.Object");
16+
17+
session.Flush();
18+
transaction.Commit();
19+
}
20+
}
21+
22+
[Test(Description = "NH-3401")]
23+
[Ignore("Test not implemented - this can be used a base for a proper test case for NH-3401.")]
24+
public void YesNoParameterLengthShouldBe1()
25+
{
26+
// MISSING PART: Asserts for the SQL parameter sizes in the generated commands.
27+
28+
using (ISession session = OpenSession())
29+
using (ITransaction transaction = session.BeginTransaction())
30+
{
31+
var e1 = new Entity {Name = "Bob"};
32+
session.Save(e1);
33+
34+
var e2 = new Entity {Name = "Sally", YesNo = true};
35+
session.Save(e2);
36+
37+
session.Flush();
38+
transaction.Commit();
39+
}
40+
41+
42+
using (ISession session = OpenSession())
43+
using (session.BeginTransaction())
44+
{
45+
var result = from e in session.Query<Entity>()
46+
where e.YesNo
47+
select e;
48+
49+
Assert.AreEqual(1, result.ToList().Count);
50+
}
51+
}
52+
}
53+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH3401">
3+
4+
<class name="Entity">
5+
<id name="Id" generator="native" />
6+
<property name="Name" />
7+
<property name="YesNo" type="YesNo" />
8+
</class>
9+
10+
</hibernate-mapping>

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,8 @@
717717
<Compile Include="NHSpecificTest\NH3058\SampleTest.cs" />
718718
<Compile Include="NHSpecificTest\NH1818\DomainClass.cs" />
719719
<Compile Include="NHSpecificTest\NH1818\Fixture1818.cs" />
720+
<Compile Include="NHSpecificTest\NH3401\Entity.cs" />
721+
<Compile Include="NHSpecificTest\NH3401\Fixture.cs" />
720722
<Compile Include="NHSpecificTest\NH1863\Domain.cs" />
721723
<Compile Include="NHSpecificTest\NH1863\Fixture.cs" />
722724
<Compile Include="MappingByCode\ExpliticMappingTests\ClassWithoutNamespaceTests.cs" />
@@ -3062,6 +3064,7 @@
30623064
<EmbeddedResource Include="NHSpecificTest\NH3058\Mappings.hbm.xml" />
30633065
<EmbeddedResource Include="NHSpecificTest\NH2985\Mappings.hbm.xml" />
30643066
<EmbeddedResource Include="NHSpecificTest\NH1818\Mappings.hbm.xml" />
3067+
<EmbeddedResource Include="NHSpecificTest\NH3401\Mappings.hbm.xml" />
30653068
<EmbeddedResource Include="NHSpecificTest\NH2049\Mappings.hbm.xml" />
30663069
<EmbeddedResource Include="NHSpecificTest\NH1863\Mappings.hbm.xml" />
30673070
<EmbeddedResource Include="NHSpecificTest\NH3614\Mappings.hbm.xml" />

src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// $ANTLR 3.5.0.2 Hql.g 2014-08-03 13:46:13
11+
// $ANTLR 3.5.0.2 Hql.g 2014-08-03 19:45:41
1212

1313
// The variable 'variable' is assigned but its value is never used.
1414
#pragma warning disable 219

src/NHibernate/Hql/Ast/ANTLR/Generated/HqlParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// $ANTLR 3.5.0.2 Hql.g 2014-08-03 13:46:13
11+
// $ANTLR 3.5.0.2 Hql.g 2014-08-03 19:45:40
1212

1313
// The variable 'variable' is assigned but its value is never used.
1414
#pragma warning disable 219

src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// $ANTLR 3.5.0.2 HqlSqlWalker.g 2014-08-03 13:46:14
11+
// $ANTLR 3.5.0.2 HqlSqlWalker.g 2014-08-03 19:45:42
1212

1313
// The variable 'variable' is assigned but its value is never used.
1414
#pragma warning disable 219

src/NHibernate/Hql/Ast/ANTLR/Generated/SqlGenerator.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// $ANTLR 3.5.0.2 SqlGenerator.g 2014-08-03 13:46:15
11+
// $ANTLR 3.5.0.2 SqlGenerator.g 2014-08-03 19:45:43
1212

1313
// The variable 'variable' is assigned but its value is never used.
1414
#pragma warning disable 219
@@ -5717,7 +5717,7 @@ private TreeRuleReturnScope<IASTNode> constant()
57175717
partial void EnterRule_arithmeticExpr();
57185718
partial void LeaveRule_arithmeticExpr();
57195719
// $ANTLR start "arithmeticExpr"
5720-
// SqlGenerator.g:293:1: arithmeticExpr : ( additiveExpr | bitwiseExpr | multiplicativeExpr | ^( UNARY_MINUS expr ) | caseExpr );
5720+
// SqlGenerator.g:293:1: arithmeticExpr : ( additiveExpr | bitwiseExpr | multiplicativeExpr | ^( UNARY_MINUS nestedExprAfterMinusDiv ) | caseExpr );
57215721
[GrammarRule("arithmeticExpr")]
57225722
private void arithmeticExpr()
57235723
{
@@ -5728,7 +5728,7 @@ private void arithmeticExpr()
57285728
DebugLocation(293, 1);
57295729
try
57305730
{
5731-
// SqlGenerator.g:294:2: ( additiveExpr | bitwiseExpr | multiplicativeExpr | ^( UNARY_MINUS expr ) | caseExpr )
5731+
// SqlGenerator.g:294:2: ( additiveExpr | bitwiseExpr | multiplicativeExpr | ^( UNARY_MINUS nestedExprAfterMinusDiv ) | caseExpr )
57325732
int alt55=5;
57335733
try { DebugEnterDecision(55, false);
57345734
switch (input.LA(1))
@@ -5814,7 +5814,7 @@ private void arithmeticExpr()
58145814
break;
58155815
case 4:
58165816
DebugEnterAlt(4);
5817-
// SqlGenerator.g:298:4: ^( UNARY_MINUS expr )
5817+
// SqlGenerator.g:298:4: ^( UNARY_MINUS nestedExprAfterMinusDiv )
58185818
{
58195819
DebugLocation(298, 4);
58205820
DebugLocation(298, 6);
@@ -5828,8 +5828,8 @@ private void arithmeticExpr()
58285828

58295829
Match(input, TokenTypes.Down, null); if (state.failed) return;
58305830
DebugLocation(298, 32);
5831-
PushFollow(Follow._expr_in_arithmeticExpr1659);
5832-
expr();
5831+
PushFollow(Follow._nestedExprAfterMinusDiv_in_arithmeticExpr1659);
5832+
nestedExprAfterMinusDiv();
58335833
PopFollow();
58345834
if (state.failed) return;
58355835

@@ -8407,7 +8407,7 @@ private static class Follow
84078407
public static readonly BitSet _bitwiseExpr_in_arithmeticExpr1643 = new BitSet(new ulong[]{0x2UL});
84088408
public static readonly BitSet _multiplicativeExpr_in_arithmeticExpr1648 = new BitSet(new ulong[]{0x2UL});
84098409
public static readonly BitSet _UNARY_MINUS_in_arithmeticExpr1655 = new BitSet(new ulong[]{0x4UL});
8410-
public static readonly BitSet _expr_in_arithmeticExpr1659 = new BitSet(new ulong[]{0x8UL});
8410+
public static readonly BitSet _nestedExprAfterMinusDiv_in_arithmeticExpr1659 = new BitSet(new ulong[]{0x8UL});
84118411
public static readonly BitSet _caseExpr_in_arithmeticExpr1665 = new BitSet(new ulong[]{0x2UL});
84128412
public static readonly BitSet _PLUS_in_additiveExpr1677 = new BitSet(new ulong[]{0x4UL});
84138413
public static readonly BitSet _expr_in_additiveExpr1679 = new BitSet(new ulong[]{0x8801003140ED150UL,0x561444C01F814010UL,0x208080UL});

0 commit comments

Comments
 (0)