Skip to content

Commit

Permalink
fix(geo): support case insensitive units (#4264)
Browse files Browse the repository at this point in the history
  • Loading branch information
andydunstall authored Dec 5, 2024
1 parent 17651b2 commit 63ccbbc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/server/zset_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1732,13 +1732,14 @@ void ZAddGeneric(string_view key, const ZParams& zparams, ScoredMemberSpan memb_
}

double ExtractUnit(std::string_view arg) {
if (arg == "M") {
const string unit = absl::AsciiStrToUpper(arg);
if (unit == "M") {
return 1;
} else if (arg == "KM") {
} else if (unit == "KM") {
return 1000;
} else if (arg == "FT") {
} else if (unit == "FT") {
return 0.3048;
} else if (arg == "MI") {
} else if (unit == "MI") {
return 1609.34;
} else {
return -1;
Expand Down Expand Up @@ -2719,8 +2720,7 @@ void ZSetFamily::GeoDist(CmdArgList args, const CommandContext& cmd_cntx) {
auto* rb = static_cast<RedisReplyBuilder*>(cmd_cntx.rb);

if (args.size() == 4) {
string unit = absl::AsciiStrToUpper(ArgS(args, 3));

string_view unit = ArgS(args, 3);
distance_multiplier = ExtractUnit(unit);
args.remove_suffix(1);
if (distance_multiplier < 0) {
Expand Down

0 comments on commit 63ccbbc

Please sign in to comment.