Skip to content

Commit

Permalink
fix: georadius should return empty set if the key does not exist (#845)
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinChamber authored Sep 11, 2022
1 parent 8a206b8 commit fa01b03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/redis_geo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ rocksdb::Status Geo::Radius(const Slice &user_key,
AppendNamespacePrefix(user_key, &ns_key);
ZSetMetadata metadata(false);
rocksdb::Status s = ZSet::GetMetadata(ns_key, &metadata);
if (!s.ok()) return s;
if (!s.ok()) return s.IsNotFound() ? rocksdb::Status::OK() : s;

/* Get all neighbor geohash boxes for our radius search */
GeoHashRadius georadius = GeoHashHelper::GetAreasByRadiusWGS84(longitude, latitude, radius_meters);
Expand Down
5 changes: 5 additions & 0 deletions tests/tcl/tests/unit/geo.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ start_server {tags {"geo"}} {
set e
} {*syntax*}

test {GEORADIUS missing key} {
r del points
assert_equal {} [r georadius points 13.361389 38.115556 50 km]
}

# test {GEOSEARCHSTORE STORE option: syntax error} {
# catch {r geosearchstore abc points fromlonlat 13.361389 38.115556 byradius 50 km store abc} e
# set e
Expand Down

0 comments on commit fa01b03

Please sign in to comment.