#666 ✓resolved
Jan Kassens

update_attributes failing with lazyload

Reported by Jan Kassens | November 23rd, 2008 @ 05:16 AM

I've got this simple Model with a lazy loaded attribute and a non lazy loaded one.


class Snippet
  include DataMapper::Resource

  property :id, Serial

  property :title, String
  property :content, Text

end

If i'm trying to update_attributes both properties on that model only the content will be changed. Here's a small merb -i session:


>> s = Snippet.first
 ~ SELECT "id", "title" FROM "snippets" ORDER BY "id" LIMIT 1
=> #<Snippet id=1 title="1" content=<not loaded>>
>> s.update_attributes :title => 'new title', :content => 'new content'
 ~ SELECT "content", "id", "title" FROM "snippets" WHERE ("id" = 1) ORDER BY "id"
 ~ UPDATE "snippets" SET "content" = 'new content' WHERE ("id" = 1)
=> true
>> s
=> #<Snippet id=1 title="1" content="new content">

Note: this only happens if content was before. The lazy load could probably just be skipped when the property is being set and assumed it has changed?

Could be related to #663

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Referenced by

Pages