Skip to content

Conversation

@leminh98
Copy link
Contributor

Pull Request Template

Description

This fix takes into account of custom serializer defined by users in CosmosClientOptions to serialize constant values during translation for LINQ queries.

Given an object:

public record MyItem
    {
        [JsonPropertyName("id")]
        public string Id { get; set; }

        [JsonPropertyName("project_id")]
        public string ProjectId { get; set; }
    }

which uses the System.Net.Json property attribute and custom System.Net.Json serializer

Consider the following query:
query = testContainer.GetItemLinqQueryable<MyItem>().Where(i => i == new MyItem() { ProjectId = "test", Id = "id1"});

before this fix, it would be translated to
{"query":"SELECT VALUE root FROM root WHERE (root = {\"Id\": \"id1\", \"ProjectId\": \"test\"})"}

which does not take into account of the custom serializer handling of the property attributes
After this fix, this would be correctly translated to
{"query":"SELECT VALUE root FROM root WHERE (root = {\"id\": \"id1\", \"project_id\": \"test\"})"}

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Closing issues

Closes #3207

sboshra
sboshra previously approved these changes Sep 30, 2022
Copy link
Contributor

@sboshra sboshra left a comment

Choose a reason for hiding this comment

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

:shipit:

@ealsur ealsur enabled auto-merge (squash) October 10, 2022 21:31
sboshra
sboshra previously approved these changes Oct 10, 2022
adityasa
adityasa previously approved these changes Oct 10, 2022
Copy link
Contributor

@adityasa adityasa left a comment

Choose a reason for hiding this comment

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

:shipit:

sboshra
sboshra previously approved these changes Oct 11, 2022
@leminh98 leminh98 dismissed stale reviews from sboshra and adityasa via 663ea3f October 11, 2022 16:12
@leminh98
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

ealsur
ealsur previously approved these changes Oct 12, 2022
sboshra
sboshra previously approved these changes Oct 12, 2022
@leminh98 leminh98 dismissed stale reviews from sboshra and ealsur via 4359ec7 October 12, 2022 21:02
Copy link
Contributor

@adityasa adityasa left a comment

Choose a reason for hiding this comment

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

:shipit:

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.

Calling GetItemLinqQueryable uses default serializer for user-provided values

8 participants