[release/7.0] Fix to #30330 - Json: updating property with conversion from string to other type fails on sql server #30615
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.
Port of #30380 (product changes) + some test infra fixes
Fixes #30330
Description
JSON entities using converters, where type without converter is string and type with converter is numeric or bool cause invalid update statements to be issues. This is usually not very common, but also affects enums. By default we store enums as strings (human readable format). If users don't like it and prefer the way default JSON serializer processes them (i.e. as int), they would apply converter on json column and hit this issue.
Customer impact
Queries with affected entities throw during update execution.
How found
Customer report report on 7.0
Regression
No. JSON support is new functionality in 7.0.
Testing
We already had a test for this scenario, but due to bug in the way we were using the test infra, the test wasn't properly exercising the scenario (converters were not being used).
Risk
Low: Fix is isolated - only affects update scenarios for properties with a converter. Without the converter exactly the same code as before is being exectued. Added quirk to revert to old behavior if necessary.