redis-om-dotnet icon indicating copy to clipboard operation
redis-om-dotnet copied to clipboard

Updating a collection that has been initialized with null is not working

Open zulander1 opened this issue 3 years ago • 1 comments

Spend a lot of time figuring this one out. This code does not update the collection if the property is null at insert, if the property is empty (i.e.: Array.Empty()) it will work.


var bob = new Customer
{
    Id = Guid.Parse("9f286de2-10ae-4366-aa35-d582b64f6f4d"),
    Age = 35,
    FirstName = "Bob",
    LastName = "Smith",
};
var customerOne = provider.RedisCollection<Customer>();
 
await customerOne.InsertAsync(bob);
var test1 = await customerOne.Where(x => x.Age == 35).ToListAsync(); // this is to have it in the snapshot!

bob.Tags = new[] { "some tag" };
await customerOne.UpdateAsync(bob);


[Document(StorageType = StorageType.Json)]
public class Customer
{
    [RedisIdField] public Guid Id { get; set; }
    [Indexed] public string FirstName { get; set; }
    [Indexed] public string[] Tags { get; set; }
    [Indexed] public string LastName { get; set; }
    [Indexed] public string Email { get; set; }
    [Indexed] public int Age { get; set; }
}

zulander1 avatar Sep 25 '22 20:09 zulander1

Oh wow that's weird, must be an issue with the way the diffs are being build. Will look into it.

slorello89 avatar Sep 26 '22 22:09 slorello89

@slorello89 hey do you think we fix this for the next release? I looked at it and I think we need to include JSON.ARRINSERT in the Lua script

zulander1 avatar Jan 05 '23 23:01 zulander1