mongoid / origin

A Ruby DSL for building MongoDB queries
http://mongoid.org/en/origin/index.html
MIT License
62 stars 29 forks source link

"Don't modify selector in place" breaks IDs array behavior #87

Closed johnnyshields closed 10 years ago

johnnyshields commented 11 years ago

Re: commit https://github.com/mongoid/origin/commit/9f8c2eaabed9f4e363eb31c57ce0ee1100ce8e04 which was added in Origin v1.0.11

(Assume foo has_many bars)

   @foo.bar_ids << @bar.id
   @foo.bar.should == [@bar]   # breaks after aforementioned commit
durran commented 10 years ago

The fact that this was working before was an accident - the documented behaviour is to set the ids array, as so:

https://github.com/mongoid/mongoid/blob/master/lib/mongoid/relations/accessors.rb#L256

johnnyshields commented 10 years ago

Thanks, this makes sense!