Skip to content

Have IFutureEnumerable.GetEnumerable executing immediatly the query #1665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-common/NHibernate.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor Condition="'$(VersionMajor)' == ''">5</VersionMajor>
<VersionMinor Condition="'$(VersionMinor)' == ''">0</VersionMinor>
<VersionPatch Condition="'$(VersionPatch)' == ''">4</VersionPatch>
<VersionPatch Condition="'$(VersionPatch)' == ''">5</VersionPatch>
<VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix>

<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
Expand Down
4 changes: 2 additions & 2 deletions build-common/common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

<!-- This is used only for build folder -->
<!-- TODO: Either remove or refactor to use NHibernate.props -->
<property name="project.version" value="5.0.4" overwrite="false" />
<property name="project.version.numeric" value="5.0.4" overwrite="false" />
<property name="project.version" value="5.0.5" overwrite="false" />
<property name="project.version.numeric" value="5.0.5" overwrite="false" />

<!-- properties used to connect to database for testing -->
<include buildfile="nhibernate-properties.xml" />
Expand Down
10 changes: 9 additions & 1 deletion releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
Build 5.0.4
Build 5.0.5
=============================

Release notes - NHibernate - Version 5.0.5

** Bug
* #1665 Have IFutureEnumerable.GetEnumerable executing immediatly the query

Build 5.0.4
=============================

Release notes - NHibernate - Version 5.0.4
Expand Down
20 changes: 20 additions & 0 deletions src/NHibernate.Test/Async/Futures/FutureQueryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,25 @@ public async Task CanExecuteMultipleQueryWithSameParameterNameAsync()
}
}
}

[Test]
public async Task FutureExecutedOnGetEnumerableAsync()
{
Sfi.Statistics.IsStatisticsEnabled = true;
try
{
using (var s = Sfi.OpenSession())
{
var persons = s.CreateQuery("from Person").Future<Person>();
Sfi.Statistics.Clear();
await (persons.GetEnumerableAsync());
Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1));
}
}
finally
{
Sfi.Statistics.IsStatisticsEnabled = false;
}
}
}
}
20 changes: 20 additions & 0 deletions src/NHibernate.Test/Futures/FutureQueryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,25 @@ public void CanExecuteMultipleQueryWithSameParameterName()
}
}
}

[Test]
public void FutureExecutedOnGetEnumerable()
{
Sfi.Statistics.IsStatisticsEnabled = true;
try
{
using (var s = Sfi.OpenSession())
{
var persons = s.CreateQuery("from Person").Future<Person>();
Sfi.Statistics.Clear();
persons.GetEnumerable();
Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1));
}
}
finally
{
Sfi.Statistics.IsStatisticsEnabled = false;
}
}
}
}
6 changes: 1 addition & 5 deletions src/NHibernate/Impl/DelayedEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ public DelayedEnumerator(GetResult result, GetResultAsync resultAsync)

public IEnumerable<T> GetEnumerable()
{
var value = _result();
foreach (T item in value)
{
yield return item;
}
return _result();
}

// Remove in 6.0
Expand Down