Skip to content
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

Fix returning wrong string range in getrange command #254

Merged
merged 2 commits into from
May 8, 2021
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
2 changes: 1 addition & 1 deletion src/redis_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class CommandGetRange: public Commander {
if (start_ > stop_) {
*output = Redis::NilString();
} else {
*output = Redis::BulkString(value.substr(start_, stop_+1));
*output = Redis::BulkString(value.substr(start_, stop_ - start_ + 1));
}
return Status::OK();
}
Expand Down
1 change: 1 addition & 0 deletions tests/tcl/tests/unit/type/string.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ start_server {tags {"string"}} {
test "GETRANGE against string value" {
r set mykey "Hello World"
assert_equal "Hell" [r getrange mykey 0 3]
assert_equal "ll" [r getrange mykey 2 3]
assert_equal "Hello World" [r getrange mykey 0 -1]
assert_equal "orld" [r getrange mykey -4 -1]
assert_equal "" [r getrange mykey 5 3]
Expand Down