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

Query correctly serializes the input into a stream #576

Merged
merged 9 commits into from
Jul 24, 2019

Conversation

j82w
Copy link
Contributor

@j82w j82w commented Jul 19, 2019

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Closing issues

closes #575

@j82w j82w added bug Something isn't working QUERY labels Jul 19, 2019
@j82w j82w requested a review from kirillg as a code owner July 19, 2019 13:37
@j82w j82w self-assigned this Jul 19, 2019
@j82w j82w changed the title Fix a bug query uses property serializer for SQL query input Query uses correct default serializer for SQL query input Jul 19, 2019
…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.
@j82w j82w changed the title Query uses correct default serializer for SQL query input Query correctly serializes the query input into stream Jul 19, 2019
@j82w j82w changed the title Query correctly serializes the query input into stream Query correctly serializes the input into a stream Jul 22, 2019
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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

@kirankumarkolli kirankumarkolli merged commit d73c850 into master Jul 24, 2019
@kirankumarkolli kirankumarkolli deleted the users/jawilley/query_input_serialization branch July 24, 2019 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working QUERY
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error with ToStream using a custom CosmosSerializer
3 participants