Save models using the overridden persistence context used for their loading

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Unknown
    • 9.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In https://github.com/mongodb/mongoid/pull/4556, it was requested that Mongoid provides a way for model instances that were loaded using a runtime-altered persistence context to retain that persistence context so that they would be saved to their correct source.

      Current behavior when loading and saving using runtime-overridden persistence context:

      band = Band.with(collection: 'foo') { |cls| cls.first }
      # #with must be called again:
      Band.with(collection: 'foo') { band.save! }
      

      Desired behavior:

      band = Band.with(collection: 'foo') { |cls| cls.first }
      # saves to 'foo'
      band.save!
      

              Assignee:
              Jamis Buck
              Reporter:
              Oleg Pudeyev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: