-
Notifications
You must be signed in to change notification settings - Fork 494
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
Query correctly serializes the input into a stream #576
Query correctly serializes the input into a stream #576
Conversation
Microsoft.Azure.Cosmos/src/Resource/Query/CosmosQueryClientCore.cs
Outdated
Show resolved
Hide resolved
…lizer for each parameter property value to serialize it. All other properties are converted using the internal serializer. This allows users custom settings to still handle values, but not break any of the backend contracts.
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs
Outdated
Show resolved
Hide resolved
writer.WritePropertyName("value"); | ||
|
||
// Use the user serializer for the parameter values so custom conversions are correctly handled | ||
using (Stream str = this.UserSerializer.ToStream(sqlParameter.Value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just use this methods:
https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_JsonSerializer_Serialize.htm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to use the user's serializer for the parameter value. The current JSON serializer is our default implementation. This way we don't expose SqlQuerySpec, and don't require the user to have custom logic to handle the query object format for the backend.
Pull Request Template
Description
SqlQuerySpec is internal and prevents users from serializing it breaking custom serializers. To fix this issue a custom serialization method was added to SqlQuerySpec. It will use the custom serializer for only the parameter property values. This allows date time handling and other custom serialization settings to be honored for the parameter values, and prevents those custom settings from breaking the expected format by the Cosmos service.
Type of change
Please delete options that are not relevant.
Closing issues
closes #575