Skip to content

Commit 8aae0b7

Browse files
Do not append from element when already in from (#3476)
1 parent 6933bf0 commit 8aae0b7

File tree

5 files changed

+90
-1
lines changed

5 files changed

+90
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 NUnit.Framework;
13+
14+
namespace NHibernate.Test.NHSpecificTest.GH3465
15+
{
16+
using System.Threading.Tasks;
17+
[TestFixture]
18+
public class FixtureAsync : BugTestCase
19+
{
20+
[Test]
21+
public void ThetaJoinSubQueryAsync()
22+
{
23+
using (var session = OpenSession())
24+
using (session.BeginTransaction())
25+
{
26+
var query = session.CreateQuery("select e.Id from EntityA e where exists (from e.Children b, EntityC c)");
27+
Assert.DoesNotThrowAsync(() => query.ListAsync());
28+
}
29+
}
30+
}
31+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace NHibernate.Test.NHSpecificTest.GH3465
5+
{
6+
class EntityA
7+
{
8+
public virtual Guid Id { get; set; }
9+
public virtual ISet<EntityB> Children { get; set; }
10+
}
11+
class EntityB
12+
{
13+
public virtual Guid Id { get; set; }
14+
public virtual EntityA Parent { get; set; }
15+
}
16+
class EntityC
17+
{
18+
public virtual Guid Id { get; set; }
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Linq;
2+
using NUnit.Framework;
3+
4+
namespace NHibernate.Test.NHSpecificTest.GH3465
5+
{
6+
[TestFixture]
7+
public class Fixture : BugTestCase
8+
{
9+
[Test]
10+
public void ThetaJoinSubQuery()
11+
{
12+
using (var session = OpenSession())
13+
using (session.BeginTransaction())
14+
{
15+
var query = session.CreateQuery("select e.Id from EntityA e where exists (from e.Children b, EntityC c)");
16+
Assert.DoesNotThrow(() => query.List());
17+
}
18+
}
19+
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
3+
namespace="NHibernate.Test.NHSpecificTest.GH3465">
4+
<class name="EntityA">
5+
<id name="Id" generator="guid.comb" />
6+
<set name="Children" cascade="all-delete-orphan" inverse="true">
7+
<key column="EntityAId" />
8+
<one-to-many class="EntityB" />
9+
</set>
10+
</class>
11+
<class name="EntityB">
12+
<id name="Id" generator="guid.comb" />
13+
<many-to-one name="Parent" column="EntityAId" class="EntityA" not-null="true" />
14+
</class>
15+
<class name="EntityC">
16+
<id name="Id" generator="guid.comb" />
17+
</class>
18+
</hibernate-mapping>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ public void SetOrigin(FromElement origin, bool manyToMany)
716716
JoinSequence.SetUseThetaStyle(true);
717717
}
718718
}
719-
else
719+
else if (Walker.CurrentClauseType != HqlSqlWalker.FROM)
720720
{
721721
FromClause.AppendFromElement(this);
722722
}

0 commit comments

Comments
 (0)