Skip to content

Commit

Permalink
Clear delayed atomic sets before substitution. Fixes #1659
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Feb 6, 2012
1 parent 58c236e commit 5b06944
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ For instructions on upgrading to newer versions, visit

* \#1668 Ensure Mongoid logger exists before calling warn. (Rémy Coutable)

* \#1659 Clear delayed atomic sets when resetting the same embedded relation.

* \#1656/#1657 Don't hit database for uniqueness validation if BOTH scope
and attribute hasn't changed. (priyaaank)

Expand Down
1 change: 1 addition & 0 deletions lib/mongoid/relations/embedded/many.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def substitute(replacement)
proxy.clear
else
atomically(:$set) do
base.delayed_atomic_sets.clear
if replacement.first.is_a?(Hash)
replacement = Many.builder(base, metadata, replacement).build
end
Expand Down
1 change: 1 addition & 0 deletions spec/functional/mongoid/relations/embedded/many_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@
end

context "when setting the relation multiple times" do

let(:address_two) do
Address.new(:street => "kudamm")
end
Expand Down

0 comments on commit 5b06944

Please sign in to comment.