[release/7.0] Fix to #30330 - Json: updating property with conversion from string to other type fails on sql server - #30615
Merged
Merged
Conversation
…o other type fails on sql server When producing update statement, when deciding whether we need CAST around the result of JSON_VALUE, we need to look if the property has converter, rather than just look at it's clr type. If the clr type is string, but it gets converted to int/bool etc we still need a CAST. Fixes #30330
Member
|
@roji I can merge this once you've approved it (CC @ajcvickers in case somebody else needs to review it) |
roji
approved these changes
Apr 5, 2023
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.
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.