ALERT: Savant 0.5.1 release fixes a serious data corruption issue

Coordinator
Jun 17, 2010 at 9:36 PM
Edited Jun 17, 2010 at 9:37 PM

Today's 0.5.1 point release fixes a serious data-corruption issue that occurs when using the partial-put methods (SimpleSavant.PutAttributes).

Let's say we have a Person class that looks like this:

    public class Person
    {
        public string Name { get; set; }
        public string Address1 {get; set;}
        public string State {get; set;}
        [ItemName]
        public Guid Id { get; set; }
    }

We create and save an instance:

    var savant = new SimpleSavant(AwsAccessKeyId, AwsSecretAccessKey);
    var person = new Person {Name = "Jack Frost", Address1="12345 My Way"};
    savant.Put(person);

Later we need to set the State attribute that was initially left blank. We want to be efficient so we perform a partial-put of just the State:

var values = new PropertyValues(personId);
values["State"] = "Georgia";
savant.PutAttributes<Person>(values);

This sequence will result in the Name and Address1 attributes being overwritten with null values in Savant 0.5.

You may encounter the same issue with the typeless version of PutAttributes, depending on how you construct your item mapping. For example, the code below will not manifest the issue:

var mapping = ItemMapping.Create("Person", AttributeMapping.Create("Id", typeof(Guid)));
mapping.AttributeMappings.Add(AttributeMapping.Create("State", typeof(string)));
var values = new PropertyValues(personId);
values["State"] = "Georgia";
savant.PutAttributes(mapping, values);

However, this next code snippet will manifest the issue because the item mapping contains attribute mappings not found in the PropertyValues collection:

var mapping = ItemMapping.Create(typeof(Person));
var values = new PropertyValues(personId);
values["State"] = "Georgia";
savant.PutAttributes(mapping, values);