Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3512

Concurrency problems with Dynamic collection

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • Affects Version/s: None
    • Component/s: None
    • None

      class Orange
      include Mongoid::Document

      field :a
      end

      class Apple
      include Mongoid::Document

      field :a
      end

      Orange.create!

      query = Apple.with(collection: "oranges")

      Apple.count

      query.count ## should == 1 but actually is 0

      I'm running into concurrency issues with multiple processes in which I do

      Apple.with(collection: "oranges").count should return 1 but instead returns 0 because in between when the query happens something else (different process/thread) accesses Apple and resets the overridden collection name.

            Assignee:
            Unassigned Unassigned
            Reporter:
            makeshifthoop makeshifthoop
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: