Skip to content

Commit

Permalink
return response in case of KeyError (#2628)
Browse files Browse the repository at this point in the history
* return response in case of KeyError

* fix code linters error

* fix linters 2

* fix linters 3
  • Loading branch information
shacharPash authored Apr 30, 2023
1 parent 8e0b84d commit 8b58ebb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 7 additions & 4 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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") + (
Expand Down

0 comments on commit 8b58ebb

Please sign in to comment.