Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/mongoid/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def read_attribute(name)
# @api private
def process_raw_attribute(name, raw, field)
value = field ? field.demongoize(raw) : raw
attribute_will_change!(name) if value.resizable?
is_relation = relations.key?(name)
attribute_will_change!(name) if value.resizable? && !is_relation
value
end

Expand Down
18 changes: 17 additions & 1 deletion spec/mongoid/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2722,7 +2722,23 @@
end
end

context "when modifiying a set referenced with the [] notation" do
context "when accessing an embedded document with the attribute accessor" do
let(:band) { Band.create! }

before do
Band.where(id: band.id).update_all({
:$push => {records: { _id: BSON::ObjectId.new }}
})
end

it "does not throw a conflicting update error" do
b1 = Band.find(band.id)
b1[:records].is_a?(Array).should be true
expect { b1.save! }.not_to raise_error
end
end

context "when modifying a set referenced with the [] notation" do
let(:catalog) { Catalog.create!(set_field: [ 1 ].to_set) }

before do
Expand Down
Loading