Skip to content

Setting a value whose path is not yet in the object does not work if the JSONPath contains [*] #1306

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

Open
nnmm opened this issue Dec 19, 2024 · 2 comments

Comments

@nnmm
Copy link

nnmm commented Dec 19, 2024

Setting a value whose path does not yet exist in the object (but its parent does exist) should work, but it doesn't if there is a [*] in the JSON path.

Description

valkey-server:6379> JSON.SET mydoc $ '{"list": [{}]}'
OK
valkey-server:6379> JSON.SET mydoc $.list[*].fruit '"apple"'
(error) Err wrong static path

This behavior is inconsistent with what happens when the path already exists, which works:

valkey-server:6379> JSON.SET mydoc $ '{"list": [{"fruit": "pear"}]}'
OK
valkey-server:6379> JSON.SET mydoc $.list[*].fruit '"apple"'
OK

It also works if the [*] is replaced with [0]:

valkey-server:6379> JSON.SET mydoc $ '{"list": [{}]}'
OK
valkey-server:6379> JSON.SET mydoc $.list[*].fruit '"apple"'
(error) Err wrong static path

Installation details

OS: Arch linux, Kernel
Redis version: Valkey 7.2 (from DockerHub)
Architecture: x86-64
RedisJSON version: 2.8.4

@LiorKogan
Copy link
Member

Duplicate? #788

@nnmm
Copy link
Author

nnmm commented Dec 20, 2024

Duplicate? #788

Yes, seems to be the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants