Skip to content

Commit

Permalink
Merge 5.4.6 in master
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericDelaporte committed Aug 27, 2023
2 parents 98bd644 + ccff784 commit ff5b845
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 12 deletions.
22 changes: 19 additions & 3 deletions releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
Build 5.4.5
Build 5.4.6
=============================

Release notes - NHibernate - Version 5.4.6

2 issues were resolved in this release.

** Bug

* #3414 Reenable use of SelectClauseVisitor for subqueries

** Task

* #3419 Release 5.4.6


Build 5.4.5
=============================

Release notes - NHibernate - Version 5.4.5
Expand All @@ -7,8 +23,8 @@ Release notes - NHibernate - Version 5.4.5

** Task

* #3408 Release 5.4.4
* #3407 Release Merge 5.3.19 in 5.4.x
* #3408 Release 5.4.5
* #3407 Merge 5.3.19 in 5.4.x


Build 5.4.4
Expand Down
13 changes: 13 additions & 0 deletions src/NHibernate.Test/Async/Linq/WhereTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,19 @@ where sheet.Users.Select(x => x.NullableEnum2 ?? value).Contains(value)
Assert.That(query.Count, Is.EqualTo(1));
}

[Test]
public async Task TimesheetsWithProjectionInSubqueryAsync()
{
if (Dialect is MsSqlCeDialect)
Assert.Ignore("Dialect is not supported");

var query = await ((from sheet in db.Timesheets
where sheet.Users.Select(x => new { Id = x.Id, Name = x.Name }).Any(x => x.Id == 1)
select sheet).ToListAsync());

Assert.That(query.Count, Is.EqualTo(2));
}

[Test]
public async Task ContainsSubqueryWithCoalesceStringEnumSelectAsync()
{
Expand Down
13 changes: 13 additions & 0 deletions src/NHibernate.Test/Linq/WhereTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,19 @@ where sheet.Users.Select(x => x.NullableEnum2 ?? value).Contains(value)
Assert.That(query.Count, Is.EqualTo(1));
}

[Test]
public void TimesheetsWithProjectionInSubquery()
{
if (Dialect is MsSqlCeDialect)
Assert.Ignore("Dialect is not supported");

var query = (from sheet in db.Timesheets
where sheet.Users.Select(x => new { Id = x.Id, Name = x.Name }).Any(x => x.Id == 1)
select sheet).ToList();

Assert.That(query.Count, Is.EqualTo(2));
}

[Test]
public void ContainsSubqueryWithCoalesceStringEnumSelect()
{
Expand Down
6 changes: 1 addition & 5 deletions src/NHibernate/Linq/Visitors/QueryModelVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,9 @@ public override void VisitSelectClause(SelectClause selectClause, QueryModel que

private HqlSelect GetSelectClause(Expression selectClause)
{
if (!_root)
return _hqlTree.TreeBuilder.Select(
HqlGeneratorExpressionVisitor.Visit(selectClause, VisitorParameters).AsExpression());

var visitor = new SelectClauseVisitor(typeof(object[]), VisitorParameters);

visitor.VisitSelector(selectClause);
visitor.VisitSelector(selectClause, !_root);

if (visitor.ProjectionExpression != null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/NHibernate/Linq/Visitors/SelectClauseNominator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public SelectClauseHqlNominator(VisitorParameters parameters)
_parameters = parameters;
}

internal Expression Nominate(Expression expression)
internal Expression Nominate(Expression expression, bool isSubQuery = false)
{
HqlCandidates = new HashSet<Expression>();
ContainsUntranslatedMethodCalls = false;
_canBeCandidate = true;
_stateStack = new Stack<bool>();
_stateStack.Push(false);
_stateStack.Push(isSubQuery);

return Visit(expression);
}
Expand Down
6 changes: 4 additions & 2 deletions src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public IEnumerable<HqlExpression> GetHqlNodes()
return _hqlTreeNodes;
}

public void VisitSelector(Expression expression)
public void VisitSelector(Expression expression) => VisitSelector(expression, false);

public void VisitSelector(Expression expression, bool isSubQuery)
{
var distinct = expression as NhDistinctExpression;
if (distinct != null)
Expand All @@ -44,7 +46,7 @@ public void VisitSelector(Expression expression)

// Find the sub trees that can be expressed purely in HQL
var nominator = new SelectClauseHqlNominator(_parameters);
expression = nominator.Nominate(expression);
expression = nominator.Nominate(expression, isSubQuery);
_hqlNodes = nominator.HqlCandidates;

// Linq2SQL ignores calls to local methods. Linq2EF seems to not support
Expand Down

0 comments on commit ff5b845

Please sign in to comment.