redis / NRedisStack

Redis Stack .Net client
MIT License
246 stars 39 forks source link

MSetAsync Set for one Property to null #347

Open kurtisane opened 2 weeks ago

kurtisane commented 2 weeks ago

Thanks for reporting an issue in NRedisStack! Please update the appropriate text below, as much data as possible really helps!

NRedisStack Version: 0.13.0

Redis Stack Version: 7.4.0-v1

Description:

When using MSetAsync and passing multiple KeyPathValues to it I can not pass in one KeyPathValue with null as value. I have a fix for this. I need to basically map null to "null", but this is inconsistend with the Set Command.

That one does not accept "null" but only null.

This array: image

Leads to this exception: StackExchange.Redis.RedisServerException: expected value at line 1 column 1 at NRedisStack.Auxiliary.ExecuteAsync(IDatabaseAsync db, SerializedCommand command) at NRedisStack.JsonCommandsAsync.MSetAsync(KeyPathValue[] KeyPathValueList)

atakavci commented 2 weeks ago

hi @kurtisane , thank you for using NRedisStack and letting us about the case your are experiencing. i was trying to reproduce the case with null values, yet not successful..

could you check if this exception shows up even when you drop the string value at index 0 in screenshot (the one starts with 2UZb_.....). i believe the issue is due to misuse of value field KeyPathValue type for string values. if that is the case, could you try to do something like below to handle the case for strings;

        values = new[]
             {
            new KeyPathValue("key1", "$.textField1", "\"someText\""),
            new KeyPathValue("key1", "$.textField2",  JsonValue.Create("someText")),
            new KeyPathValue("key1", "$.textField3", null),
        };