Skip to content

Commit 43fefb9

Browse files
committed
Fix
1 parent 57e2623 commit 43fefb9

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -832,16 +832,6 @@ void CreateFromJoinElement(
832832

833833
HandleWithFragment(fromElement, with);
834834
}
835-
836-
if (fromElement.Parent == null)
837-
{
838-
// Most likely means association join is used in invalid context
839-
// I.e. in subquery: from EntityA a where exists (from EntityB join a.Assocation)
840-
// Maybe we should throw exception instead
841-
fromElement.FromClause.AddChild(fromElement);
842-
if (fromElement.IsImplied)
843-
fromElement.JoinSequence.SetUseThetaStyle(true);
844-
}
845835
}
846836

847837
if ( log.IsDebugEnabled() )
@@ -930,7 +920,7 @@ private static string GetPropertyPath(DotNode dotNode, IASTNode alias)
930920
return lhs.Path + "." + path;
931921
}
932922

933-
IASTNode CreateFromElement(string path, IASTNode pathNode, IASTNode alias, IASTNode propertyFetch)
923+
FromElement CreateFromElement(string path, IASTNode pathNode, IASTNode alias, IASTNode propertyFetch)
934924
{
935925
FromElement fromElement = _currentFromClause.AddFromElement(path, alias);
936926
SetPropertyFetch(fromElement, propertyFetch, alias);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,14 @@ fromElementList @init{
266266
267267
fromElement!
268268
@init {
269-
IASTNode fromElement = null;
269+
FromElement fromElement = null;
270270
}
271271
// A simple class name, alias element.
272-
: ^(RANGE p=path (a=ALIAS)? (pf=propertyFetch)? ) { fromElement = CreateFromElement($p.p, $p.tree, $a, $pf.tree); }
272+
: ^(RANGE p=path (a=ALIAS)? (pf=propertyFetch)? )
273+
{
274+
fromElement = CreateFromElement($p.p, $p.tree, $a, $pf.tree);
275+
fromElement.JoinSequence.SetUseThetaStyle(true);
276+
}
273277
-> {fromElement != null}? ^({fromElement})
274278
->
275279
| je=joinElement

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,11 @@ internal void FinishInit()
447447
dependentElement.Parent.InsertChild(index, item);
448448
}
449449
}
450+
451+
if (_appendFromElements.Count > 0)
452+
{
453+
_fromElements[0].JoinSequence.SetUseThetaStyle(true);
454+
}
450455
_appendFromElements.Clear();
451456
}
452457

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,7 @@ public void SetOrigin(FromElement origin, bool manyToMany)
711711
}
712712
else
713713
{
714-
// Otherwise, the destination node was implied by the FROM clause and the FROM clause processor
715-
// will automatically add it in the right place.
714+
FromClause.AppendFromElement(this);
716715
}
717716
}
718717

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public FromElement CreateEntityJoin(
321321
// 1) 'elem' is the "root from-element" in correlated subqueries
322322
// 2) The DotNode.useThetaStyleImplicitJoins has been set to true
323323
// and 'elem' represents an implicit join
324-
if (elem.FromClause != elem.Origin.FromClause || DotNode.UseThetaStyleImplicitJoins)
324+
if (DotNode.UseThetaStyleImplicitJoins)
325325
{
326326
// the "root from-element" in correlated subqueries do need this piece
327327
elem.Type = HqlSqlWalker.FROM_FRAGMENT;

0 commit comments

Comments
 (0)