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
SqlNullabilityProcessor ignores Contains item visitation #32208
Comments
@shvmgpt116 thanks, I can indeed see this bug occuring also with SQL Server with QueryBugsTest.Nested_contains_with_enum, once the compatibility level is set to under 130; older versions of SQL Server don't yet support OPENJSON, so in those cases the provider is in the same state as Oracle. The It also trips the debug assertion in QuerySqlGenerator.GenerateIn. Note that this test represents a pretty rare edge case which shouldn't affect too many actual queries (but of course I'll work on a fix). Generated SQL on SQL Server with low compatibility levelSELECT [t].[Id], [t].[Type]
FROM [Todos] AS [t]
WHERE CASE
WHEN [t].[Type] IN (
) THEN @__key_2
ELSE @__key_2
END IN ('0a47bcb7-a1cb-4345-8944-c58f82d6aac7', '5f221fb9-66f4-442a-92c9-d97ed5989cc7') On a related note, are you planning on implementing the new JSON support for the Oracle provider? For example, the analog of SQL Server's OPENJSON seems to be the JSON_TABLE function on Oracle. I also know that Oracle has a special JSON type for storing JSON data in an optimized way; I'm currently working on making the PostgreSQL provider support that, you could do similar work on the Oracle side. Anyway, let me know if you're interested in this direction and need any assistance! |
This turned out to be a symptom of a larger bug where we were ignoring the results of visiting item in SqlNullabilityProcessor.VisitIn; this affects more scenarios beyond this specific query type. |
@roji Thanks for confirming the issue. |
Reopening to discuss patching 8.0. |
…dotnet#32214) Fixes dotnet#32208 (cherry picked from commit 338b76a)
Merged fix to 8.0.1 via #32265. |
I am running GIT test
QueryBugsTest.Nested_contains_with_enum
. The test is executing following LINQ-The test was working fine with Oracle EFCore 7 provider. However it seems there is some regression issue introduced from the relational layer in EFCore 8 daily label, due to which the test is failing.
Here is my observation.
SqlServer EFCore 7 provider used to generate following query for it-
However in EFCore 8 provider, the query has been changed to-
For the database providers which don't support OPENJSON or similar functionality, they may want to keep on generating the query which was getting generated with EFCore 7 provider.
For Ex:- Oracle EFCore 7 provider generates following query for the test-
However in EFCore 8 the query has been changed to-
While debugging the relational layer code (Method
SqlNullabilityProcessor.VisitIn
) . It seems EFCore 7 used to convert certainInExpression
toSqlBinaryExpression
.For Ex:- There will be two
InExpression
for the above LINQ but the inner one will be converted toSqlBinaryExpression
and the provider will generate[t].[Type] = 0
corresponding to theSqlBinaryExpression
.However in EFCore 8 provider, the converted
SqlBinaryExpression
isn't used to generate the SQL ifInExpression.SubQuery
is null.Is this expected? If yes, then
InExpression.Value
field shouldn't be null (which is the case as of now). TheInExpression
which is used to generate SQL"t"."Type" IN ( )
has null value.This seems to be an issue from the relational layer. Please could someone clarify.
The text was updated successfully, but these errors were encountered: