We're aware of this bug. I'm not myself sure of the best way to fox it, though.
In the meantime, of you touch resource.attributes before making your changes, everything should work as expected. Bernerd Schaefer Sent from my iPhone On Nov 28, 2008, at 10:27 PM, "Gary Yngve" <[EMAIL PROTECTED]> wrote: > dm-core.0.9.7 > All the properties of a resource are loaded but one that's lazy. > You change in memory one of the property's loaded values, but that > change is reverted when you access the final lazy-loaded property. > > Here is a unit test to repro the bug: > > it "should not overwrite modified, already loaded, > columns" do > repository(ADAPTER) do > nancy = Zebra.first > k = nancy.age > nancy.age = k+1 > nancy.notes # notes is type text, so lazy-loaded > nancy.age.should == k+1 > end > end > > 'DataMapper::Collection (loaded) with lazy loading should not > overwrite modified, already loaded, columns' FAILED > expected: 12, > got: 11 (using ==) > > The source of the bug is that the query to load nancy.notes looks > good (fields is just [id, notes]), but when scoped_query gets called > from all(:reload=>true), a new query with the fields => default > properties (all of them) is merged onto the nice query, so all > fields are reloaded. > > I don't think this is an easy fix (especially for a DM neophyte as > myself) because of the intricacies of eager/lazy loading, but I > think it's extremely dangerous as-is because the behavior is so > unexpected. > > -Gary > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
