Skip to content

Commit e72daa0

Browse files
authored
Fix entity join for entity with discriminator (#2464)
1 parent 3c161f0 commit e72daa0

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System.Linq;
12+
using NHibernate.DomainModel;
13+
using NUnit.Framework;
14+
using NHibernate.Linq;
15+
16+
namespace NHibernate.Test.NHSpecificTest.GH2463
17+
{
18+
using System.Threading.Tasks;
19+
[TestFixture]
20+
public class FixtureAsync : TestCase
21+
{
22+
protected override string[] Mappings
23+
{
24+
get { return new[] {"ABC.hbm.xml"}; }
25+
}
26+
27+
[Test]
28+
public async Task CanJoinOnEntityWithDiscriminatorAsync()
29+
{
30+
using (var s = OpenSession())
31+
{
32+
await (s.Query<A>().Join(
33+
s.Query<A>(),
34+
a => a.Id,
35+
b => b.Id,
36+
(a, b) =>
37+
new {a, b}).ToListAsync());
38+
}
39+
}
40+
}
41+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Linq;
2+
using NHibernate.DomainModel;
3+
using NUnit.Framework;
4+
5+
namespace NHibernate.Test.NHSpecificTest.GH2463
6+
{
7+
[TestFixture]
8+
public class Fixture : TestCase
9+
{
10+
protected override string[] Mappings
11+
{
12+
get { return new[] {"ABC.hbm.xml"}; }
13+
}
14+
15+
[Test]
16+
public void CanJoinOnEntityWithDiscriminator()
17+
{
18+
using (var s = OpenSession())
19+
{
20+
s.Query<A>().Join(
21+
s.Query<A>(),
22+
a => a.Id,
23+
b => b.Id,
24+
(a, b) =>
25+
new {a, b}).ToList();
26+
}
27+
}
28+
}
29+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,7 @@ private IQueryable ResolveEntityJoinReferencedPersister(IASTNode path)
794794
if (path.Type == IDENT)
795795
{
796796
var pathIdentNode = (IdentNode) path;
797-
string name = path.Text ?? pathIdentNode.OriginalText;
798-
return SessionFactoryHelper.FindQueryableUsingImports(name);
797+
return SessionFactoryHelper.FindQueryableUsingImports(pathIdentNode.Path);
799798
}
800799
else if (path.Type == DOT)
801800
{

0 commit comments

Comments
 (0)