Skip to content

Conversation

@uros-db
Copy link
Contributor

@uros-db uros-db commented Aug 12, 2024

What changes were proposed in this pull request?

Fix the following string expression to handle surrogate pairs properly:

  • StringRepeat

The issue has to do with counting surrogate pairs, which are single Unicode code points (and single UTF-8 characters), but are represented using 2 characters in UTF-16 (Java String).

Example of incorrect result (under UNICODE collation, but similar issues are noted for all ICU collations):

StringReplace("😄a", "a", "b") // returns: "😄ab" (incorrect), instead of: "😄b" (correct)

Why are the changes needed?

Currently, some string expressions are giving wrong results when working with surrogate pairs.

Does this PR introduce any user-facing change?

Yes, this expression will now work properly with surrogate pairs: repeat.

How was this patch tested?

New tests in CollationSupportSuite.

Was this patch authored or co-authored using generative AI tooling?

Yes.

@github-actions github-actions bot added the SQL label Aug 12, 2024
Copy link
Contributor Author

@uros-db uros-db left a comment

Choose a reason for hiding this comment

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

all checks good, marking as ready for review

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in e77c8fb Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants