Skip to content

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

Merged
ajcvickers merged 1 commit into
release/7.0from
fix30330_70
Apr 5, 2023
Merged

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

Conversation

@maumar

@maumar maumar commented Apr 3, 2023

Copy link
Copy Markdown
Contributor

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

wtgodbe commented Apr 4, 2023

Copy link
Copy Markdown
Member

@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