
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
-
Dan Kubb (dkubb) November 29th, 2008 @ 08:04 PM
- State changed from new to open
- Assigned user cleared.
Jan, I believe I've fixed this in edge dm-core (http://github.com/sam/dm-core/tr... Can you install it and let me know if it's fixed for you?
-
Dan Kubb (dkubb) November 30th, 2008 @ 12:44 PM
- Assigned user set to Dan Kubb (dkubb)
-
Dan Kubb (dkubb) November 30th, 2008 @ 02:00 PM
- State changed from open to resolved
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.
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
-
664 No record update after upgrade to 0.9.7 #666 is likely related and has a small example (could eas...
-
664 No record update after upgrade to 0.9.7 Marking this as resolved. Duplicate of #666 and #675
-
675 Some attributes can only be saved correctly when other attributes are also saved I've got confirmation in a duplicate ticket that this is ...
-
663 lazy attribute validation prevents record update I've got confirmation in a duplicate ticket that this is ...