diff options
author | Alex Schmitz <alex.schmitz@gmail.com> | 2023-03-15 04:33:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 11:33:38 +0200 |
commit | b546a9a81c374b054835a5eeda9b580344d78dfd (patch) | |
tree | 6d5e3a89ec63adff4a55fe6d63a4ff26aa05eaae /redis/commands/json/commands.py | |
parent | 6c708c2e0511364c2c3f21fa1259de05e590632d (diff) | |
download | redis-py-b546a9a81c374b054835a5eeda9b580344d78dfd.tar.gz |
update json().arrindex() default values (#2611)
* update json().arrindex() default values
* add unit test
* fix falsy checks
* more unit tests
* add asyncio tests
* fix lint line length
---------
Co-authored-by: Alex Schmitz <aschmitz@box.com>
Diffstat (limited to 'redis/commands/json/commands.py')
-rw-r--r-- | redis/commands/json/commands.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/redis/commands/json/commands.py b/redis/commands/json/commands.py index 7fd4039..c02c47a 100644 --- a/redis/commands/json/commands.py +++ b/redis/commands/json/commands.py @@ -31,8 +31,8 @@ class JSONCommands: name: str, path: str, scalar: int, - start: Optional[int] = 0, - stop: Optional[int] = -1, + start: Optional[int] = None, + stop: Optional[int] = None, ) -> List[Union[int, None]]: """ Return the index of ``scalar`` in the JSON array under ``path`` at key @@ -43,9 +43,13 @@ class JSONCommands: For more information see `JSON.ARRINDEX <https://redis.io/commands/json.arrindex>`_. """ # noqa - return self.execute_command( - "JSON.ARRINDEX", name, str(path), self._encode(scalar), start, stop - ) + pieces = [name, str(path), self._encode(scalar)] + if start is not None: + pieces.append(start) + if stop is not None: + pieces.append(stop) + + return self.execute_command("JSON.ARRINDEX", *pieces) def arrinsert( self, name: str, path: str, index: int, *args: List[JsonType] |