This repository has been archived by the owner. It is now read-only.

Arrays / Sets won't update properly #240

Open
florian opened this Issue Feb 16, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@florian

florian commented Feb 16, 2013

One of my models has a property that is a Set. (Same problem with arrays.)

property :some_set, Object

When I create an instance, the set is properly saved. But when I try to update the set (add a field to the set, and save the instance) the new set is not saved to the database.

instance = Model.first
instance.some_set #=> <Set: {"a", "b"}>

instance.some_set = instance.some_set.add('c')
instance.save()

instance.some_set #=> <Set: {"a", "b", "c"}>
Model.first.some_set #=> <Set: {"a", "b"}>

How to reproduce:

$ git clone https://github.com/js-coder/dm-sets.git
$ cd dm-sets
$ ruby set.rb
$ ruby array.rb
@mbj

This comment has been minimized.

Show comment
Hide comment
@mbj

mbj Feb 16, 2013

Member

With objects mutated inplace dm1 is unable to detect dirtyness. A verbose answer can be found here: http://stackoverflow.com/questions/13917062/why-datamapper-does-not-update-records-detect-dirtiness. dm-types tries to workaround this with a dirty-minder, but this IMHO only does only fix the symptoms not the problem itself.

DataMapper 2.0 does not have this problem, by design.

Member

mbj commented Feb 16, 2013

With objects mutated inplace dm1 is unable to detect dirtyness. A verbose answer can be found here: http://stackoverflow.com/questions/13917062/why-datamapper-does-not-update-records-detect-dirtiness. dm-types tries to workaround this with a dirty-minder, but this IMHO only does only fix the symptoms not the problem itself.

DataMapper 2.0 does not have this problem, by design.

@florian

This comment has been minimized.

Show comment
Hide comment
@florian

florian Feb 16, 2013

So I'd include dm-types and use Flag for arrays? There's no type for a Set right?

florian commented Feb 16, 2013

So I'd include dm-types and use Flag for arrays? There's no type for a Set right?

@tpitale

This comment has been minimized.

Show comment
Hide comment
@tpitale

tpitale Feb 8, 2016

Member

I wonder if a quick fix would be to add the ability to explicitly mark something as dirty? I think I could add this feature. It's not ideal, but I think it's doable.

Member

tpitale commented Feb 8, 2016

I wonder if a quick fix would be to add the ability to explicitly mark something as dirty? I think I could add this feature. It's not ideal, but I think it's doable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.