Skip to content

Conversation

p-mongo
Copy link
Contributor

@p-mongo p-mongo commented Feb 4, 2019

No description provided.

@p-mongo p-mongo changed the title 4524 MONGOID-4524 Ensure that nested PersistenceContexts on the same object behave as expected Feb 4, 2019
@p-mongo p-mongo changed the title MONGOID-4524 Ensure that nested PersistenceContexts on the same object behave as expected MONGOID-4524 Combine options when nesting PersistenceContexts on the same object Feb 4, 2019
@p-mongo p-mongo requested a review from saghm February 5, 2019 03:06
end
new_options = existing_options.merge(options_or_context)
context = PersistenceContext.new(object, new_options)
Thread.current[key] = context
Copy link
Contributor

@saghm saghm Feb 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, will this cause issues if there's more code after the inner block within the outer block? e.g.

Band.with(collection: "artists") do |klass|
  Band.with(client: :reports) do |klass|
    klass.new.collection_name
  end

  klass.new.collection_name
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, repaired this as well.

@p-mongo p-mongo merged commit ce5accd into mongodb:master Feb 6, 2019
@p-mongo p-mongo deleted the 4524 branch February 6, 2019 17:27
p-mongo added a commit that referenced this pull request Feb 6, 2019
…same object (#4608)

* MONGOID-4524 Combine options when nesting PersistenceContexts on the same object

* Restore persistence context when leaving with block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants