subsonic / SubSonic-2.0

SubSonic 2.0 Home
http://subsonic.github.io/
Other
80 stars 45 forks source link

ODSController does not update nullable columns to null values #6

Open BeamRider opened 14 years ago

BeamRider commented 14 years ago

SubSonic 2.2.1

When using the Update method on ODSController (ie using GridView / FormView in an ASP.NET application) and passing null values to nullable columns, the nullable column value remains unchanged.

This is due to the way that update method instantiate the ActiveRecord to update:

    public void Update(Guid MyKey, ...)
    {
        MyItem item =  new MyItem();
        item.MarkOld();
        item.IsLoaded = true;
        ...
        item.Save(UserName);
    }

By creating an empty MyItem instance (all fields are null) and setting a nullable field to null doesn' t allow the column to finish in the DirtyColumns collection (see ActiveHelper GetUpdateCommand).