Skip to content

Commit 8b58ebb

Browse files
authored
return response in case of KeyError (#2628)
* return response in case of KeyError * fix code linters error * fix linters 2 * fix linters 3
1 parent 8e0b84d commit 8b58ebb

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

redis/client.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,13 @@ def parse_geosearch_generic(response, **options):
518518
Parse the response of 'GEOSEARCH', GEORADIUS' and 'GEORADIUSBYMEMBER'
519519
commands according to 'withdist', 'withhash' and 'withcoord' labels.
520520
"""
521-
if options["store"] or options["store_dist"]:
522-
# `store` and `store_dist` cant be combined
523-
# with other command arguments.
524-
# relevant to 'GEORADIUS' and 'GEORADIUSBYMEMBER'
521+
try:
522+
if options["store"] or options["store_dist"]:
523+
# `store` and `store_dist` cant be combined
524+
# with other command arguments.
525+
# relevant to 'GEORADIUS' and 'GEORADIUSBYMEMBER'
526+
return response
527+
except KeyError: # it means the command was sent via execute_command
525528
return response
526529

527530
if type(response) != list:

tests/test_commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3508,6 +3508,12 @@ def test_geosearchstore_dist(self, r):
35083508
# instead of save the geo score, the distance is saved.
35093509
assert r.zscore("places_barcelona", "place1") == 88.05060698409301
35103510

3511+
@skip_if_server_version_lt("3.2.0")
3512+
def test_georadius_Issue2609(self, r):
3513+
# test for issue #2609 (Geo search functions don't work with execute_command)
3514+
r.geoadd(name="my-key", values=[1, 2, "data"])
3515+
assert r.execute_command("GEORADIUS", "my-key", 1, 2, 400, "m") == [b"data"]
3516+
35113517
@skip_if_server_version_lt("3.2.0")
35123518
def test_georadius(self, r):
35133519
values = (2.1909389952632, 41.433791470673, "place1") + (

0 commit comments

Comments
 (0)