Skip to content

Fetch requests do not work with collection projections #2341

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

LodewijkSioen
Copy link

Added tests to show #1298 is fixed on the current master.

Added tests to show nhibernate#1298 is fixed
Copy link
Member

@bahusoid bahusoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async code is missing. It can be generated via ShowBuildMenu.bat option H. Please note after
any modifications it needs to be regenerated again. And see my comments below

Resolved comments on PR2341
@LodewijkSioen
Copy link
Author

I've run the 'H' option in the buildmenu, but no code was generated...

Lodewijk Sioen added 2 commits April 1, 2020 08:46
Fix Code Formatting
Fixed test: this shows the difference between Fetch/non-Fetch
Copy link
Member

@bahusoid bahusoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run the 'H' option in the buildmenu, but no code was generated...

Well did it give you any error messages? There is async version of this file:
https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate.Test/Async/Linq/ProjectionsTests.cs

And for new added tests async counterparts should be generated.

@LodewijkSioen
Copy link
Author

Ah, I did have an error, but it wasn't obvious:

     [exec] Starting 'dotnet (../Tools/CSharpAsyncGenerator.CommandLine/0.18.1/tools/netcoreapp2.1/AsyncGenerator.CommandLine.dll)' in 'C:\Projects\External\NHibernate\nhibernate-core\src'
     [exec] Could not execute because the specified command or file was not found.
     [exec] Possible reasons for this include:
     [exec]   * You misspelled a built-in dotnet command.
     [exec]   * You intended to execute a .NET Core program, but dotnet-../Tools/CSharpAsyncGenerator.CommandLine/0.18.1/tools/netcoreapp2.1/AsyncGenerator.CommandLine.dll does not exist.
     [exec]   * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

I don't have a netcoreapp2.1-folder. Only net472...

@bahusoid
Copy link
Member

bahusoid commented Apr 1, 2020

I don't have a netcoreapp2.1

Well yeah - .net core 2.1 is required to be installed on PC to make async generator work

@LodewijkSioen
Copy link
Author

LodewijkSioen commented Apr 1, 2020

No, I don't have this folder: "../Tools/CSharpAsyncGenerator.CommandLine/0.18.1/tools/netcoreapp2.1/" in my git checkout. only "../Tools/CSharpAsyncGenerator.CommandLine/0.18.1/tools/net472/".

Edit: I deleted my Tools folder, and now the package is restored correctly. I'm going to try and get this fixed tomorrow. Sorry for the inconvenience.

public void ProjectAnonymousTypeWithCollection3WithFetch()
{
var query = from o in db.Orders.Fetch(o => o.OrderLines)
select new { OrderLines = o.OrderLines.ToList() };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sql created from this query returns more than 7000 rows, I think that it would be better to use the PatientRecords collection of Patient which has less data:

var query = from o in db.Patients.Fetch(o => o.PatientRecords)
						select new { PatientRecords = o.PatientRecords.ToList() };

the same applies for other queries that were added by this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I should just add the test from the original bug report. Since doing a Fetch when projecting a collection is actually redundant. Adding that one test will guard against a regression for this code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I should just add the test from the original bug report

Fine by me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also ok with that.

@LodewijkSioen
Copy link
Author

I'm sorry, but I'm unable to build the project using ShowBuildMenu. I emptied my .nuget folder, did a git-clean but I still get this exception: buildlog.txt

Buildding in Visual Studio works, but generating the async code after building in Studio gives me the following exception: asynclog.txt

@hazzik
Copy link
Member

hazzik commented Apr 10, 2020

The workaround would be to run following in the root of the repository:

dotnet new globaljson --sdk-version 2.1.700 --force

(Please check what 2.1 SDK version you have first)

@maca88 can you investigate support for .net 3.1?

@hazzik
Copy link
Member

hazzik commented Apr 10, 2020

Which PR has fixed the issue, anyone?

@LodewijkSioen
Copy link
Author

I had tried adding a global.json, but I probably used the wrong sdk-version. Anyhow: I changed the test as discussed. Only the test from the original Issue (#1298) is added and the async version is committed.

@maca88

This comment has been minimized.

@maca88

This comment has been minimized.

@hazzik hazzik marked this pull request as ready for review July 27, 2023 02:29
@hazzik hazzik enabled auto-merge (squash) July 27, 2023 02:29
@hazzik hazzik added this to the 5.5 milestone Jul 27, 2023
@hazzik hazzik disabled auto-merge July 27, 2023 02:30
@hazzik hazzik enabled auto-merge (squash) July 27, 2023 02:31
@hazzik hazzik disabled auto-merge July 27, 2023 02:32
@hazzik hazzik removed this from the 5.5 milestone Jul 27, 2023
@hazzik hazzik removed the r: Fixed label Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants