-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Associations, Query
-
3
-
(copied to CRM)
If you have an object that has been retrieved via #only, you can be subject to data loss when saving that model.
class Parent include Mongoid::Document embeds_one :child end class Child include Mongoid::Document embedded_in :parent field :a, :type => Integer, :default => 0 field :b, :type => Integer, :default => 0 field :c, :type => Integer, :default => 0 end Parent.delete_all() p = Parent.new p.build_child(:a => 10, :b => 20, :c => 30) p.save() Mongoid::IdentityMap.clear p = Parent.only(:_id, 'child._id', 'child.a').first p.child.a = 40 p.save() p.reload() p.child # => #<Child _id: 50eb642bdd365a121b00000c, a: 40, b: 0, c: 0>
- causes
-
MONGOID-4769 embeds_many mishandles positional projections (foo.$)
- Closed
-
MONGOID-4952 Unable to access embedded fields in projected query results
- Closed
- is related to
-
MONGOID-4701 Allow writing fields omitted in #only
- Backlog
-
MONGOID-4704 Project referenced associations with #only
- Backlog
- links to