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

Deprecate legacy behaviour around negative limits in find

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Component/s: CRUD
    • None
    • Needed

      The CRUD spec's Q&A section contains the following:

      Q: Where is singleBatch in FindOptions?

      Drivers have historically allowed users to request a single batch of results (after which the cursor is closed) by specifying a negative value for the limit option. For servers < 3.2, a single batch may be requested by specifying a negative value in the numberToReturn wire protocol field. For servers >= 3.2, the find command defines limit as a non-negative integer option but introduces a singleBatch boolean option. Rather than introduce a singleBatch option to FindOptions, the spec preserves the existing API for limit and instructs drivers to convert negative values accordingly for servers >= 3.2.

      As we no longer support MongoDB 3.2 or lower, the spec should be changed. In particular:

      • Accepting negative limits should not be required by the spec, so that drivers can deprecate and remove this behaviour as they please
      • The spec should clearly state that this behaviour is now deprecated and will be removed from drivers
      • Tests regarding negative limits and their handling should be extracted to a separate test file to allow for easier skipping in drivers that no longer implement this
      • A singleBatch option should be added to FindOptions to allow setting this option
      • Tests around singleBatch should be created in a separate file to allow for easier skipping in drivers that do not implement this option yet
      • Documentation for the singleBatch option in the spec and in drivers must mention that the batch may not contain all results requested. find returns fewer documents than min(limit, batchSize) even when more results are present if the documents would otherwise exceed the 16 MB size limit of the return document. In such cases, the server will not create a cursor to iterate the remaining documents, but only return documents up to the size limit.

            Assignee:
            Unassigned Unassigned
            Reporter:
            andreas.braun@mongodb.com Andreas Braun
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: