-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSON.MSET #944
Add JSON.MSET #944
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #944 +/- ##
==========================================
+ Coverage 81.45% 81.53% +0.07%
==========================================
Files 15 15
Lines 3894 3954 +60
==========================================
+ Hits 3172 3224 +52
- Misses 722 730 +8
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments.
REDIS_OK | ||
} | ||
|
||
fn apply_updates<M: Manager>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure, you just extracted the code above into a function right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one change, the for ui in update_info
now doesn't stop on the first error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the for ui in update_info now doesn't stop on the first error
Consider testing that a specific change, which cannot be done, does not prevent apply_changes
for previously done changes, e.g., once first change is done, second cannot be done, but third should be done as well.
json.set a $ '{"x": {"y":[10,20], "z":[30,40]}}'
json.set b $ '{"x": 60}'
json.mset a $.x '{}' a '$.x.z[1]' '50' b $.x '70'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also on the same key
json.mset a $.x '{}' a '$.x.z[1]' '50' a $.u '70'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is also fixed for json_set
- now it may notify on a similar scenario with multi-value (using wildcards, etc.) , while it did not notify before - could affect RediSearch results for example, but this would be a progression and is not considered a breaking change.
Agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes #821
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example for the problem with a single json.set
(using RediSearch as a subscriber for keyspace notifications)
127.0.0.1:6379> json.set k1 $ '{"x":{"x":{"y":[4,5,6]}}}'
OK
127.0.0.1:6379> ft.create idx on json schema '$..y[*]' as y numeric
OK
127.0.0.1:6379> ft.search idx '@y:[4 5]'
1) (integer) 1
2) "k1"
3) 1) "$"
2) "{\"x\":{\"x\":{\"y\":[4,5,6]}}}"
The following json.set
was failing in the middle and not notifying on changes, so the index was not being updated causing search to return a stale result:
127.0.0.1:6379> json.set k1 '$..x' '1'
(nil)
127.0.0.1:6379> json.get k1 $
"[{\"x\":1}]"
127.0.0.1:6379> ft.search idx '@y:[4 5]'
1) (integer) 1
2) "k1"
3) 1) "$"
2) "{\"x\":1}"
With this PR it should be fixed ☝🏼 (search should return an empty result)
And once RediSearch/RediSearch#3507 is merged, it should also work with json.mset
, e.g.,
json.mset k1 $ '{"x":{"x":{"y":[4,5,6]}}}' k1 '$..x' '1'
And then ft.search idx '@y:[4 5]'
should return an empty result
And with
json.mset k1 $ '{"x":{"x":{"y":[4,5,6]}}}' k1 '$..x' '1' k1 '$.y' '[4, 5, 6]'
The same search should return k1.
I suppose such tests should be added to RediSearch/RediSearch#3507
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gkorland Keyspace notification can also be tested in this PR (without RediSearch) as in
def test_keyspace_set(env): |
src/commands.rs
Outdated
!update_info.is_empty() && apply_updates::<M>(&mut redis_key, value, update_info) | ||
} else { | ||
// In case it is a root path | ||
redis_key.set_value(Vec::new(), value).unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redis_key.set_value(Vec::new(), value).unwrap() | |
redis_key.set_value(Vec::new(), value).expect("<Some informative message>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced it with a fold so if one fails an error will be returned
@@ -30,6 +30,12 @@ def test_keyspace_set(env): | |||
assert_msg(env, pubsub.get_message(timeout=1), 'pmessage', 'json.set') | |||
assert_msg(env, pubsub.get_message(timeout=1), 'pmessage', 'test_key') | |||
|
|||
env.assertEqual('OK', r.execute_command('JSON.MSET', 'test_key', '$.foo', '"gogo"', 'test_key{test_key}', '$', '{"a":"fufu"}')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E501: line too long (135 > 79 characters)
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
Command | Usage |
---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
assert_msg(env, pubsub.get_message(timeout=1), 'pmessage', 'json.mset') | ||
assert_msg(env, pubsub.get_message(timeout=1), 'pmessage', 'test_key') | ||
assert_msg(env, pubsub.get_message(timeout=1), 'pmessage', 'json.mset') | ||
assert_msg(env, pubsub.get_message(timeout=1), 'pmessage', 'test_key{test_key}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E501: line too long (88 > 79 characters)
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
Command | Usage |
---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
No description provided.