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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.2.17, 3.4.9, 3.5.13
    • Component/s: 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 }));
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Backlog - Query Team (Inactive)
            Reporter:
            Kyle Suarez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: