Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2699

make readable methods recognize chained options

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.18.0
    • Affects Version/s: 2.14.0
    • Component/s: None
    • None
    • Fully Compatible

      Queries of the form `MyCollection.where(...).hint(...).count` run an aggregation pipeline to determine the size without passing on the index hint. In cases where the query is sufficiently complicated the server will use the wrong index and the query times out. 

      I tracked down the issue to `Mongo::Collection::View::Readable#count_documents` where the aggregation pipeline `opts` do not include the view's `options[:hint]`. Adding `opts[:hint] = options[:hint]` before the aggregation pipeline runs seems to resolve the issue.

      I'm not sure why all of the view options are not currently used for `count_documents`, but it certainly seems like a bug to not respect the index hint provided. 

       

       

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            d.peters@spiketrap.io Daniel Peters
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: