summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-06-27 09:43:47 +0200
committerantirez <antirez@gmail.com>2015-06-27 09:43:47 +0200
commitcd91beea1c11a37be9811260c16dfe8eb8e57e9e (patch)
treee664f22bcbe0f4c88fa88f710122c088bf73fc1c
parent710c05ac2ab0eedc56cc19ba16ad8fc40d24e81d (diff)
downloadredis-cd91beea1c11a37be9811260c16dfe8eb8e57e9e.tar.gz
Geo: only one way to specify any given option.
-rw-r--r--src/geo.c13
-rw-r--r--tests/unit/geo.tcl8
2 files changed, 11 insertions, 10 deletions
diff --git a/src/geo.c b/src/geo.c
index 72dadb885..1a90fa87b 100644
--- a/src/geo.c
+++ b/src/geo.c
@@ -413,6 +413,7 @@ void geoAddCommand(redisClient *c) {
#define RADIUS_MEMBER 2
/* GEORADIUS key x y radius unit [WITHDIST] [WITHHASH] [WITHCOORD] [ASC|DESC]
+ * [LIMIT count]
* GEORADIUSBYMEMBER key member radius unit ... options ... */
static void geoRadiusGeneric(redisClient *c, int type) {
robj *key = c->argv[1];
@@ -457,17 +458,17 @@ static void geoRadiusGeneric(redisClient *c, int type) {
int remaining = c->argc - base_args;
for (int i = 0; i < remaining; i++) {
char *arg = c->argv[base_args + i]->ptr;
- if (!strncasecmp(arg, "withdist", 8))
+ if (!strcasecmp(arg, "withdist")) {
withdist = 1;
- else if (!strcasecmp(arg, "withhash"))
+ } else if (!strcasecmp(arg, "withhash")) {
withhash = 1;
- else if (!strncasecmp(arg, "withcoord", 9))
+ } else if (!strcasecmp(arg, "withcoord")) {
withcoords = 1;
- else if (!strncasecmp(arg, "asc", 3))
+ } else if (!strcasecmp(arg, "asc")) {
sort = SORT_ASC;
- else if (!strncasecmp(arg, "desc", 4))
+ } else if (!strcasecmp(arg, "desc")) {
sort = SORT_DESC;
- else {
+ } else {
addReply(c, shared.syntaxerr);
return;
}
diff --git a/tests/unit/geo.tcl b/tests/unit/geo.tcl
index a049804ae..5544d6555 100644
--- a/tests/unit/geo.tcl
+++ b/tests/unit/geo.tcl
@@ -49,18 +49,18 @@ start_server {tags {"geo"}} {
} {{wtc one} 1791873972053020 {union square} 1791875485187452 {central park n/q/r} 1791875761332224 4545 1791875796750882 {lic market} 1791875804419201 q4 1791875830079666 jfk 1791895905559723}
test {GEORADIUS simple (sorted)} {
- r georadius nyc -73.9798091 40.7598464 3 km ascending
+ r georadius nyc -73.9798091 40.7598464 3 km asc
} {{central park n/q/r} 4545 {union square}}
- test {GEORADIUS withdistance (sorted)} {
- r georadius nyc -73.9798091 40.7598464 3 km withdistance ascending
+ test {GEORADIUS withdist (sorted)} {
+ r georadius nyc -73.9798091 40.7598464 3 km withdist asc
} {{{central park n/q/r} 0.7750} {4545 2.3651} {{union square} 2.7697}}
test {GEORADIUSBYMEMBER simple (sorted)} {
r georadiusbymember nyc "wtc one" 7 km
} {{wtc one} {union square} {central park n/q/r} 4545 {lic market}}
- test {GEORADIUSBYMEMBER withdistance (sorted)} {
+ test {GEORADIUSBYMEMBER withdist (sorted)} {
r georadiusbymember nyc "wtc one" 7 km withdist
} {{{wtc one} 0.0000} {{union square} 3.2544} {{central park n/q/r} 6.7000} {4545 6.1975} {{lic market} 6.8969}}