Make TableExpressionBase.Alias immutable #32815
Merged
roji merged 1 commit intodotnet:mainfrom Jan 19, 2024
Merged
Conversation
c2b8510 to
341241f
Compare
This was referenced Jan 14, 2024
341241f to
02f0a42
Compare
roji
commented
Jan 18, 2024
| IEntityType entityType, | ||
| IReadOnlyList<SelectExpression> subSelectExpressions, | ||
| IEnumerable<IAnnotation>? annotations) | ||
| IReadOnlyDictionary<string, IAnnotation>? annotations) |
Member
Author
There was a problem hiding this comment.
@maumar the changes around annotations are to stop duplicating/copying them every time we copy/clone the table expression node; since they're immutable we just reuse the existing dictionary, as is standard with expressions.
| // TODO: Either add a mandatory, abstract non-destructive ChangeAlias to TableExpressionBase, or ideally, | ||
| // TODO: refactor things to split the alias out of TableExpressionBase altogether. | ||
| table.Alias = newAlias; | ||
| table = table.WithAlias(newAlias); |
Member
Author
There was a problem hiding this comment.
This was the one point left actually mutating aliases - an immutable copy of the table is now produced instead.
02f0a42 to
4973e9b
Compare
And do some cleanup around table annotations Continues work from dotnet#32558
4973e9b to
078b677
Compare
AndriySvyryd
approved these changes
Jan 18, 2024
Member
AndriySvyryd
left a comment
There was a problem hiding this comment.
Make sure that the TODO comments you added earlier have a tracking issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE: THIS IS BASED ON TOP OF #32812, REVIEW ONLY THE LAST COMMIT ONLYThis completes the immutability work done in #32812; that PR got rid of the mutable TableReferenceExpression, and this one makes TableExpressionBase.TableAlias immutable. After this, the only mutability we have in our SQL query tree is SelectExpression itself being in temporary mutable mode during translation.
Also did some cleanup around table annotations.
Note: as an alternative design, I considered extracting Alias out of TableExpressionBase altogether, and moving it out to a TableAliasExpression (or AsExpression) which would wrap the table, adding the
AS xpart; this is very similar to what we do in the prjection with ProjectionExpression. However, this would make it considerably harder to work with tables when not caring about their aliases - which is the majority of the time.