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

Prohibit find() with no selector in Bulk API

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Done
    • None
    • None
    • None

    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

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

              Dates

                Created:
                Updated:
                Resolved: