File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 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> {
1818
1919 constructor ( ns : MongoDBNamespace , documents : Document [ ] , options : BulkWriteOptions ) {
2020 super ( undefined , options ) ;
21- this . options = { ...options , checkKeys : true } ;
21+ this . options = { ...options , checkKeys : options . checkKeys ?? true } ;
2222 this . ns = ns ;
2323 this . documents = documents ;
2424 }
Original file line number Diff line number Diff line change @@ -269,6 +269,16 @@ describe('Collection', function () {
269269 } ) ;
270270 } ) ;
271271
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+
272282 it ( 'should fail due to illegal listCollections' , function ( done ) {
273283 db . collection ( 5 , err => {
274284 expect ( err . message ) . to . equal ( 'collection name must be a String' ) ;
You can’t perform that action at this time.
0 commit comments