Upgrades to enumeration fields and queries related to them #8801
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.
In reference to issue #8800, which solves a compatibility issue added by #8789 , I added an Upgrade procedure (inside the Upgrade module) that saves / publishes again every content item which contains an EnumerationField in the definition of its parts. This is needed to ensure that both the content item's infoset and the string field index records used by the projections for the enumeration fields' values are in the new format (with ";" separator characters at the beginning and at the end of the value).
I didn't use a migration step because of the lenght of the procedure (potentially saving thousands of content items for each tenant) and to be able to schedule the long update script to be asynchronous.
As discussed and explained in the issue thread, I also implemented a new IFilterProvider, specific for EnumerationFields, that processes the values for the query in order to ensure that old queries still work. This solves an issue which is specific to single choice EnumerationFields, the value of which is now in the format of ";value;" instead of "value" (without the semicolons). Appropriate semicolons are added for Equals/NotEquals, StartsWith/NotStartsWith and EndsWith/NotEndsWith string operators, the ones who were affected by #8789 .
This new filter provider has the same category and name of the original ContentFieldsFilterProvider (modificed accordingly to exclude EnumerationFields from its execution) and, for this reason, old queries work properly without the need of a migration, using the new, specific provider.
The Upgrade step has to be executed manually for each tenant in order to make the new filter provider to work properly. If upgrade isn't executed, EnumerationFields with the old value format will not be "found" by the queries if they are filtered with Equals/NotEquals, StartsWith/NotStartsWith or EndsWith/NotEndsWith string operators.