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

Scope doesn't respect runtime persistence in 4.0.0.beta1

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

      It seems like #with works inconsistently between 3.1.6 and 4.0.0.beta1.

      Mongoid 3.1.6, moped 1.5.2:

      15.times { User.create!(salary: 1) }
      10.times { User.with(database: "other_db").create!(salary: 1) }
      
      User.count                                 # => 15
      User.with(database: "other_db").count      # => 10 - good.
      User.with(database: "other_db").all.count  # => 10 - good.
      User.all.with(database: "other_db").count  # => 10 - good.
      

      Mongoid 4.0.0.beta1, moped 2.0.0.beta6:

      15.times { User.create!(salary: 1) }
      10.times { User.with(database: "other_db").create!(salary: 1) }
      
      User.count                                 # => 15
      User.with(database: "other_db").count      # => 10 - good.
      User.with(database: "other_db").all.count  # => 15 - It should be 10.
      User.all.with(database: "other_db").count  # => 10 - good.
      

      Both ran on Ruby 2.1.1:

      $ ruby -v
      ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
      

      Was this behaviour changed intentionally?

            Assignee:
            arthurnn Arthur Nogueira Neves
            Reporter:
            yuki24 yuki24
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: