(function() {
|
'use strict';
|
|
var dbName = 'bypass_document_validation';
|
var collName = 'bypass_document_validation';
|
var myDb = db.getSiblingDB(dbName);
|
var coll = myDb[collName];
|
var docValidationErrorCode = ErrorCodes.DocumentValidationFailure;
|
coll.drop();
|
|
// Create a collection with a validation rule
|
assert.commandWorked(myDb.runCommand({create: collName, validator: {a: {$exists: true}}}));
|
// Test applyOps with a simple insert
|
var op = [{ts: Timestamp(0, 0), h: 1, v: 2, op: 'i', ns: coll.getFullName(), o: {_id: 1}}];
|
// applyOps is returning ErrorCodes.UnknownError (8) instead of DocumentValidationFailure
|
assert.commandFailedWithCode(
|
myDb.runCommand({applyOps: op, bypassDocumentValidation: false}), docValidationErrorCode );
|
assert.eq(0, coll.count({_id: 1}));
|
})();
|