Skip to content

Commit e4cf767

Browse files
committed
Stringify value argument to SET
1 parent 61bb68f commit e4cf767

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/redis.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ def incrbyfloat(key, increment)
627627
# @return `"OK"`
628628
def set(key, value)
629629
synchronize do |client|
630-
client.call([:set, key, value])
630+
client.call([:set, key, value.to_s])
631631
end
632632
end
633633

test/lint/strings.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ def test_set_and_get_with_newline_characters
2626
assert_equal "1\n", r.get("foo")
2727
end
2828

29+
def test_set_and_get_with_non_string_value
30+
value = ["a", "b"]
31+
32+
r.set("foo", value)
33+
34+
assert_equal value.to_s, r.get("foo")
35+
end
36+
2937
def test_set_and_get_with_ascii_characters
3038
if defined?(Encoding)
3139
with_external_encoding("ASCII-8BIT") do

0 commit comments

Comments
 (0)