From a64b29485d4f2359b9d698c0e21e890a212ad1bb Mon Sep 17 00:00:00 2001 From: Steve Lorello <42971704+slorello89@users.noreply.github.com> Date: Sat, 25 Jun 2022 12:02:20 -0400 Subject: [PATCH] changing min,max in ZRANGE -> start stop (#10097) In 6.2.0 with the introduction of the REV subcommand in ZRANGE, there was a semantic shift in the arguments of ZRANGE when the REV sub-command is executed. Without the sub-command `min` and `max` (the old names of the arguments) are appropriate because if you put the min value and the max value in everything works fine. ```bash 127.0.0.1:6379> ZADD myset 0 foo (integer) 1 127.0.0.1:6379> ZADD myset 1 bar (integer) 1 127.0.0.1:6379> ZRANGE myset 0 inf BYSCORE 1) "foo" 2) "bar" ``` However - if you add the `REV` subcommand, ordering the arguments `min` `max` breaks the command: ```bash 127.0.0.1:6379> ZRANGE myset 0 inf BYSCORE REV (empty array) ``` why? because `ZRANGE` with the `REV` sub-command is expecting the `max` first and the `min` second (because it's a reverse range like `ZREVRANGEBYSCORE`): ```bash 127.0.0.1:6379> ZRANGE myset 0 inf BYSCORE REV (empty array) ``` --- src/commands.c | 4 ++-- src/commands/zrange.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands.c b/src/commands.c index 1e40b5e54..d581d02be 100644 --- a/src/commands.c +++ b/src/commands.c @@ -5812,8 +5812,8 @@ struct redisCommandArg ZRANGE_offset_count_Subargs[] = { /* ZRANGE argument table */ struct redisCommandArg ZRANGE_Args[] = { {"key",ARG_TYPE_KEY,0,NULL,NULL,NULL,CMD_ARG_NONE}, -{"min",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_NONE}, -{"max",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_NONE}, +{"start",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_NONE}, +{"stop",ARG_TYPE_STRING,-1,NULL,NULL,NULL,CMD_ARG_NONE}, {"sortby",ARG_TYPE_ONEOF,-1,NULL,NULL,"6.2.0",CMD_ARG_OPTIONAL,.subargs=ZRANGE_sortby_Subargs}, {"rev",ARG_TYPE_PURE_TOKEN,-1,"REV",NULL,"6.2.0",CMD_ARG_OPTIONAL}, {"offset_count",ARG_TYPE_BLOCK,-1,"LIMIT",NULL,"6.2.0",CMD_ARG_OPTIONAL,.subargs=ZRANGE_offset_count_Subargs}, diff --git a/src/commands/zrange.json b/src/commands/zrange.json index 1c7232a95..63fb01a09 100644 --- a/src/commands/zrange.json +++ b/src/commands/zrange.json @@ -45,11 +45,11 @@ "key_spec_index": 0 }, { - "name": "min", + "name": "start", "type": "string" }, { - "name": "max", + "name": "stop", "type": "string" }, {