Skip to content

Commit

Permalink
Use compact
Browse files Browse the repository at this point in the history
  • Loading branch information
swanson committed Feb 13, 2024
1 parent 0bf2705 commit eb68a92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/kredis/types/hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def []=(key, value)
end

def update(**entries)
hset entries.transform_values { |val| type_to_string(val, typed) } if entries.flatten.any?
hset entries.transform_values { |val| type_to_string(val, typed) }.compact if entries.flatten.any?
end

def values_at(*keys)
Expand Down
8 changes: 4 additions & 4 deletions test/types/hash_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ class HashTest < ActiveSupport::TestCase
assert_equal({ "space_invaders" => 100, "pong" => 42 }, @hash.to_h)
end

test "does not support nil values" do
assert_raises do
@hash.update("key" => nil)
end
test "handles nil values gracefully" do
@hash.update("key" => nil, "key2" => "value2")
assert_nil @hash["key"]
assert_equal "value2", @hash["key2"]
end
end

0 comments on commit eb68a92

Please sign in to comment.