-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Json column has different support for Chinese in addition and editing #30315
Comments
This is probably a result of us handling partial updates differently than full-document updates... /cc @maumar |
we populate parameter value using the same code paths, and they are both in the same form in the parameter string: exec sp_executesql N'SET IMPLICIT_TRANSACTIONS OFF;
SET NOCOUNT ON;
INSERT INTO [User] ([Address], [UserId], [Name])
VALUES (@p0, @p1, @p2);
',N'@p0 nvarchar(23),@p1 uniqueidentifier,@p2 nvarchar(50)',@p0=N'{"City":"\u4E0A\u6D77"}',@p1='F41F2D67-0FDB-4C09-8681-A1180CB2920C',@p2=N'超超' vs exec sp_executesql N'SET IMPLICIT_TRANSACTIONS OFF;
SET NOCOUNT ON;
UPDATE [User] SET [Address] = JSON_MODIFY([Address], ''strict $.City'', JSON_VALUE(@p0, ''$[0]''))
OUTPUT 1
WHERE [UserId] = @p1;
',N'@p0 nvarchar(16),@p1 uniqueidentifier',@p0=N'["\u5317\u4EAC"]',@p1='F41F2D67-0FDB-4C09-8681-A1180CB2920C' however, the output is different between JSON_VALUE and JSON_QUERY: SELECT JSON_VALUE(N'{"City" : "\u5317\u4EAC"}', '$.City') returns whereas SELECT JSON_QUERY(N'{"City" : "\u5317\u4EAC"}') returns |
to get consistent (escaped) behavior we can escape the escape char when generating string for single property value. SELECT JSON_VALUE(N'{"City" : "\\u5317\\u4EAC"}', '$.City') returns We need provider specific ModificationCommand to do that properly, but we already need provider specific ModificationCommand for JSON on Sqlite work. |
Note from triage: Try including Unicode characters directly in the string, rather than with escape sequences. |
we still save data in the escaped form. We now use Utf8JsonWriter.WriteStringValue which does the escaping |
When data is added, the Chinese in Json column is escaped.
If you edit this record, the Chinese in the Json column will not be escaped.
Whether there is a parameter configuration that allows us to define whether Chinese is escaped.
Include provider and version information
EF Core version:7.02
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0)
Operating system:Windows 11
IDE: Visual Studio 2022 17.5.0 Preview 6.0
The text was updated successfully, but these errors were encountered: