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

EnumHasFlagTranslator should clone SelectExpression when repeating #24460

Closed
smitpatel opened this issue Mar 20, 2021 · 2 comments · Fixed by #24701
Closed

EnumHasFlagTranslator should clone SelectExpression when repeating #24460

smitpatel opened this issue Mar 20, 2021 · 2 comments · Fixed by #24701
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@smitpatel
Copy link
Contributor

Generated SQL

SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank]
FROM [Gears] AS [g]
WHERE ([g].[Rank] & COALESCE((
    SELECT TOP(1) [g1].[Rank]
    FROM [Gears] AS [g1]
    ORDER BY [g1].[Nickname], [g1].[SquadId]), 0)) = COALESCE((
    SELECT TOP(1) [g1].[Rank]
    FROM [Gears] AS [g1]
    ORDER BY [g1].[Nickname], [g1].[SquadId]), 0)

The SelectExpression is visited twice and mutated in place. Current side effect is first visit applies "g0" alias, second one updates to "g1" erasing "g0" from query.

@ajcvickers ajcvickers added this to the Backlog milestone Mar 23, 2021
smitpatel added a commit that referenced this issue Apr 20, 2021
Also add a visitor to verify that all table references are proper
Update alias unique-fier to skip already visited expression

Fixes #24473
Fixes #24460
@smitpatel
Copy link
Contributor Author

For now, I am converting to skip already visited SelectExpression so we don't re-assign new alias. If in future we encounter case where it causes incorrect SQL, we can look into how to resolve it.

@smitpatel smitpatel self-assigned this Apr 20, 2021
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Apr 20, 2021
@smitpatel smitpatel modified the milestones: Backlog, 6.0.0 Apr 20, 2021
smitpatel added a commit that referenced this issue Apr 20, 2021
Also add a visitor to verify that all table references are proper
Update alias unique-fier to skip already visited expression

Fixes #24473
Fixes #24460
smitpatel added a commit that referenced this issue Apr 20, 2021
Also add a visitor to verify that all table references are proper
Update alias unique-fier to skip already visited expression

Fixes #24473
Fixes #24460
@ghost ghost closed this as completed in #24701 Apr 20, 2021
ghost pushed a commit that referenced this issue Apr 20, 2021
Also add a visitor to verify that all table references are proper
Update alias unique-fier to skip already visited expression

Fixes #24473
Fixes #24460
@ajcvickers ajcvickers modified the milestones: 6.0.0, 6.0.0-preview5 Apr 26, 2021
@smitpatel
Copy link
Contributor Author

#26532 will resolve it fully.

@ajcvickers ajcvickers modified the milestones: 6.0.0-preview5, 6.0.0 Nov 8, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants