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

Transform JSON_VALUE() to OPENJSON/WITH for binary/varbinary #33440

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

roji
Copy link
Member

@roji roji commented Mar 30, 2024

This transforms JSON_VALUE() into OPENJSON() in postprocessing for JSON binary/varbinary properties, applying base64 decoding to the data coming out of JSON and properly converting it to SQL Server binary/varbinary. I can't say I'm happy with SQL Server making us jump through all these hoops, but at least our query infrastructure now makes it pretty nice and easy to do this kind of stuff...

Note that this PR only handles binary/varbinary; other cases where we may want to transform JSON_VALUE() to OPENJSON() (e.g. nvarchar(max)) aren't handled and are still tracked by #30981.

Closes #33435

/cc @maumar @cincuranet

@roji roji requested a review from maumar March 30, 2024 22:55
@roji roji changed the title Transform JSON_VALUE() to OPENJSON/WITH when needed Transform JSON_VALUE() to OPENJSON/WITH for binary/varbinary Apr 12, 2024
@roji roji force-pushed the JsonValueOpenjson branch 2 times, most recently from cb2e6fe to fe5a512 Compare April 12, 2024 17:40
@roji
Copy link
Member Author

roji commented Apr 12, 2024

@maumar @cincuranet this PR is restricted specifically to solving the binary/varbinary problem - I'm leaving other things (like big >4000 strings) for discussion/research in #30981. The "infra" introduced in this PR can easily be used to convert JSON_VALUE() -> OPENJSON() for other types as well, if we want to do that.

@roji roji marked this pull request as ready for review April 12, 2024 18:30
@roji roji requested a review from cincuranet April 12, 2024 18:30
@roji roji merged commit ef5f7a3 into dotnet:main Apr 16, 2024
7 checks passed
@roji roji deleted the JsonValueOpenjson branch April 16, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entity mapped to JSON returns different byte[] when not the whole entity is projected
2 participants