diff options
author | shacharPash <93581407+shacharPash@users.noreply.github.com> | 2023-04-30 04:13:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-30 04:13:54 +0300 |
commit | 8b58ebb73e03970fade4d3f9e2c961831713c228 (patch) | |
tree | 6f24c2c1249b91c136d329805cf765c9982fe817 | |
parent | 8e0b84d8a25c90070817c911af266cd5cabe1604 (diff) | |
download | redis-py-8b58ebb73e03970fade4d3f9e2c961831713c228.tar.gz |
return response in case of KeyError (#2628)
* return response in case of KeyError
* fix code linters error
* fix linters 2
* fix linters 3
-rwxr-xr-x | redis/client.py | 11 | ||||
-rw-r--r-- | tests/test_commands.py | 6 |
2 files changed, 13 insertions, 4 deletions
diff --git a/redis/client.py b/redis/client.py index 1a9b96b..79a7bff 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 94249e9..a44dac4 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -3509,6 +3509,12 @@ class TestRedisCommands: 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") + ( 2.1873744593677, |