Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] Fix to #30330 - Json: updating property with conversion from string to other type fails on sql server #30615

Merged
merged 1 commit into from
Apr 5, 2023

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Apr 3, 2023

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.

…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
@maumar maumar requested a review from roji April 3, 2023 20:53
@leecow leecow added this to the 7.0.6 milestone Apr 4, 2023
@wtgodbe
Copy link
Member

wtgodbe commented Apr 4, 2023

@roji I can merge this once you've approved it (CC @ajcvickers in case somebody else needs to review it)

@ajcvickers ajcvickers merged commit 5d71afe into release/7.0 Apr 5, 2023
@ajcvickers ajcvickers deleted the fix30330_70 branch April 5, 2023 17:47
@rbhanda rbhanda modified the milestones: 7.0.6, 7.0.7 Jun 1, 2023
@ajcvickers ajcvickers removed this from the 7.0.7 milestone Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants