Skip to content

Commit f44223e

Browse files
committed
Code review changes
1 parent 4cee217 commit f44223e

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,11 @@ public async Task TestFetchAfterEntityIsInitializedAsync(bool readOnly)
948948
[Test]
949949
public async Task TestHqlCrossJoinFetchFormulaAsync()
950950
{
951+
if (!Dialect.SupportsCrossJoin)
952+
{
953+
Assert.Ignore("Dialect does not support cross join.");
954+
}
955+
951956
var persons = new List<Person>();
952957
var bestFriends = new List<Person>();
953958
using (var sqlSpy = new SqlLogSpy())

src/NHibernate.Test/Async/Linq/LinqQuerySamples.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,8 +1065,8 @@ join c in db.Customers on
10651065
await (ObjectDumper.WriteAsync(q));
10661066

10671067
var sql = sqlSpy.GetWholeLog();
1068-
Assert.That(GetTotalOccurrences(sql, "left outer join"), Is.EqualTo(1));
1069-
Assert.That(GetTotalOccurrences(sql, "inner join"), Is.EqualTo(1));
1068+
Assert.That(GetTotalOccurrences(sql, "left outer join"), Is.EqualTo(0));
1069+
Assert.That(GetTotalOccurrences(sql, "inner join"), Is.EqualTo(2));
10701070
}
10711071
}
10721072

src/NHibernate.Test/FetchLazyProperties/FetchLazyPropertiesFixture.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,11 @@ public void TestFetchAfterEntityIsInitialized(bool readOnly)
937937
[Test]
938938
public void TestHqlCrossJoinFetchFormula()
939939
{
940+
if (!Dialect.SupportsCrossJoin)
941+
{
942+
Assert.Ignore("Dialect does not support cross join.");
943+
}
944+
940945
var persons = new List<Person>();
941946
var bestFriends = new List<Person>();
942947
using (var sqlSpy = new SqlLogSpy())

src/NHibernate.Test/Linq/LinqQuerySamples.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,8 +1609,8 @@ join c in db.Customers on
16091609
ObjectDumper.Write(q);
16101610

16111611
var sql = sqlSpy.GetWholeLog();
1612-
Assert.That(GetTotalOccurrences(sql, "left outer join"), Is.EqualTo(1));
1613-
Assert.That(GetTotalOccurrences(sql, "inner join"), Is.EqualTo(1));
1612+
Assert.That(GetTotalOccurrences(sql, "left outer join"), Is.EqualTo(0));
1613+
Assert.That(GetTotalOccurrences(sql, "inner join"), Is.EqualTo(2));
16141614
}
16151615
}
16161616

src/NHibernate/Linq/ReWriters/AddJoinsReWriter.cs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class AddJoinsReWriter : NhQueryModelVisitorBase, IIsEntityDecider
2020
private readonly ISessionFactoryImplementor _sessionFactory;
2121
private readonly MemberExpressionJoinDetector _memberExpressionJoinDetector;
2222
private readonly WhereJoinDetector _whereJoinDetector;
23-
private int? _joinInsertIndex;
2423
private JoinClause _currentJoin;
2524

2625
private AddJoinsReWriter(ISessionFactoryImplementor sessionFactory, QueryModel queryModel)
@@ -72,13 +71,11 @@ private void VisitJoinClause(JoinClause joinClause, QueryModel queryModel, IBody
7271
joinClause.InnerSequence = _whereJoinDetector.Transform(joinClause.InnerSequence);
7372

7473
// When associations are located in the outer key (e.g. from a in A join b in B b on a.C.D.Id equals b.Id),
75-
// we have to insert the association join before the current join in order to produce a valid query.
76-
_joinInsertIndex = queryModel.BodyClauses.IndexOf(bodyClause);
77-
joinClause.OuterKeySelector = _whereJoinDetector.Transform(joinClause.OuterKeySelector);
78-
_joinInsertIndex = null;
74+
// do nothing and leave them to HQL for adding the missing joins.
7975

8076
// When associations are located in the inner key (e.g. from a in A join b in B b on a.Id equals b.C.D.Id),
81-
// we have to move the condition to the where statement, otherwise the query will be invalid.
77+
// we have to move the condition to the where statement, otherwise the query will be invalid (HQL does not
78+
// support them).
8279
// Link newly created joins with the current join clause in order to later detect which join type to use.
8380
_currentJoin = joinClause;
8481
joinClause.InnerKeySelector = _whereJoinDetector.Transform(joinClause.InnerKeySelector);
@@ -99,15 +96,7 @@ public bool IsIdentifier(System.Type type, string propertyName)
9996
private void AddJoin(QueryModel queryModel, NhJoinClause joinClause)
10097
{
10198
joinClause.ParentJoinClause = _currentJoin;
102-
if (_joinInsertIndex.HasValue)
103-
{
104-
queryModel.BodyClauses.Insert(_joinInsertIndex.Value, joinClause);
105-
_joinInsertIndex++;
106-
}
107-
else
108-
{
109-
queryModel.BodyClauses.Add(joinClause);
110-
}
99+
queryModel.BodyClauses.Add(joinClause);
111100
}
112101
}
113102
}

0 commit comments

Comments
 (0)