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

Don't escape separator characters in single key values #35252

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ajcvickers
Copy link
Contributor

Fixes #35224

When we generate a key containing multiple values, then we escape the separator character if it is found in any of the values. However, we should not do this if the key is made up of a single value and so will have no separators.

Fixes #35224

When we generate a key containing multiple values, then we escape the separator character if it is found in any of the values. However, we should not do this if the key is made up of a single value and so will have no separators.
@ajcvickers ajcvickers requested a review from a team as a code owner December 2, 2024 16:30
@@ -102,6 +108,7 @@ public virtual ISetSource GetExpectedData()
{ typeof(HierarchicalPartitionKeyEntity), e => ((HierarchicalPartitionKeyEntity?)e)?.Id },
{ typeof(OnlyHierarchicalPartitionKeyEntity), e => ((OnlyHierarchicalPartitionKeyEntity?)e)?.Payload },
{ typeof(SinglePartitionKeyEntity), e => ((SinglePartitionKeyEntity?)e)?.Id },
{ typeof(Cat35224), e => ((Cat35224?)e)?.Id },
Copy link
Member

Choose a reason for hiding this comment

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

This looks like an ideal case of a non-shared test to me...

@@ -89,23 +89,24 @@ public virtual string GenerateIdString(IEnumerable<object?> values)

if (_discriminatorProperty != null)
{
AppendValue(_discriminatorProperty!, _discriminatorValue!);
AppendValue(_discriminatorProperty!, _discriminatorValue!, false);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
AppendValue(_discriminatorProperty!, _discriminatorValue!, false);
AppendValue(_discriminatorProperty!, _discriminatorValue!, singleValue: false);

builder = builder.Replace("|", "^|", startingIndex, builder.Length - startingIndex);
}

return builder
Copy link
Member

Choose a reason for hiding this comment

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

We should just let Cosmos throw for the invalid characters in single value mode to preserve the 1:1 doctrine.

@AndriySvyryd AndriySvyryd self-assigned this Dec 18, 2024
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.

Cosmos: EF Core 9 fails to find document with '|' character in it's id
3 participants