Skip to content

Commit

Permalink
Uppercase commands in CommandsParser.get_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
falk-h committed Jun 16, 2022
1 parent bedf3c8 commit d2f705e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Compare commands case-insensitively in the asyncio command parser
* Allow negative `retries` for `Retry` class to retry forever
* Add `items` parameter to `hset` signature
* Create codeql-analysis.yml (#1988). Thanks @chayim
Expand Down
6 changes: 3 additions & 3 deletions redis/asyncio/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ async def get_keys(self, *args: Any) -> Optional[Tuple[str, ...]]:
return None

try:
command = self.commands[args[0]]
command = self.commands[args[0].upper()]
except KeyError:
# try to split the command name and to take only the main command
# e.g. 'memory' for 'memory usage'
args = args[0].split() + list(args[1:])
cmd_name = args[0]
cmd_name = args[0].upper()
if cmd_name not in self.commands:
# We'll try to reinitialize the commands cache, if the engine
# version has changed, the commands may not be current
await self.initialize()
if cmd_name not in self.commands:
raise RedisError(
f"{cmd_name.upper()} command doesn't exist in Redis commands"
f"{cmd_name} command doesn't exist in Redis commands"
)

command = self.commands[cmd_name]
Expand Down

0 comments on commit d2f705e

Please sign in to comment.