Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,16 @@ public async Task NullableEntityProjectionAsync()
var withValidManyToOneList = await (session.Query<NullableOwner>().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<NullableOwner>());
var withNullManyToOneList = await (session.Query<NullableOwner>().Where(x => x.ManyToOne == null).ToListAsync());
var withNullManyToOneJoinedList =
await ((from x in session.Query<NullableOwner>()
from x2 in session.Query<NullableOwner>()
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));
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/NHibernate.Test/Hql/EntityJoinHqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,16 @@ public void NullableEntityProjection()
var withValidManyToOneList = session.Query<NullableOwner>().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<NullableOwner>();
var withNullManyToOneList = session.Query<NullableOwner>().Where(x => x.ManyToOne == null).ToList();
var withNullManyToOneJoinedList =
(from x in session.Query<NullableOwner>()
from x2 in session.Query<NullableOwner>()
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));
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(", ");
}
}
}

Expand Down