From 093232d8b4cecaac5d8b15c908bd0f8f73927238 Mon Sep 17 00:00:00 2001 From: dvora-h <67596500+dvora-h@users.noreply.github.com> Date: Mon, 8 May 2023 13:09:28 +0300 Subject: [PATCH] fix parse_slowlog_get (#2732) --- redis/client.py | 4 ++++ tests/test_commands.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/redis/client.py b/redis/client.py index 79a7bff2a2..c43a388358 100755 --- a/redis/client.py +++ b/redis/client.py @@ -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] diff --git a/tests/test_commands.py b/tests/test_commands.py index 2b769be34d..4020f5e8a8 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -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]: