Reused query ignores `with` options

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: 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
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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 (Inactive)
              Reporter:
              Federico Nusymowicz
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: