-
Notifications
You must be signed in to change notification settings - Fork 900
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
FIX: sort strings in UTF-8 encoded byte order #8691
base: main
Are you sure you want to change the base?
Conversation
|
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1This report is too large (508,382 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.Test Logs |
@@ -74,6 +74,22 @@ export interface Equatable<T> { | |||
isEqual(other: T): boolean; | |||
} | |||
|
|||
/** Compare strings in UTF-8 encoded byte order */ | |||
export function compareUtf8Strings(left: string, right: string): number { |
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.
comparison function added here to avoid circular dependency.
For PRs, please add information to the PR summary as to why this change is being made including any internal b/ tickets or any external GH issues that are associated with it so, later, if something goes wrong, we can reference the information. Also could you add a patch-level changeset since this a behavioral change? |
Strings should be sorted in UTF-8 encoded byte order. Public document: https://cloud.google.com/firestore/docs/concepts/data-types#data_types
SDK sorts strings using built in comparator method, which sorts lexicographically, and leads to mismatch between server and sdk when special characters are present. This PR fixes the string order mismatches on document field, map key, and document key.
Remaining bug: when document keys include special characters, reading docs from IndexedDB with order fields (other than document ID) will miss some documents as indexedDB uses lexicographical order.