-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 6.2.1
-
Component/s: None
-
None
-
Environment:Mongoid driver 6.2.1, Ruby 2.5.1
When creating a Mongoid::Document the double left operator "<<" works as expected for field type of Array, however for field type of Set, it returns the correct value from the operation but does not update the instance attribute.
Below is an example of the bug in a console.
Here you can see the << operator returns the correctly appended "third" value to the set field but when queried the instance's attribute has not been set as expected.
> class Foo > include Mongoid::Document > field :queue, :type => :array, default: Array.new > field :bad_queue, :type => :set, default: Set.new > end => #<Mongoid::Fields::Standard:0x00007f89557c39c8 @name="bad_queue", @options={:type=>Set, :default=>#<Set: {}>, :klass=>Foo}, @label=nil, @default_val=#<Set: {}>, @pre_processed=true> > my_foo = Foo.new => #<Foo _id: 5c33cef8199fcd4ae792539e, queue: [], bad_queue: []> > my_foo.queue = ["first", "second"] => ["first", "second"] > my_foo.queue << "third" => ["first", "second", "third"] > my_foo.queue => ["first", "second", "third"] > my_foo.bad_queue = ["first", "second"] => ["first", "second"] > my_foo.bad_queue << "third" => #<Set: {"first", "second", "third"}> > my_foo.bad_queue => #<Set: {"first", "second"}>
- duplicates
-
MONGOID-2951 Attributes of container types are not persisted when mutated
- Backlog
- is related to
-
MONGOID-4683 Document that mutated container attributes are not stored/persisted by Mongoid
- Closed