-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
GroupJoin to parent with no child throws invalid operation exception #9892
Comments
Notes for triage: I was able to reproduce this and the data in the database looks valid. This is reported as a regression, so assigning to @smitpatel to do some initial investigation and putting in 2.0.1 until we know more. |
I downloaded zip file from repro. Updated connection strings. Ran 'dotnet ef database update' and 'dotnet run' it passes successfully. What am i missing. |
@smitpatel Did you set |
I got repro. |
… invalid operation exception Issue: When we are trying to lift GroupJoin queries without DefaultIfEmpty, we generate LEFT JOIN which means the inner can be null too. But we still have inner key selector doing property access on inner which could throw null ref. If the inner is using EntityShaper then shaper & all access becomes null safe, but in other cases it fails. Solution: Since inner is projecting out a non-entity, we would always have TypedProjectionShaper, which does not have null safe mechanism. Hence For such queries we need to block lifting into lift join Resolves #9892
@smitpatel Can you write the patch Risk/Justification for this? |
Risk: Low |
This patch bug is approved for the 2.0.x patch. Please send a PR to the |
Hi, we have a public test feed that you can use to try out the ASP.NET/EF Core 2.0.3 patch! To try out the pre-release patch, please refer to the following guide:
We are looking for feedback on this patch. We'd like to know if you have any issues with this patch by updating your apps and libraries to the latest packages and seeing if it fixes the issues you've had, or if it introduces any new issues. If you have any issues or questions, please reply on this issue to let us know as soon as possible. Thanks, |
I can confirm that I no longer get this error. A little annoyingly it still runs two queries to get the results, but I'll take that over an error. |
Still having this issue with 2.0.1 packages (including Microsoft.EntityFrameworkCore.SqlServer 2.0.1)... here is my package reference list <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.1.5" />
<PackageReference Include="System.Security.Cryptography.Csp" Version="4.3.0" />
</ItemGroup> dotnet 2.0.3 |
@mchenx Can you post a new issue with a runnable project/solution or code listing that reproduces what you are seeing? |
I have a query that selects parent records sets all child records to be a property. This query work in EF Core 1.1 even if it was rather inefficient and performed the matching in memory. With EF Core 2.0 it is now efficiently running just one query and attempting to build the objects from the one result set. This works fine so long as all parent records have a child record. If one of the parents does not have a child record it throws the following error.
Steps to reproduce
If have created a sample application (with EF migrations) that exhibits this issue, the repo is available here
The query that is causing the problem is:
if I materialise the child query and then pass it into the group join, then it works as expected i.e:
I have other very similar queries which work as expected, however they return an EF typed object from the first parameter to the GroupJoin method. If it is an anonymous type (like here) or another POCO, I get this error.
If have tried the following query
But this seems to query
OtherParent
for eachParent
that has at least oneChild
.Further technical details
EF Core version: 2.0.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Win10
IDE: Visual Studio 2017 (15.3.5)
The text was updated successfully, but these errors were encountered: