#256 ✓resolved
Nathan Herald

Attributes dirty enough for me

Reported by Nathan Herald | May 7th, 2008 @ 09:54 AM


If I set value = "something" for that Weird class in the pastie above, the attribute that it sets never gets marked as dirty.

To test, you can do:

w = Weird.new

w.value = "something"




Therefore, the save doesn't actually save the data to the db. Using the newest dm-core/do as of 5/7/08 @ 10:49am ET with a mysql db.

I was going to try to patch this, but I am not sure how attributes get marked as dirty, as Resource doesn't seem to have this logic in there (or does it?)

If someone can point me in the right direction, I will try to fix it.

Comments and changes to this ticket

  • Nathan Herald

    Nathan Herald May 7th, 2008 @ 10:07 AM

    I see that if I use self.string_value = new_value, then the #attribute_set is called on the Resource.

    This does not work with just string_value = new_value, the self is required.

    I suppose this is not a bug if it were documented well enough. I offer to provide some documentation, if this functionality were not going to change.

    Is this something to document or fix?

  • Adam French

    Adam French May 7th, 2008 @ 10:31 PM

    yeah, don't talk to the @ivars directly if you can avoid it....for that very reason.

    I want to say that we're talking about exposing a configuration so that users can choose the 'dirty strategy' they want to use. I don't really know the status of this, so it may be a better idea to document the default strategy for now.

  • Nathan Herald

    Nathan Herald May 8th, 2008 @ 07:50 AM

    • Title changed from “Attributes not quite dirty enough” to “Attributes dirty enough for me”

    After talking with people on IRC and reading your reply, I think that this behavior is fine if it's documented.

    The only issue is that use the ivar's was the proper way in 0.3 and the examples do it, so it might need to be part of an upgrade guide or something.

    I am not sure I like idea of choosing a strategy, but as long as it doesn't complicate the code base I suppose it's fine.

    I consider this resolved, but cannot update the status myself.

  • Sam Smoot

    Sam Smoot May 8th, 2008 @ 11:56 PM

    • State changed from “new” to “resolved”

    Just a final note: There's pending strategy specs in 0.9.0 right now.

    We're basically talking about a property option. There's load-time with the :load (#dup the value) and :hash (store the value#hash for later comparison) strategies. There's the false strategy for values that can't be duped like Fixnum or booleans so they'll be copied on load. Finally there's copy-on :get and copy-on :set, doing the obvious.

    There's some comments in the spec setup that should explain it a bit: http://github.com/sam/dm-core/tr...

    The examples themselves "load", "get", etc are copy/paste useless at this point of course.

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