Skip to content

Conversation

@milaGGL
Copy link
Contributor

@milaGGL milaGGL commented Jan 6, 2025

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.

@product-auto-label product-auto-label bot added size: s Pull request size is small. api: firestore Issues related to the googleapis/nodejs-firestore API. labels Jan 6, 2025
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jan 7, 2025
@milaGGL milaGGL marked this pull request as ready for review January 10, 2025 15:43
@milaGGL milaGGL requested review from a team as code owners January 10, 2025 15:43
@milaGGL milaGGL changed the title sort strings in UTF-8 encoded byte order FIX: sort strings in UTF-8 encoded byte order Jan 13, 2025
@milaGGL milaGGL merged commit a2950e0 into main Jan 15, 2025
17 checks passed
@milaGGL milaGGL deleted the mila/fix-string-comparison branch January 15, 2025 18:28
dconeybe added a commit that referenced this pull request Jul 7, 2025
The semantics of this logic were originally fixed by #2275, but this fix
caused a material performance degradation, which was then improved by #2299
The performance was, however, still suboptimal, and this PR further improves the
speed back to close to its original speed and, serendipitously, simplifies the
algorithm too.

This commit is a port of firebase/firebase-js-sdk#9143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the googleapis/nodejs-firestore API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants