You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Query: accessing property on a required navigation defined on a derived type produces INNER JOIN #10988
SELECT [p].[Id], [p].[Discriminator], [p].[SchoolId], [p].[StudentName]
FROM [People] AS [p]
INNER JOIN [Schools] AS [p.School] ON CASE
WHEN [p].[Discriminator] = N'Student'
THEN [p].[SchoolId] ELSE NULL
END = [p.School].[Id]
WHERE [p].[Discriminator] IN (N'Student', N'Person')
ORDER BY [p.School].[Name]
We should be producing LOJ here, in case not all people are students (such query would throw cast exception in L2O, but we allow it to execute)
changed the title [-]Query: order by property on a required navigation defined on a derived type produces INNER JOIN[/-][+]Query: accessing property on a required navigation defined on a derived type produces INNER JOIN[/+]on Feb 16, 2018
This is not included in 2.1.0-preview1 but seems important to me. I was happy to have the fix for #3910 but including my derived properties is causing INNER JOIN thus not solving my problem (I'm currently explicitly loading those properties). Is it planned to add this to 2.1?
@iudelsmann as I said in a comment before, changing from int to int? solved my problem, and generates a left join, without the need to explicitly load the properties
@heightpi It does work indeed, but it would also allow someone to save a null value where I wouldn't want one. I can't have the restriction in the database since the parent class doesn't have the property, so I must have the restriction in my code. When someone tries to save value zero the database will throw an error since it violates the foreign key constraint.
I could do this or another workaround, but I prefer waiting for the release since this is already fixed.
@iudelsmann - This is fixed in 2.1.0 milestone so it will be included in RTM release of 2.1.0. It should be included in next release (preview/rc/RTM). The milestone will change accordingly to indicate the exact release number.
@ajcvickers Sorry for the delay, had some busy days and some troubles. Tried to test this now but seems to be getting a problem with missing apostrophes surrounding my discriminator values, causing the query to be invalid throwing an exception in postgres. Using ef core 2.1.0-preview2-30301 and npgsql.PostgreSQL 2.1.0-ci-00132.
Any missing apostrophes sound more like an issue in the Npgsql provider (and unrelated to the original issue above), can you please post a code sample on Npgsql.EntityFrameworkCore.PostgreSQL?
Activity
heightpi commentedon Feb 16, 2018
Until this will be fixed, i used nullable int to generate a LEFT JOIN
public int? SchoolId { get; set; }in the Student Class[-]Query: order by property on a required navigation defined on a derived type produces INNER JOIN[/-][+]Query: accessing property on a required navigation defined on a derived type produces INNER JOIN[/+]ajcvickers commentedon Feb 17, 2018
Decision from triage: we should make both the explicit cast and the as cast work in the same way, including null compensation/propagation.
Fix to #10988 - Query: accessing property on a required navigation de…
Fix to #10988 - Query: accessing property on a required navigation de…
Fix to #10988 - Query: accessing property on a required navigation de…
maumar commentedon Feb 21, 2018
Fixed in 1fcdbea
iudelsmann commentedon Mar 2, 2018
This is not included in 2.1.0-preview1 but seems important to me. I was happy to have the fix for #3910 but including my derived properties is causing INNER JOIN thus not solving my problem (I'm currently explicitly loading those properties). Is it planned to add this to 2.1?
heightpi commentedon Mar 2, 2018
@iudelsmann as I said in a comment before, changing from int to int? solved my problem, and generates a left join, without the need to explicitly load the properties
iudelsmann commentedon Mar 2, 2018
@heightpi It does work indeed, but it would also allow someone to save a null value where I wouldn't want one. I can't have the restriction in the database since the parent class doesn't have the property, so I must have the restriction in my code. When someone tries to save value zero the database will throw an error since it violates the foreign key constraint.
I could do this or another workaround, but I prefer waiting for the release since this is already fixed.
smitpatel commentedon Mar 2, 2018
@iudelsmann - This is fixed in 2.1.0 milestone so it will be included in RTM release of 2.1.0. It should be included in next release (preview/rc/RTM). The milestone will change accordingly to indicate the exact release number.
ajcvickers commentedon Mar 2, 2018
@iudelsmann Could you test with out nightly build? The feeds are listed on the repo home: https://github.com/aspnet/EntityFrameworkCore
iudelsmann commentedon Mar 13, 2018
@ajcvickers Sorry for the delay, had some busy days and some troubles. Tried to test this now but seems to be getting a problem with missing apostrophes surrounding my discriminator values, causing the query to be invalid throwing an exception in postgres. Using ef core 2.1.0-preview2-30301 and npgsql.PostgreSQL 2.1.0-ci-00132.
ajcvickers commentedon Mar 13, 2018
@iudelsmann Can you file a new issue for this including a runnable project/solution or complete code listing so that we can investigate? /cc @roji
roji commentedon Mar 13, 2018
Any missing apostrophes sound more like an issue in the Npgsql provider (and unrelated to the original issue above), can you please post a code sample on Npgsql.EntityFrameworkCore.PostgreSQL?