-
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
Don't escape separator characters in single key values #35252
base: main
Are you sure you want to change the base?
Conversation
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.
@@ -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 }, |
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.
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); |
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.
AppendValue(_discriminatorProperty!, _discriminatorValue!, false); | |
AppendValue(_discriminatorProperty!, _discriminatorValue!, singleValue: false); |
builder = builder.Replace("|", "^|", startingIndex, builder.Length - startingIndex); | ||
} | ||
|
||
return builder |
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.
We should just let Cosmos throw for the invalid characters in single value mode to preserve the 1:1 doctrine.
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.