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

Reused query ignores `with` options

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 12_01_17
    • Affects Version/s: 5.1.5
    • Component/s: None
    • Environment:
      jruby 9.1.6.0, mongoid 5.1.5, mongo 2.3.0, bson 4.1.1-java

      Configure the `default` client to use read mode `:secondary_preferred`. Then configure a `primary` client to use read mode `:primary`. Then:

      ```
      Mongo::Logger.level = Logger::DEBUG

      MyModel.where(key: 'existing_key').with(client: :primary).first

      1. logs show that model is fetched from primary, as expected

      q = MyModel.where(key: 'existing_key')
      q.first

      1. logs show that model is fetched from secondary, as expected

      q.with(client: :primary).first

      1. logs show that model is fetched from secondary, which is unexpected
        ```

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            fedenusy13 Federico Nusymowicz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: