Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-141

Prohibit find() with no selector in Bulk API

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Component/s: None
    • Labels:
      None
    • SERVER fixVersion:
      2.6

      Description

      There's been a clarification to the spec: The Bulk API's find() method requires a selector. (Also known as a "query" or a "spec".) It should immediately raise the appropriate compile error or runtime exception if called like:

      // Prohibited:
      collection.initializeOrderedBulkOp().find()
      collection.initializeUnorderedBulkOp().find()

      Calling find() with an empty selector is fine:

      collection.initializeOrderedBulkOp().find({})

      Justification

      We're updating APIs to follow these principles:

      1. Keep allowing users to read documents without specifying a query: find().
      2. Require users to specify a query when updating or removing documents. remove() is prohibited.
      3. The empty query "{}" counts as a query. remove({}) is ok.

      For example, in SERVER-12409 we prohibit collection.remove() in the shell. collection.remove({}) is still ok, because the user has expressed a desire to deliberately remove all documents.

      Fluent and Bulk API specifications have been updated to match these principles.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              barrie Barrie Segal
              Reporter:
              jesse A. Jesse Jiryu Davis
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: