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

db.collection.insert() shell helper does not support "bypassDocumentValidation" option

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 3.2.17, 3.4.9, 3.5.13
    • Shell
    • None
    • Query
    • ALL
    • Hide

      assert.commandWorked(db.runCommand({create: "coll", validator: {a: 1}}));
      assert.writeOK(db.coll.insert({a: 2}, {bypassDocumentValidation: true}));
      

      Show
      assert.commandWorked(db.runCommand({create: "coll" , validator: {a: 1}})); assert.writeOK(db.coll.insert({a: 2}, {bypassDocumentValidation: true }));

    Description

      Frustratingly, the db.collection.insert() shell helper silently ignores the "bypassDocumentValidation" flag. Fixing this problem is Harder Than It Sounds because the function uses the shell's Bulk API, which apparently does not have any notion of passing in options when performing an insert.

      I manually inspected the shell code back to v3.2 and I believe the issue has been present since when document validation was introduced.

      As a workaround, you can use db.runCommand to run the insert command directly and specify the option yourself.

      Attachments

        Activity

          People

            backlog-server-query Backlog - Query Team (Inactive)
            kyle.suarez@mongodb.com Kyle Suarez
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: