redis-om-dotnet
redis-om-dotnet copied to clipboard
Issue with Updating collections with new objects
There seems to be a weird issue with how diffs are being built when new objects are being added to arrays withing JSON objects, it seems like the nodes are not being created correctly.
@slorello89 , I think this is related to #169 ?
Just for reference, I will add my bug description as posted on discord.
Redis OM V0.2.3, docker image redis/redis-stack:6.2.4-v2
I have an Account class that contains an Id field (RedisIdField), a Title and an array of Payments. A Payment consists of a GUID and an Amount. Basically, an Account can have multiple Payments and I want to store these in Redis. When I add the first Payment to an existing Account that I got from the RedisCollection<Account>, the Payment is added successfully. But when I try to add another Payment item to the array the same way and do an Update(account), an error is thrown.
StackExchange.Redis.RedisServerException: ERR Error running script (call to f_118f0eee57ae15ddfd37bd680e8002358aaf7161): @userscript:5: WRONGTYPE wrong type of path value - expected scalar but found { "Id": "f66cfb7f-ca7b-4d12-8b17-5f895a0e636e", "Amount": 4.0 }
at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in //src/StackExchange.Redis/ConnectionMultiplexer.cs:line 1863
Workaround: However, I got it to work by neither using Update(account) nor Save(). When I do an _accounts.Insert(account) with an object that already exists in Redis, the nested Payments array is correctly stored. It looks like the whole object is simply overwritten.
Ref issue: RedisJSON/RedisJSON#886