Skip to content
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

[release/6.0] Fix to #27356 - Collection_navigation_equal_to_null_for_subquery fails after merging from release/6.0 #27429

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Feb 11, 2022

Improvement on the previous patch fix (#26744). We were not taking into the account scenario where collection projected from FirstOrDefault was compared to null. Collection can only be null if the parent entity is null, so we can safely apply the same optimization we do for anonymous types and required entities.

Fixes #27356


Description

Problem was that we were scaled down the optimization for comparing complex expressions to null, but we scaled it down too much. Scenario involving collection projection could also be optimized (and was being optimized in the too eager version before the previous fix), but now the optimization wouldn't apply causing query compilation error.

Customer impact

Customer executing the query in the scenario would see query compilation error now, whereas before query worked correctly. The scenario is quite niche/contrived (projecting collection navigation, then composing First/Single/etc and then projecting another collection and comparing that to null)

How found

We found it after merging patch to main - we have test coverage for this scenario but it was (incorrectly) disabled with another issue on release 6.0 branch.

Regression

Yes. Optimization before #26744 was too aggressive, but this scenario would have been optimized correctly. Comments in #26744 predicts these breaks could happen. Most of the time it would just lead to worse sql, but here its a scenario enabling optimization, since we are unable to translate the query in it's original form.

Testing

Re-enabled the test case covering this, that we already had.

Risk

Low. Extended the optimization to another (straightforward) scenario. Code path affected is very isolated. Quirk already present.

@maumar maumar changed the title Fix to #27356 - Collection_navigation_equal_to_null_for_subquery fails after merging from release/6.0 [release/6.0] Fix to #27356 - Collection_navigation_equal_to_null_for_subquery fails after merging from release/6.0 Feb 11, 2022
…s after merging from release/6.0

Improvement on the previous patch fix (#26744). We were not taking into the account scenario where collection projected from FirstOrDefault was compared to null. Collection can only be null if the parent entity is null, so we can safely apply the same optimization we do for anonymous types and required entities.

Fixes #27356
@AndriySvyryd AndriySvyryd added this to the 6.0.x milestone Feb 11, 2022
@rbhanda rbhanda modified the milestones: 6.0.x, 6.0.4 Feb 15, 2022
@dougbu dougbu merged commit 0d42647 into release/6.0 Mar 2, 2022
@dougbu dougbu deleted the fix27356_60 branch March 2, 2022 01:20
@ajcvickers ajcvickers removed this from the 6.0.4 milestone Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants