
Json type / Hash assignment fails to mark attribute as dirty.
Reported by ojak | October 19th, 2009 @ 05:31 AM
After changing the Hash, Resource#save returns true without a DB update.
See attached test.
Comments and changes to this ticket
-
ojak October 19th, 2009 @ 06:53 PM
- Title changed from Json type fails to mark as dirty after changes (save returns true without DB update). to Json type / Hash assignment fails to mark attribute as dirty.
-
Dan Kubb (dkubb) February 2nd, 2010 @ 12:41 PM
- State changed from new to unconfirmed
- Assigned user cleared.
-
Piotr Solnica (solnic) February 19th, 2010 @ 07:47 AM
Have you ever considered this case? It's something I also have faced when I added support for Hash and Array as the property type. It's an interesting challenge to have it working correctly. Any ideas how we could approach that?
-
Collin April 20th, 2010 @ 10:52 AM
I have the same problem when serializing hashes in DM.
An interesting case I've run into is this:
I'm doing some serialization work and I thought I could keep a reference to the record in the attribute object.
"@record = record"
But this does not work because now the object cannot be serialized by marshal. Not quite sure what to do about this.
module Fauxsql
# Attribute is a mixin for AttributeList and AttributeMap classes. # It should be mixed into classes that inherit standard Ruby data structures(Hash, Array, Set, etc.) module Attribute def initialize(record, name) super() # explicitly super without arguments to preserve base behavior record.fauxsql_attributes[name] = self @record = record # THIS DOES NOT WORK end end
end
-
Collin April 20th, 2010 @ 01:39 PM
I've figured out a way to do this in my library.
It's here in the "dirty!" method.
http://github.com/collin/fauxsql/blob/master/lib/fauxsql/attribute_...Also, "dirty!" in action:
http://github.com/collin/fauxsql/blob/master/lib/fauxsql/map_wrappe... -
Dan Kubb (dkubb) May 22nd, 2010 @ 01:05 AM
- State changed from unconfirmed to confirmed
-
buhrmi (at gmail) January 3rd, 2011 @ 07:27 AM
- Milestone order changed from 0 to 0
I came up with a hacky monkey patch to add a similar method to DataMapper::Resource.
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 »