From 2ea2c1f7a699eda8c7aafba1c3b927d24a2b3ebe Mon Sep 17 00:00:00 2001 From: shacharPash Date: Sun, 19 Mar 2023 18:00:17 +0200 Subject: [PATCH 1/4] return response in case of KeyError --- redis/client.py | 11 +++++++---- tests/test_commands.py | 6 ++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/redis/client.py b/redis/client.py index 1a9b96b83d..dc22b5820a 100755 --- a/redis/client.py +++ b/redis/client.py @@ -518,10 +518,13 @@ def parse_geosearch_generic(response, **options): Parse the response of 'GEOSEARCH', GEORADIUS' and 'GEORADIUSBYMEMBER' commands according to 'withdist', 'withhash' and 'withcoord' labels. """ - if options["store"] or options["store_dist"]: - # `store` and `store_dist` cant be combined - # with other command arguments. - # relevant to 'GEORADIUS' and 'GEORADIUSBYMEMBER' + try: + if options["store"] or options["store_dist"]: + # `store` and `store_dist` cant be combined + # with other command arguments. + # relevant to 'GEORADIUS' and 'GEORADIUSBYMEMBER' + return response + except KeyError: # it means the command was sent via execute_command return response if type(response) != list: diff --git a/tests/test_commands.py b/tests/test_commands.py index 94249e9419..29bf7f9d0d 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -3508,6 +3508,12 @@ def test_geosearchstore_dist(self, r): # instead of save the geo score, the distance is saved. assert r.zscore("places_barcelona", "place1") == 88.05060698409301 + @skip_if_server_version_lt("3.2.0") + def test_georadius_Issue2609(self, r): + # test for issue #2609 (Geo search functions don't work with execute_command) + r.geoadd(name="my-key", values=[1, 2, "data"]) + assert r.execute_command("GEORADIUS", 'my-key', 1, 2, 400, "m") == [b"data"] + @skip_if_server_version_lt("3.2.0") def test_georadius(self, r): values = (2.1909389952632, 41.433791470673, "place1") + ( From 4dc79d9818df00387ec5bf9e13827ac83046cbf4 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Sun, 19 Mar 2023 18:07:12 +0200 Subject: [PATCH 2/4] fix code linters error --- redis/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis/client.py b/redis/client.py index dc22b5820a..79a7bff2a2 100755 --- a/redis/client.py +++ b/redis/client.py @@ -524,7 +524,7 @@ def parse_geosearch_generic(response, **options): # with other command arguments. # relevant to 'GEORADIUS' and 'GEORADIUSBYMEMBER' return response - except KeyError: # it means the command was sent via execute_command + except KeyError: # it means the command was sent via execute_command return response if type(response) != list: From 78357ba3dbd40bb0737fb705341285a6391d7349 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 20 Mar 2023 13:02:11 +0200 Subject: [PATCH 3/4] fix linters 2 --- tests/test_commands.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index 29bf7f9d0d..5d71044d91 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -3512,8 +3512,7 @@ def test_geosearchstore_dist(self, r): def test_georadius_Issue2609(self, r): # test for issue #2609 (Geo search functions don't work with execute_command) r.geoadd(name="my-key", values=[1, 2, "data"]) - assert r.execute_command("GEORADIUS", 'my-key', 1, 2, 400, "m") == [b"data"] - + assert r.execute_command("GEORADIUS", "my-key", 1, 2, 400, "m") == [b"data"] @skip_if_server_version_lt("3.2.0") def test_georadius(self, r): values = (2.1909389952632, 41.433791470673, "place1") + ( From 93f71a02103308bce689fcea8a083f4b557f12d3 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 20 Mar 2023 13:42:53 +0200 Subject: [PATCH 4/4] fix linters 3 --- tests/test_commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_commands.py b/tests/test_commands.py index 5d71044d91..a44dac42af 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -3513,6 +3513,7 @@ def test_georadius_Issue2609(self, r): # test for issue #2609 (Geo search functions don't work with execute_command) r.geoadd(name="my-key", values=[1, 2, "data"]) assert r.execute_command("GEORADIUS", "my-key", 1, 2, 400, "m") == [b"data"] + @skip_if_server_version_lt("3.2.0") def test_georadius(self, r): values = (2.1909389952632, 41.433791470673, "place1") + (