File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -359,6 +359,17 @@ describe("Individual operator tests", function() {
359359 expect ( coll . find ( { "c" : { $eq : undefined } } ) . length ) . toEqual ( 4 ) ;
360360 } ) ;
361361
362+ it ( 'query nested documents with nullable object' , function ( ) {
363+ var db = new loki ( 'db' ) ;
364+ var coll = db . addCollection ( 'coll' ) ;
365+
366+ coll . insert ( { a : null , b : 5 , c : { a : 1 } } ) ;
367+ coll . insert ( { a : "11" , b : 5 , c : { a : 1 } } ) ;
368+ coll . insert ( { a : "11" , b : 5 , c : null } ) ;
369+
370+ expect ( coll . find ( { "c.a" : { $eq : 1 } } ) . length ) . toEqual ( 2 ) ;
371+ } ) ;
372+
362373 it ( '$exists ops work as expected' , function ( ) {
363374 var db = new loki ( 'db' ) ;
364375 var coll = db . addCollection ( 'coll' ) ;
Original file line number Diff line number Diff line change 415415
416416 var valueFound = false ;
417417 var element ;
418- if ( typeof root === 'object' && path in root ) {
418+ if ( root !== null && typeof root === 'object' && path in root ) {
419419 element = root [ path ] ;
420420 }
421421 if ( pathOffset + 1 >= paths . length ) {
You can’t perform that action at this time.
0 commit comments