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

Support empty update document when upsert:true

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None

    Description

      Recent changes in the Node.js driver to ensure the CRUD spec requirement that all update documents MUST contain atomic operators has exposed a limitation in the spec previously supported in the driver: we provide no spec-compliant way to upsert an empty document. The specific language indicates:

      The update family of operations require that the update document parameter MUST have only atomic modifiers.

      However, the following query results in a server error:

      await db.collection('Test').bulkWrite([{
          updateOne: { filter: { name: 'test' }, update: { $set: {} }, upsert: true }
      }]);
       
      // error: '$set' is empty. You must specify a field like so: {$set: {<field>: ...}}
      

      I suggest that we loosen the language for the requirement of atomic operators to consider whether upsert: true has been provided.

      Attachments

        Activity

          People

            jmikola@mongodb.com Jeremy Mikola
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: