Skip to content

Commit

Permalink
Do not append from element when already in from (#3476)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericDelaporte committed Feb 2, 2024
1 parent 6933bf0 commit 8aae0b7
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/NHibernate.Test/Async/NHSpecificTest/GH3465/Fixture.cs
@@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


using System.Linq;
using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.GH3465
{
using System.Threading.Tasks;
[TestFixture]
public class FixtureAsync : BugTestCase
{
[Test]
public void ThetaJoinSubQueryAsync()
{
using (var session = OpenSession())
using (session.BeginTransaction())
{
var query = session.CreateQuery("select e.Id from EntityA e where exists (from e.Children b, EntityC c)");
Assert.DoesNotThrowAsync(() => query.ListAsync());
}
}
}
}
20 changes: 20 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3465/Entities.cs
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;

namespace NHibernate.Test.NHSpecificTest.GH3465
{
class EntityA
{
public virtual Guid Id { get; set; }
public virtual ISet<EntityB> Children { get; set; }
}
class EntityB
{
public virtual Guid Id { get; set; }
public virtual EntityA Parent { get; set; }
}
class EntityC
{
public virtual Guid Id { get; set; }
}
}
20 changes: 20 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3465/Fixture.cs
@@ -0,0 +1,20 @@
using System.Linq;
using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.GH3465
{
[TestFixture]
public class Fixture : BugTestCase
{
[Test]
public void ThetaJoinSubQuery()
{
using (var session = OpenSession())
using (session.BeginTransaction())
{
var query = session.CreateQuery("select e.Id from EntityA e where exists (from e.Children b, EntityC c)");
Assert.DoesNotThrow(() => query.List());
}
}
}
}
18 changes: 18 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3465/Mappings.hbm.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
namespace="NHibernate.Test.NHSpecificTest.GH3465">
<class name="EntityA">
<id name="Id" generator="guid.comb" />
<set name="Children" cascade="all-delete-orphan" inverse="true">
<key column="EntityAId" />
<one-to-many class="EntityB" />
</set>
</class>
<class name="EntityB">
<id name="Id" generator="guid.comb" />
<many-to-one name="Parent" column="EntityAId" class="EntityA" not-null="true" />
</class>
<class name="EntityC">
<id name="Id" generator="guid.comb" />
</class>
</hibernate-mapping>
2 changes: 1 addition & 1 deletion src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs
Expand Up @@ -716,7 +716,7 @@ public void SetOrigin(FromElement origin, bool manyToMany)
JoinSequence.SetUseThetaStyle(true);
}
}
else
else if (Walker.CurrentClauseType != HqlSqlWalker.FROM)
{
FromClause.AppendFromElement(this);
}
Expand Down

0 comments on commit 8aae0b7

Please sign in to comment.