@@ -795,7 +795,7 @@ exports['ShouldCorrectlyLocatePostAndIncValues'] = function(test) {
795
795
*/
796
796
exports [ 'Should Correctly Handle FindAndModify Duplicate Key Error' ] = function ( test ) {
797
797
client . createCollection ( 'FindAndModifyDuplicateKeyError' , function ( err , collection ) {
798
- collection . ensureIndex ( [ 'name' , 1 ] , { unique :true } , function ( err , index ) {
798
+ collection . ensureIndex ( [ 'name' , 1 ] , { unique :true , safe : true } , function ( err , index ) {
799
799
// Test return new document on change
800
800
collection . insert ( [ { name :'test1' } , { name :'test2' } ] , { safe :true } , function ( err , doc ) {
801
801
// Let's modify the document in place
@@ -888,7 +888,7 @@ exports.shouldCorrectlyFindAndModifyDocumentWithDBStrict = function(test) {
888
888
exports . shouldCorrectlyFindAndModifyDocumentThatFailsInFirstStep = function ( test ) {
889
889
client . createCollection ( 'shouldCorrectlyFindAndModifyDocumentThatFailsInFirstStep' , function ( err , collection ) {
890
890
// Set up an index to force duplicate index erro
891
- collection . ensureIndex ( [ [ 'failIndex' , 1 ] ] , { unique :true } , function ( err , index ) {
891
+ collection . ensureIndex ( [ [ 'failIndex' , 1 ] ] , { unique :true , safe : true } , function ( err , index ) {
892
892
// Setup a new document
893
893
collection . insert ( { 'a' :2 , 'b' :2 , 'failIndex' :2 } , function ( err , doc ) {
894
894
@@ -1259,7 +1259,7 @@ exports.shouldCorrectlyErrorOutFindAndModifyOnDuplicateRecord = function(test) {
1259
1259
collection . insert ( [ { 'login' :'user1' } , { 'login' :'user2' } ] , { safe :true } , function ( err , docs ) {
1260
1260
var id = docs [ 1 ] . _id ;
1261
1261
// Set an index
1262
- collection . ensureIndex ( 'login' , { unique :true } , function ( err , result ) {
1262
+ collection . ensureIndex ( 'login' , { unique :true , safe : true } , function ( err , result ) {
1263
1263
// Attemp to modify document
1264
1264
collection . findAndModify ( { _id : id } , [ ] , { $set : { login : 'user1' } } , { } , function ( err , user ) {
1265
1265
test . ok ( err != null ) ;
0 commit comments