Repository navigation
MOD-21735: Keep comma-named siblings when collapsing nested paths - #1726
Open
AvivDavid23 wants to merge 1 commit into
Open
AvivDavid23 wants to merge 1 commit into
AvivDavid23 wants to merge 1 commit into
Conversation
prepare_paths_for_updating joined path segments with "," and detected nesting by string prefix, so a member named "a,b" looked nested under "a" and was dropped from JSON.DEL / JSON.SET updates. Compare segments directly instead.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1726 +/- ##
==========================================
- Coverage 88.13% 88.12% -0.02%
==========================================
Files 18 18
Lines 6861 6852 -9
==========================================
- Hits 6047 6038 -9
Misses 814 814 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TalBarYakar
reviewed
Dec 1, 2026
TalBarYakar
left a comment
Contributor
There was a problem hiding this comment.
This scans all paths for each match, which gets expensive on large objects. In a local benchmark with 60k children, filtering went from ~3 ms to ~810 ms
This branch has not been 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.
Fixes #1711 (MOD-21735)
Problem
JSON.DELwith a recursive path left a member behind when its name contained a comma:JSON.SET k '$..*' 0had the same problem ("a,b"was not updated).Fix
prepare_paths_for_updatingremoves paths nested under another selected path. It joined each path's segments with","and checked string prefixes, so["a,b"]looked like["a"]+band was dropped. It now compares segments directly: a path is dropped only if another selected path is a shorter segment prefix of it. The joined strings and their numeric sort, used only for that check, are removed.This function is shared by
JSON.DEL,JSON.SETand auto-create path updates.Test plan
test_prepare_paths_for_updating_keeps_comma_named_siblings:["a"]and["a,b"]kept,["a","b"]dropped (failed before fix)testMutateCommaNamedSiblings: SET$..*updates both members; DEL$..*returns 2 and removes the key; real nesting still collapses (failed before fix)cargo test -p redis_json122/122;QUICK=1suite 376/376;cargo clippy/cargo fmt --checkcleanNote
Medium Risk
Changes shared path-deduplication logic for JSON mutation commands; behavior shift for keys with commas in member names, with targeted tests but broad call sites (DEL/SET/auto-create).
Overview
Fixes incorrect nested-path collapsing when object member names contain commas.
prepare_paths_for_updatingno longer joins segments into a string and tests prefix overlap; it marks a path for removal only when another selected path is a strictly shorter segment prefix (p.len() < path.len() && path.starts_with(p)).Because this helper is shared by
JSON.DEL,JSON.SET(via auto-create), and related multi-path mutations, recursive commands like$..*now update/delete bothaanda,binstead of skipping the sibling whose name looks like a nested path. True nesting (e.g.athenbas separate segments) is still collapsed to the ancestor.Adds a Rust unit test for comma-named siblings and a pytest flow covering
JSON.SET/JSON.DELwith$..*.Reviewed by Cursor Bugbot for commit 4fa36e5. Bugbot is set up for automated code reviews on this repo. Configure here.