File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export class InsertOperation extends CommandOperation<Document> {
18
18
19
19
constructor ( ns : MongoDBNamespace , documents : Document [ ] , options : BulkWriteOptions ) {
20
20
super ( undefined , options ) ;
21
- this . options = { ...options , checkKeys : true } ;
21
+ this . options = { ...options , checkKeys : options . checkKeys ?? true } ;
22
22
this . ns = ns ;
23
23
this . documents = documents ;
24
24
}
Original file line number Diff line number Diff line change @@ -269,6 +269,16 @@ describe('Collection', function () {
269
269
} ) ;
270
270
} ) ;
271
271
272
+ it ( 'should permit insert of dot and dollar keys if requested' , function ( ) {
273
+ const collection = db . collection ( 'test_invalid_key_names' ) ;
274
+ return Promise . all ( [
275
+ collection . insertOne ( { hel$lo : 0 } , { checkKeys : false } ) ,
276
+ collection . insertOne ( { hello : { $hello : 0 } } , { checkKeys : false } ) , // embedded document can have a leading dollar
277
+ collection . insertOne ( { 'hel.lo' : 0 } , { checkKeys : false } ) ,
278
+ collection . drop ( )
279
+ ] ) ;
280
+ } ) ;
281
+
272
282
it ( 'should fail due to illegal listCollections' , function ( done ) {
273
283
db . collection ( 5 , err => {
274
284
expect ( err . message ) . to . equal ( 'collection name must be a String' ) ;
You can’t perform that action at this time.
0 commit comments