diff --git a/src/types/redis_geo.cc b/src/types/redis_geo.cc index cc8173e6175..37adc35d374 100644 --- a/src/types/redis_geo.cc +++ b/src/types/redis_geo.cc @@ -188,7 +188,7 @@ rocksdb::Status Geo::Get(const Slice &user_key, const Slice &member, GeoPoint *g auto iter = geo_points.find(member.ToString()); if (iter == geo_points.end()) { - return rocksdb::Status::NotFound(); + return rocksdb::Status::InvalidArgument("could not decode requested zset member"); } *geo_point = iter->second; return rocksdb::Status::OK(); diff --git a/tests/gocase/unit/geo/geo_test.go b/tests/gocase/unit/geo/geo_test.go index fe7bb199695..6db8c222a41 100644 --- a/tests/gocase/unit/geo/geo_test.go +++ b/tests/gocase/unit/geo/geo_test.go @@ -136,6 +136,18 @@ func TestGeo(t *testing.T) { require.EqualValues(t, []interface{}([]interface{}{}), rdb.Do(ctx, "GEORADIUSBYMEMBER_RO", "points", "member", "1", "km").Val()) }) + t.Run("GEORADIUSBYMEMBER against non existing member", func(t *testing.T) { + require.NoError(t, rdb.Do(ctx, "DEL", "src", "dst").Err()) + + require.NoError(t, rdb.Do(ctx, "GEOADD", "src", "10", "10", "Shenzhen").Err()) + require.Error(t, rdb.Do(ctx, "GEORADIUSBYMEMBER", "src", "Shenzhen_2", 20, "M").Err()) + + require.NoError(t, rdb.Do(ctx, "GEOADD", "dst", "20", "20", "Guangzhou").Err()) + require.Error(t, rdb.Do(ctx, "GEORADIUSBYMEMBER", "src", "Shenzhen_2", 20, "M", "STORE", "dst").Err()) + // Verify command does not affect dst + require.EqualValues(t, 1, rdb.Exists(ctx, "dst").Val()) + }) + t.Run("GEORADIUSBYMEMBER store: remove the dst key when there is no result set", func(t *testing.T) { require.NoError(t, rdb.Do(ctx, "DEL", "src", "dst").Err()) @@ -244,6 +256,18 @@ func TestGeo(t *testing.T) { require.EqualValues(t, 0, rdb.Do(ctx, "GEOSEARCHSTORE", "dst", "src", "FROMMEMBER", "Shenzhen", "BYBOX", 88, 88, "m").Val()) }) + t.Run("GEOSEARCH / GEOSEARCHSTORE FROMMEMBER against non existing member", func(t *testing.T) { + require.NoError(t, rdb.Do(ctx, "DEL", "src", "dst").Err()) + + require.NoError(t, rdb.Do(ctx, "GEOADD", "src", "10", "10", "Shenzhen").Err()) + require.Error(t, rdb.Do(ctx, "GEOSEARCH", "src", "FROMMEMBER", "Shenzhen_2", "BYBOX", 88, 88, "M").Err()) + + require.NoError(t, rdb.Do(ctx, "GEOADD", "dst", "20", "20", "Guangzhou").Err()) + require.Error(t, rdb.Do(ctx, "GEOSEARCHSTORE", "dst", "src", "FROMMEMBER", "Shenzhen_2", "BYBOX", 88, 88, "M").Err()) + // Verify command does not affect dst + require.EqualValues(t, 1, rdb.Exists(ctx, "dst").Val()) + }) + t.Run("GEOSEARCHSTORE remove the dst key when there is no result set", func(t *testing.T) { require.NoError(t, rdb.Do(ctx, "del", "src", "dst").Err())