Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return response in case of KeyError #2628

Merged
merged 5 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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