New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: adds JSON.STRLEN, JSON.STRAPPEND commands #1187
base: main
Are you sure you want to change the base?
Conversation
Args: | ||
client (TRedisClient): The Redis client to execute the command. | ||
key (str): The key of the JSON document. | ||
path (Optional[str]): The JSONPath to specify. Default is root `$`. // TODO check (since when sending strlen "non_exiting" and strlen "non_exiting" . -> behaves the same) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when running the commands:
127.0.0.1:6379> json.strlen non_existing_key
(nil)
127.0.0.1:6379> json.strlen non_existing_key .
(nil)
127.0.0.1:6379> json.strlen non_existing_key $
(error) ERR could not perform this operation on a key that doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I am not really sure that default it $
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then remove the comment to what it defaults to, just say in the documentation that if not passed a default value will be used
dcfc7f6
to
83f1e04
Compare
83f1e04
to
bd2affb
Compare
CHANGELOG.md
Outdated
@@ -52,6 +52,7 @@ | |||
* Core: Enabled Cluster Mode periodic checks by default ([#1089](https://github.com/aws/glide-for-redis/pull/1089)) | |||
* Node: Added Rename command. ([#1124](https://github.com/aws/glide-for-redis/pull/1124)) | |||
* Python: Added JSON.TOGGLE command ([#1184](https://github.com/aws/glide-for-redis/pull/1184)) | |||
* Python: Added JSON.STRLEN, JSON.STAPPEND commands ([#1187](https://github.com/aws/glide-for-redis/pull/1187)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it up to the right version
path (Optional[str]): The JSONPath to specify. If not passed, a default value will be used. | ||
|
||
Returns: | ||
TJsonResponse[Optional[int]]: For JSONPath (`path` starts with `$`), returns a list of integer replies for every possible path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets simplify it by splitting the return to two sections:
Returns:
TJsonResponse[Optional[int]]:
For JSONPath (`path` starts with `$`):
Returns a list of integer replies for every possible path, indicating the length of the JSON string value, or None for JSON values matching the path that are not string. If `key` doesn't exist, an error is raised.
For legacy path (`path` doesn't start with `$`):
Returns the length of the JSON value at `path` or None if `key` doesn't exist. If the JSON value at `path` is not a string of if `path` doesn't exist, an error is raised, If `key` doesn't exist, None is returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do it for all
with pytest.raises(RequestError): | ||
assert await json.toggle(redis_client, "non_exiting_key", "$") | ||
|
||
@pytest.mark.parametrize("cluster_mode", [True, False]) | ||
@pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about tests without specifying path?
Args: | ||
client (TRedisClient): The Redis client to execute the command. | ||
key (str): The key of the JSON document. | ||
path (Optional[str]): The JSONPath to specify. If not passed, a default value will be used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets try to stick with the document in ElastiCache docs, if it fits also for OSS
https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/json-strlen.html
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.