Skip to content

lettuce connection.execute("JSON.MGET", args) not working as expected #3308

@jochen-schuettler

Description

@jochen-schuettler

When we do

    List<byte[]> argList = new ArrayList<>();
    for (String key : keys) {
        argList.add(key.getBytes(UTF_8));
    }
    argList.add(".".getBytes(UTF_8));
    byte[][] args = argList.toArray(new byte[0][]);
    var result = connection.execute("JSON.MGET", args);

we get a Json array with one element, the result from the last key.

We expect results for all keys.

demo.zip

run the test should return more than the last key to show the problem

see lettuce Issue here - the problem was already analyzed from lettuce side and found to be within SDR:

"it's not actually a Lettuce problem ...
Currently spring-data-redis doesn't have native JSON API, so you are forced to use the RAW command API. spring-data-redis doesn't allow you to choose the output type for yourself, but makes the choice on your behalf. And in the current scenario - makes wrong choice - ByteArrayOutput, which as you already found returns you only one of the keys.
TLDR - you should raise this issue to SDR and from what i saw it should be easy solution for them - to fix the mapping for JSON MGET to some sort of ListOutput - currently in Lettuce we use JsonValueListOutput."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions