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
Handle delete of empty list of keys #998
Conversation
handle empty list
Please advise as to how to test. Thanks |
lib/redis.rb
Outdated
if keys.is_a?(Array) && keys.empty? | ||
return 0 | ||
end |
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.
if keys.is_a?(Array) && keys.empty? | |
return 0 | |
end | |
return 0 if keys.empty? |
keys
can't be anything else than an array.
redis-rb/test/commands_on_value_types_test.rb Lines 10 to 24 in 6542934
|
applied suggested improvement and tests
@@ -30,6 +32,8 @@ def test_del_with_array_argument | |||
|
|||
assert_equal ["bar", "baz", "foo"], r.keys("*").sort | |||
|
|||
assert_equal 0, r.del([]) |
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.
This isn't handled by your code, you need to add a keys.flatten!
in del
.
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.
Or even flatten!(1)
Thanks @byroot for the review and feedback! |
Handle deletion of an empty list of keys