Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,8 @@ impl<'a> WriteHolder<Value, Value> for KeyHolderWrite<'a> {

fn delete_path(&mut self, path: Vec<String>) -> Result<bool, RedisError> {
let mut deleted = false;
update(&path, self.get_value().unwrap().unwrap(), |v| {
if !v.is_null() {
deleted = true; // might delete more than a single value
}
update(&path, self.get_value().unwrap().unwrap(), |_v| {
deleted = true; // might delete more than a single value
Ok(None)
})?;
Ok(deleted)
Expand Down
6 changes: 2 additions & 4 deletions src/redisjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,8 @@ impl RedisJSON {

pub fn delete_path(&mut self, path: &str) -> Result<usize, Error> {
let mut deleted = 0;
self.data = jsonpath_lib::replace_with(self.data.take(), path, |v| {
if !v.is_null() {
deleted += 1; // might delete more than a single value
}
self.data = jsonpath_lib::replace_with(self.data.take(), path, |_v| {
deleted += 1; // might delete more than a single value

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is not needed right?

None
})?;
Ok(deleted)
Expand Down
7 changes: 7 additions & 0 deletions tests/pytest/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ def testDelCommand(env):
res = r.execute_command('JSON.DEL', 'doc2', '$[2,1,0]')
r.assertGreater(res, 0)

# Test deleting a null value
r.assertOk(r.execute_command('JSON.SET', 'doc2', '$', '[ true, { "answer": 42}, null ]'))
res = r.execute_command('JSON.DEL', 'doc2', '[-1]')
r.assertEqual(res, 1)
res = r.execute_command('JSON.GET', 'doc2', '$')
r.assertEqual(json.loads(res), [[True, {"answer": 42}]])


def testForgetCommand(env):
"""Test REJSON.FORGET command"""
Expand Down