Skip to content

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

Merged
roji merged 1 commit into
dotnet:mainfrom
roji:JsonValueOpenjson
Apr 16, 2024
Merged

Transform JSON_VALUE() to OPENJSON/WITH for binary/varbinary#33440
roji merged 1 commit into
dotnet:mainfrom
roji:JsonValueOpenjson

Conversation

@roji

@roji roji commented Mar 30, 2024

Copy link
Copy Markdown
Member

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 roji force-pushed the JsonValueOpenjson branch from fe5a512 to 1ef51cf Compare April 12, 2024 18:20
@roji

roji commented Apr 12, 2024

Copy link
Copy Markdown
Member Author

@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
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