Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40718

Validate parameters for estimatedDocumentCount

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: None
    • Labels:
      None

      Description

      The documentation for `estimatedDocumentCount` is a bit confusing.

      It seems that both MongoDB (shell) and PyMongo allow passing arbitrary, meaningless options. In PyMongo, I've been calling the function thus:

      db.coll.estimated_document_count(
              filter=query, limit=limit, maxTimeMS=10000)
      
      

      Not realizing that the filter and limit had no effect.

      I've tested and the shell also silently accepts arbitrary fields:

      rs0:PRIMARY> db.coll.estimatedDocumentCount({"foo": "bar"})
      1
      
      

      I try to imagine what is the value of accepting arbitrary keyword arguments. I could imagine that some future version of MongoDB might honor other parameters for that query, so you'd like to support that interface before it exists. Even for that use-case, I'd expect the server to respond with some warning or errors about unused parameters, especially when the docs say "this method wraps the count command", which does take more parameters.

      Can this call be made so that it rejects invalid parameters?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              jason.coombs@yougov.com Jason R. Coombs
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated: