feat(redis): edit JSON values as source with compact saves#3460
Conversation
Allow string keys, hash fields, and native RedisJSON to be edited in a foldable source editor, validate/compact on save, keep large numeric literals lossless end-to-end, and protect unsaved drafts from refresh. Close t8y2#3371
t8y2
left a comment
There was a problem hiding this comment.
I'm going to request changes for now. The compact-save path is not lossless for Redis string and hash JSON values.
normalizeRedisJsonDraft uses safeJsonFormat, which reconstructs the document through JSON.parse and JSON.stringify. The editor baseline is formatted through the same path. As a result, valid source such as:
{"role":"reader","role":"writer"}
is silently changed to:
{"role":"writer"}
before it is written back. Redis string and hash values are raw text, and this feature is expected to remove only non-data whitespace, so an unrelated edit must not delete duplicate object members.
Please use a source-preserving JSON validation/formatting and minification path, and add regression coverage for duplicate members in both string and hash JSON editors.
Use a source-preserving JSON pretty/minify path for Redis string, hash, and RedisJSON editors so compact saves only strip insignificant whitespace and keep duplicate object members. Add regression coverage for both string and hash open+save flows.
已改为 source-preserving 的 formatJsonSource():只校验并重排空白,不再走 JSON.parse/stringify,因此不会丢掉重复 key。 回归测试覆盖 reviewer 的 {"role":"reader","role":"writer"} fixture, 以及 string SET / hash HSET 两条保存路径。 |
|
Thanks for the contribution! Merged in ceadf73, will be released in the next version. |
变更说明
实现 Redis JSON 值的源码编辑与无损读写:
JSON.GET原始文本,避免大整数/高精度数字被 JS 解析丢失变更类型
涉及前端
验证
make check通过make cargo-check-fast通过补充验证:
手动建议:
关联 Issue
Close #3371