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

Consider passing find (collection view) session to count_documents

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.19.0
    • Affects Version/s: 2.16.0
    • Component/s: None
    • None

      Original report:

      when you do:

      collection.find({}, session: x).count_documents

      it doesn't use the session that is stored in the options of the View that find returns

       

      Sorry if I didn't specify clearly enough. In an attempt to clarify more, I monkeypatched the method like so:

      opts = opts.select{ |k, _| [:hint, :max_time_ms, :read, :collation, :session].include?(k) }
      opts[:collation] ||= collation
      opts[:session] ||= options[:session]

      This then allows you to override the session when calling count_documents but by default it will use the one already specified on the View

       ----------------------

      There is precedent for some find options not being applicable to subsequent methods, for example limit given to find does not apply to updates (which could update either a single document or all matching documents, but not an arbitrary number of them).

      As part of this ticket at least all of the view methods should be reviewed for behaving consistently with respect to either using or not using the session option given to find.

      Additionally, reference documentation needs to be reviewed and likely updated to state that find session will carry over to other operations.

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            michael@brightbits.co.uk Michael Baldry
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: