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/7.0] Fix to #30358 - Duplicate table alias in generated select query (An item with the same key has already been added) #30486

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Mar 14, 2023

Port of #30484
Fixes #30358

Description

Queries that join tables starting with the same letter that also have owned navigations mapped to a different table, also starting with the same letter generate incorrect aliases resulting in exception when trying to execute those queries. Problem was that the metadata describing our sql expressions and the actual expression were out of sync, so there might be other cases fixed by this as well.

Customer impact

Affected queries throw during translation.

How found

Customer report on 7.0

Regression

Yes. This scenario worked correctly in previous version of EF Core.

Testing

Added regression tests for affected scenario.

Risk

Low: Fix is on a relatively common path but is very simple and safe. Worst case we will generate query with different aliases (e.g. e1 rather than e) but it shouldn't have a negative functional impact. Added quirk to revert to old behavior if necessary.

…tem with the same key has already been added)

We were not updating usedAliases list as we uniquify table aliases after combining two sources because of JOIN. If the resulting query also needs owned type expanded (when owned type is mapped to a separate table - this expansion happens in translation rather than nav expansion), additional table generated could have incorrect alias.
Fix is to update the usedAliases list as we make changes to aliases, so that when new tables are added we generate new aliases correctly.

Fixes #30358
@maumar maumar requested review from roji and ajcvickers March 14, 2023 22:56
@maumar maumar added this to the 7.0.x milestone Mar 14, 2023
@maumar maumar changed the title Fix to #30358 - Duplicate table alias in generated select query (An item with the same key has already been added) [release/7.0] Fix to #30358 - Duplicate table alias in generated select query (An item with the same key has already been added) Mar 14, 2023
@rbhanda rbhanda modified the milestones: 7.0.x, 7.0.7, 7.0.6 Mar 16, 2023
@wtgodbe wtgodbe merged commit ec314d5 into release/7.0 Apr 4, 2023
@wtgodbe wtgodbe deleted the fix30358_70 branch April 4, 2023 19:27
@rbhanda rbhanda modified the milestones: 7.0.6, 7.0.7 Jun 1, 2023
@ajcvickers ajcvickers removed this from the 7.0.7 milestone Nov 14, 2023
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.

5 participants