diff --git a/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs b/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs index eebd9d8768c..95672bab016 100644 --- a/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs +++ b/src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs @@ -344,10 +344,16 @@ public async Task NullableEntityProjectionAsync() var withValidManyToOneList = await (session.Query().Where(x => x.ManyToOne != null).Select(x => new {x.Name, ManyToOneId = (Guid?) x.ManyToOne.Id}).ToListAsync()); var withValidManyToOneList2 = await (session.CreateQuery("from NullableOwner ex where not ex.ManyToOne is null").ListAsync()); var withNullManyToOneList = await (session.Query().Where(x => x.ManyToOne == null).ToListAsync()); + var withNullManyToOneJoinedList = + await ((from x in session.Query() + from x2 in session.Query() + where x == x2 && x.ManyToOne == null && x.OneToOne.Name == null + select x2).ToListAsync()); Assert.That(fullList.Count, Is.EqualTo(2)); Assert.That(withValidManyToOneList.Count, Is.EqualTo(0)); Assert.That(withValidManyToOneList2.Count, Is.EqualTo(0)); Assert.That(withNullManyToOneList.Count, Is.EqualTo(2)); + Assert.That(withNullManyToOneJoinedList.Count, Is.EqualTo(2)); } } diff --git a/src/NHibernate.Test/Hql/EntityJoinHqlTest.cs b/src/NHibernate.Test/Hql/EntityJoinHqlTest.cs index 85164ebb861..ac67ccb647e 100644 --- a/src/NHibernate.Test/Hql/EntityJoinHqlTest.cs +++ b/src/NHibernate.Test/Hql/EntityJoinHqlTest.cs @@ -332,10 +332,16 @@ public void NullableEntityProjection() var withValidManyToOneList = session.Query().Where(x => x.ManyToOne != null).Select(x => new {x.Name, ManyToOneId = (Guid?) x.ManyToOne.Id}).ToList(); var withValidManyToOneList2 = session.CreateQuery("from NullableOwner ex where not ex.ManyToOne is null").List(); var withNullManyToOneList = session.Query().Where(x => x.ManyToOne == null).ToList(); + var withNullManyToOneJoinedList = + (from x in session.Query() + from x2 in session.Query() + where x == x2 && x.ManyToOne == null && x.OneToOne.Name == null + select x2).ToList(); Assert.That(fullList.Count, Is.EqualTo(2)); Assert.That(withValidManyToOneList.Count, Is.EqualTo(0)); Assert.That(withValidManyToOneList2.Count, Is.EqualTo(0)); Assert.That(withNullManyToOneList.Count, Is.EqualTo(2)); + Assert.That(withNullManyToOneJoinedList.Count, Is.EqualTo(2)); } } diff --git a/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs b/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs index 0f1c7a64603..20e05086d2a 100644 --- a/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs +++ b/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs @@ -229,8 +229,15 @@ protected virtual void FromFragmentSeparator(IASTNode a) } else { - // these are just two unrelated table references - Out(", "); + if (right.JoinSequence?.IsThetaStyle == false && right.JoinSequence.JoinCount != 0) + { + Out(" "); + } + else + { + // these are just two unrelated table references + Out(", "); + } } }