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

GEO* units are case insensitive since 7.0 #357

Merged
merged 1 commit into from
Mar 8, 2024
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
2 changes: 1 addition & 1 deletion cmd_geo.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func withinRadius(members []ssElem, longitude, latitude, radius float64) []geoDi
}

func parseUnit(u string) float64 {
switch u {
switch strings.ToLower(u) {
case "m":
return 1
case "km":
Expand Down
2 changes: 1 addition & 1 deletion cmd_geo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func TestGeodist(t *testing.T) {
)
mustDo(t, c,
"GEODIST", "Sicily", "Palermo", "Catania", "miles",
proto.Error("ERR unsupported unit provided. please use m, km, ft, mi"),
proto.Error("ERR unsupported unit provided. please use M, KM, FT, MI"),
)
mustDo(t, c,
"GEODIST", "Sicily", "Palermo", "Catania", "m", "too many",
Expand Down
3 changes: 3 additions & 0 deletions integration/geo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func TestGeodist(t *testing.T) {
c.Do("GEODIST", "nosuch", "Catania", "Palermo")
c.DoRounded(2, "GEODIST", "Sicily", "Palermo", "Catania", "m")
c.Do("GEODIST", "Sicily", "Palermo", "Catania", "km")
c.Do("GEODIST", "Sicily", "Palermo", "Catania", "KM")
c.Do("GEODIST", "Sicily", "Palermo", "Catania", "mi")
c.DoRounded(2, "GEODIST", "Sicily", "Palermo", "Catania", "ft")
c.Do("GEODIST", "Sicily", "Palermo", "Palermo")
Expand All @@ -112,6 +113,7 @@ func TestGeodist(t *testing.T) {
c.Error("wrong number", "GEODIST", "Sicily")
c.Error("wrong number", "GEODIST", "Sicily", "Palermo")
c.Error("syntax error", "GEODIST", "Sicily", "Palermo", "Palermo", "miles", "too many")
c.Error("unsupported unit provided. please use M, KM, FT, MI", "GEODIST", "Sicily", "Palermo", "Catania", "foobar")
c.Do("SET", "string", "123")
c.Error("wrong kind", "GEODIST", "string", "a", "b")
})
Expand All @@ -128,6 +130,7 @@ func TestGeoradius(t *testing.T) {
"-73.98384899986625", "40.76172799961419", "50th St",
)
c.Do("GEORADIUS", "stations", "-73.9718893", "40.7728773", "4", "km")
c.Do("GEORADIUS", "stations", "-73.9718893", "40.7728773", "4", "KM")
c.Do("GEORADIUS", "stations", "1.0", "1.0", "1", "km")
c.Do("GEORADIUS", "stations", "-73.9718893", "40.7728773", "4", "ft", "WITHDIST")
c.Do("GEORADIUS", "stations", "-73.9718893", "40.7728773", "4", "m", "WITHDIST")
Expand Down
2 changes: 1 addition & 1 deletion redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const (
msgStreamIDTooSmall = "ERR The ID specified in XADD is equal or smaller than the target stream top item"
msgStreamIDZero = "ERR The ID specified in XADD must be greater than 0-0"
msgNoScriptFound = "NOSCRIPT No matching script. Please use EVAL."
msgUnsupportedUnit = "ERR unsupported unit provided. please use m, km, ft, mi"
msgUnsupportedUnit = "ERR unsupported unit provided. please use M, KM, FT, MI"
msgXreadUnbalanced = "ERR Unbalanced 'xread' list of streams: for each stream key an ID or '$' must be specified."
msgXgroupKeyNotFound = "ERR The XGROUP subcommand requires the key to exist. Note that for CREATE you may want to use the MKSTREAM option to create an empty stream automatically."
msgXtrimInvalidStrategy = "ERR unsupported XTRIM strategy. Please use MAXLEN, MINID"
Expand Down
Loading