Skip to content

Commit 70dffa3

Browse files
authored
Fix mixing implied implicit and left joins in hql (nhibernate#3187)
5.3 specific fix Fixes nhibernate#3185
1 parent 37b5020 commit 70dffa3

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

build-common/NHibernate.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
<PropertyGroup>
55
<NhVersion Condition="'$(NhVersion)' == ''" >5.3</NhVersion>
6-
<VersionPatch Condition="'$(VersionPatch)' == ''">14</VersionPatch>
6+
<VersionPatch Condition="'$(VersionPatch)' == ''">15</VersionPatch>
77
<!-- Clear VersionSuffix for making release and set it to dev for making development builds -->
8-
<VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix>
8+
<VersionSuffix Condition="'$(VersionSuffix)' == ''">dev</VersionSuffix>
99

1010
<VersionPrefix Condition="'$(VersionPrefix)' == ''">$(NhVersion).$(VersionPatch)</VersionPrefix>
1111
<VersionSuffix Condition="'$(VersionSuffix)' != '' AND '$(BuildNumber)' != ''">$(VersionSuffix).$(BuildNumber)</VersionSuffix>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,17 @@ from x2 in session.Query<NullableOwner>()
359359
var withNullOrValidList = await (session.Query<NullableOwner>().Where(x => x.ManyToOne.Id == validManyToOne.Id || x.ManyToOne == null).ToListAsync());
360360
var withNullOrValidList2 = await (session.Query<NullableOwner>().Where(x => x.ManyToOne == null || x.ManyToOne.Id == validManyToOne.Id).ToListAsync());
361361

362+
//GH-3185
363+
var mixImplicitAndLeftJoinList = await (session.Query<NullableOwner>().Where(x => x.ManyToOne.Id == validManyToOne.Id && x.OneToOne == null).ToListAsync());
364+
362365
Assert.That(fullList.Count, Is.EqualTo(2));
363366
Assert.That(withValidManyToOneList.Count, Is.EqualTo(0));
364367
Assert.That(withValidManyToOneList2.Count, Is.EqualTo(0));
365368
Assert.That(withNullManyToOneList.Count, Is.EqualTo(2));
366369
Assert.That(withNullManyToOneJoinedList.Count, Is.EqualTo(2));
367370
Assert.That(withNullOrValidList.Count, Is.EqualTo(2));
368371
Assert.That(withNullOrValidList2.Count, Is.EqualTo(2));
372+
Assert.That(mixImplicitAndLeftJoinList.Count, Is.EqualTo(1));
369373
}
370374
}
371375

src/NHibernate.Test/Hql/EntityJoinHqlTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,17 @@ from x2 in session.Query<NullableOwner>()
347347
var withNullOrValidList = session.Query<NullableOwner>().Where(x => x.ManyToOne.Id == validManyToOne.Id || x.ManyToOne == null).ToList();
348348
var withNullOrValidList2 = session.Query<NullableOwner>().Where(x => x.ManyToOne == null || x.ManyToOne.Id == validManyToOne.Id).ToList();
349349

350+
//GH-3185
351+
var mixImplicitAndLeftJoinList = session.Query<NullableOwner>().Where(x => x.ManyToOne.Id == validManyToOne.Id && x.OneToOne == null).ToList();
352+
350353
Assert.That(fullList.Count, Is.EqualTo(2));
351354
Assert.That(withValidManyToOneList.Count, Is.EqualTo(0));
352355
Assert.That(withValidManyToOneList2.Count, Is.EqualTo(0));
353356
Assert.That(withNullManyToOneList.Count, Is.EqualTo(2));
354357
Assert.That(withNullManyToOneJoinedList.Count, Is.EqualTo(2));
355358
Assert.That(withNullOrValidList.Count, Is.EqualTo(2));
356359
Assert.That(withNullOrValidList2.Count, Is.EqualTo(2));
360+
Assert.That(mixImplicitAndLeftJoinList.Count, Is.EqualTo(1));
357361
}
358362
}
359363

src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,13 @@ public void SetOrigin(FromElement origin, bool manyToMany)
590590
}
591591
else
592592
{
593-
if (!Walker.IsInFrom && !Walker.IsInSelect)
593+
if (Walker.IsInFrom || Walker.IsInSelect || (this.IsImplied && !this.JoinSequence.IsThetaStyle))
594594
{
595-
FromClause.AddChild(this);
595+
origin.AddChild(this);
596596
}
597597
else
598598
{
599-
origin.AddChild(this);
599+
FromClause.AddChild(this);
600600
}
601601
}
602602
}

0 commit comments

Comments
 (0)