Python: adds JSON.ARRAPPEND command - #2382
Conversation
| Examples: | ||
| >>> from glide import json as valkeyJson | ||
| >>> import json | ||
| >>> await redisJson.set(client, "doc", "$", '{"a": 1, "b": ["one", "two"]}') |
There was a problem hiding this comment.
| >>> await redisJson.set(client, "doc", "$", '{"a": 1, "b": ["one", "two"]}') | |
| >>> await valkeyJson.set(client, "doc", "$", '{"a": 1, "b": ["one", "two"]}') |
There was a problem hiding this comment.
need to fix all this doc
| For legacy path (`path` doesn't start with `$`): | ||
| Returns the length of the new array after appending `values` to the array at `path`. | ||
| If multiple paths match, the length of the last updated array is returned. | ||
| If the JSON value at `path` is not a array of if `path` doesn't exist, an error is raised. |
There was a problem hiding this comment.
| If the JSON value at `path` is not a array of if `path` doesn't exist, an error is raised. | |
| If the JSON value at `path` is not a array or if `path` doesn't exist, an error is raised. |
| ) -> TJsonResponse[int]: | ||
| """Appends one or more `values` to the JSON array at the specified `path` within the JSON document stored at `key`. | ||
|
|
||
| See https://valkey.io/commands/json.append/ for more details. |
There was a problem hiding this comment.
This link is not found. Do we use https://redis.io/docs/latest/commands/json.arrappend/ instead?
There was a problem hiding this comment.
forgot to remove it, you can ignore
|
Please update CHANGELOG too. |
| client: TGlideClient, | ||
| key: TEncodable, | ||
| values: List[TEncodable], | ||
| path: Optional[TEncodable] = None, |
There was a problem hiding this comment.
path is not optional for JSON.ARRAPPEND. Ref: https://docs.aws.amazon.com/memorydb/latest/devguide/json-arrappend.html
There was a problem hiding this comment.
True, but it is optional is redis , wasn't sure what I'm supposed to do 🙁
There was a problem hiding this comment.
I think we should ignore redis impl for the module
Adding at the end of every pr |
Signed-off-by: Shoham Elias <shohame@amazon.com>
Signed-off-by: Shoham Elias <shohame@amazon.com>
0ca5d32 to
44f7d7f
Compare
ikolomi
left a comment
There was a problem hiding this comment.
On condition that not having path as Optional is not a bug
| async def arrappend( | ||
| client: TGlideClient, | ||
| key: TEncodable, | ||
| path: TEncodable, |
There was a problem hiding this comment.
why isnt the path an optional per docs?
There was a problem hiding this comment.
optional in redis, not aws, the decision was to stick with aws implementation
There was a problem hiding this comment.
Can you explain that?
If I'm using json with a regular Valkey-server with json, not cloud provided server, is it optional?
There was a problem hiding this comment.
it is, not sure what to do
There was a problem hiding this comment.
As I see it, optional. It doesn't block AWS users, they just need to have it documented to know that for them, it's a must.
We would rather not block other user types. Tomorrow we might have some user open an issue on it.
If there's a real conflict between implementations, we can discuss with what to stick or create two APIs for the different cases.
But we would rather support all cases when those are possible together with no real issue.
Misuse is always possible, like users with a lower version using the API available in a higher version. We don't block all users from using the API, since we have some version preferences.
We can consider more sophisticated ways if you think it's not perfect, but it requires some thinking.
There was a problem hiding this comment.
In particular, the usage of this command without path is quite a narrow case: it indicates that the entire JSON is just an array at its root. I would say this is, to some degree, the justification of AWS JSON module making path mandatory.
Signed-off-by: Shoham Elias <116083498+shohamazon@users.noreply.github.com>
Signed-off-by: Shoham Elias <shohame@amazon.com>
--------- Signed-off-by: Shoham Elias <shohame@amazon.com> Signed-off-by: Shoham Elias <116083498+shohamazon@users.noreply.github.com>
No description provided.