Repository navigation
fix: keep raw values when editing JSON-looking items - #71
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ytkimirti
marked this pull request as ready for review
October 28, 2026 08:03
alitariksahin
approved these changes
Nov 11, 2026
This branch was successfully deployed
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.
Bug: Editing a zset score or hash value renamed the member/field, and values like
12345678901234567890or10.00were shown and saved wrong. The value editor wroteJSON.stringify(JSON.parse(value), null, 2)into the form for anything that parses as JSON, so the "edited" name no longer matched the stored one (remove + add) and numbers went through JS doubles.Fix: The form keeps the stored bytes; JSON is pretty-printed for display only.
Why each change
components/databrowser/components/display/input/format-json.ts: a formatter that only changes whitespace outside strings, so formatting can never alter numbers, escapes or key order the way parse + stringify does. It takes the native path when the value is already canonical compact JSON, where native formatting is lossless and faster.format-json.tsgetJSONSource/toStoredValue: the untouched formatted view maps back to the original bytes, so opening and saving without edits writes exactly what was stored. Edits to values stored compact are compacted again, so display indentation isn't saved into them.components/databrowser/components/display/input/use-field.tsx: the form value is now the stored value; the editor shows the formatted view, or after typing the exact typed text (kept together with the value it maps to, so the editor doesn't reformat under the cursor). This replaces the effects that overwrote the form with formatted JSON.components/databrowser/components/display/input/content-type-select.tsx:checkIsValidJSONmoved next to the formatter.format-json.test.ts: locks in lossless formatting (scalars, big numbers, key order) and the stored-value mapping.Repro:
ZADD z 100 '{"id":1}', openz, change only the score to 200, Save: the member is now the pretty-printed string.SET s 12345678901234567890: the editor shows12345678901234567000.Part of DX-3147