Repository navigation
Native Result.to_json(): write text outside ASCII as it is, as the JVM build does - #495
Merged
Merged
Conversation
…M build does The JVM build's to_json() is the engine's writer: a character outside ASCII is written as it is. The native build used json.dumps with its default ensure_ascii, so the same row was a different, longer text. It now writes with ensure_ascii=False and escapes U+2028, U+2029 and lone surrogates afterwards, so the text matches the JVM build and always has a UTF-8 form. A golden test with two, three and four byte characters runs on both wheels. The upgrade page states the changed text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Result.to_json()of the same row was different text on the two packages.arcadedb-jvmwrites a character outside ASCII as it is, andarcadedbwrote it as a\uescape, so the length, the bytes, and a hash of the text differed. The native build now writes the character as it is too. It keeps a\uescape only where the JVM build has one (control characters, U+2028, and U+2029), and for a lone surrogate, which has no UTF-8 form. The parsed values do not change.For a row with one string property:
to_json()arcadedbbefore{"s":"caf\u00e9 \ud83d\ude00"}arcadedbafter{"s":"café 😀"}arcadedb-jvm{"s":"café 😀"}Related issues
Closes #454. Refs #314.
Performance changes
None claimed, and I did not time it.
Docs
upgrading.adocstates the changed text under changed behaviour, anddatabases-and-queries.adocsays howto_json()writes a string.Checklist
test_to_json_text_outside_ascii_goldenruns on both wheels in CI; the old native call writes the escapes shown above, which the expected text does not have)uvx pre-commit run --files <changed files>passes