Support editing Redis hash fields - #7140
Conversation
t8y2
left a comment
There was a problem hiding this comment.
request changes: the current Redis hash field rename path is not safe enough to merge.
-
apps/desktop/src/components/redis/RedisValueViewer.vue:2043-2044implements rename as two independent requests:HSET newFieldfollowed byHDEL oldField. This overwrites an existing destination field, permits concurrent writes between the two commands, and leaves duplicate fields when the delete fails.Please move rename into one backend operation that atomically rejects destination collisions and updates/deletes the field through the same Direct/Cluster path. Preserve the original field TTL where supported, and add collision, TTL, partial-failure, and concurrency regressions.
-
RedisValueViewer.vue:2031trims the edited field before writing it. An existing field such as" user "is silently renamed to"user"even when only its value changes. Preserve the field bytes exactly instead of normalizing its identity. -
Field-only edits are not included in the dirty/draft state, so closing and reopening the detail view silently discards the edited field name. Include field changes in draft retention, refresh protection, and save-state tests.
Replace the client-side HSET+HDEL hash field rename with one backend EVAL that rejects destination collisions, preserves field TTL when supported, and rolls back partial writes. Stop trimming field identity on save, and keep field-name drafts in dirty/unsaved retention so close/reopen does not drop renames.
t8y2
left a comment
There was a problem hiding this comment.
Pushed a small follow-up at 7e06a7c.
The new field input uses t('redis.field'), but the redis namespace had no bare field key (only mongo does), so the placeholder and aria-label rendered the literal "redis.field". Added field to the redis sections of en.ts / zh-CN.ts / zh-TW.ts next to fieldRequired; other locales will be picked up by the i18n autofill workflow.
Checks run: vue-tsc --noEmit clean, oxlint zero warnings on the three locale files.
🌐 I18n autofill completed✅ Added translations for 1 new
|
|
Thanks for the contribution! Merged in 0f9d32e, will be released in the next version. |
变更说明
为 Redis Hash 成员详情增加 field 编辑能力,并按 review 要求改为安全的原子后端更新:
原子 rename / value 更新
前端不再用
HSET新 field 再HDEL旧 field 的两段请求。改为单一后端操作
redisHashFieldUpdate(Direct / Cluster 同一路径),在服务端用 一条 EVAL 完成:HTTL/HEXPIRE保留原 field TTL脚本内对后续失败做回滚/清理,避免留下双 field 或静默丢 TTL;权限不足时明确报错,不回退到非原子路径。
不规范化 field 身份
保存时不再对 field 名做
.trim()。例如已有" user "只改 value 时仍保持" user "。空 field 名(length === 0)仍拒绝。field 草稿进入 dirty / unsaved 保护
单独保留
memberFieldDraftBaseline,field-only 编辑参与memberFieldChanged/memberValueChanged/hasRetainedMemberDraft/hasUnsavedRedisDraft。关闭再打开详情不会静默丢掉未保存的 field 改名。变更类型
涉及前端
主要改动面
crates/dbx-core:hash_field_updateLua EVAL + Direct/Cluster opsdbx-web/src-tauri:/redis/hash-field-update与redis_hash_field_update命令apps/desktop:RedisValueViewer调api.redisHashFieldUpdate;field draft baseline;无 trimredisHashFieldUpdate)关联 Issue
Close #7129