Skip to content

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

@nnmm

Description

@nnmm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions