a new method of ProposedNew
set comparison
#32563
Merged
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.
The existing
ProposedNew
set comparison method uses the prior elements with the computed portions nulled out to find candidates to match the configuration. This has the shortcoming of always removing optional+computed attributes, because we have not yet found the configuration to know if attribute was set or not.Rather than having to take the most pessimistic value before comparison to precompute the nulled values, we can compare each candidate config and prior pair directly, walking the values in tandem. Each prior value is compared against the config and checked to see if it could have been derived from that configuration value, which allows us to treat optional+computed as optional if there is config and computed if there is not.
This removes the ambiguity from having optional+computed attributes within sets, giving us consistent plans when all values are known. Unknown values of course are still undecidable, as are edge cases were providers refresh with altered values or retained changed prior values plan that were deemed not functionally significant. We also cannot descend into nested sets, not only because the combinatorial problem of matching all possible nested values, but because we can't lookup nested blocks by paths nor can we use
path.Apply
when indexing through sets. The latter problems are possible to solve, through refactoring the schema and temporarily restructuring the set elements for comparison, but unless a compelling use case for such a structure arises the additional complexity has little benefit.