Skip to content

Commit

Permalink
fix parse_slowlog_get (#2732)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvora-h authored May 8, 2023
1 parent 9370711 commit 093232d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,13 @@ def parse_item(item):
# an O(N) complexity) instead of the command.
if isinstance(item[3], list):
result["command"] = space.join(item[3])
result["client_address"] = item[4]
result["client_name"] = item[5]
else:
result["complexity"] = item[3]
result["command"] = space.join(item[4])
result["client_address"] = item[5]
result["client_name"] = item[6]
return result

return [parse_item(item) for item in response]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ def test_slowlog_get(self, r, slowlog):
# make sure other attributes are typed correctly
assert isinstance(slowlog[0]["start_time"], int)
assert isinstance(slowlog[0]["duration"], int)
assert isinstance(slowlog[0]["client_address"], bytes)
assert isinstance(slowlog[0]["client_name"], bytes)

# Mock result if we didn't get slowlog complexity info.
if "complexity" not in slowlog[0]:
Expand Down

0 comments on commit 093232d

Please sign in to comment.