@@ -390,6 +390,77 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
390
390
await expectAsync ( adapter . getClass ( 'UnknownClass' ) ) . toBeRejectedWith ( undefined ) ;
391
391
} ) ;
392
392
393
+
394
+ /**
395
+ * If we use equalTo to comparse the nested pointer it works
396
+ * But it does not work with contained in or matchesQuery
397
+ */
398
+ it ( 'Parse query works with nested objects if equal to is used' , async ( ) => {
399
+ const child = new Parse . Object ( 'Child' )
400
+ child . set ( 'key' , 'value' )
401
+ await child . save ( ) ;
402
+
403
+ const parent = new Parse . Object ( 'Parent' ) ;
404
+ parent . set ( 'some' , {
405
+ nested : {
406
+ key : {
407
+ child
408
+ }
409
+ }
410
+ } )
411
+ await parent . save ( ) ;
412
+
413
+ const query1 = await new Parse . Query ( 'Parent' )
414
+ . equalTo ( 'some.nested.key.child' , child )
415
+ . find ( ) ;
416
+
417
+ expect ( query1 . length ) . toEqual ( 1 ) ;
418
+ } )
419
+
420
+ it ( 'Parse query works when containedIn is used' , async ( ) => {
421
+ const child = new Parse . Object ( 'Child' )
422
+ child . set ( 'key' , 'value' )
423
+ await child . save ( ) ;
424
+
425
+ const parent = new Parse . Object ( 'Parent' ) ;
426
+ parent . set ( 'some' , {
427
+ nested : {
428
+ key : {
429
+ child
430
+ }
431
+ }
432
+ } )
433
+ await parent . save ( ) ;
434
+
435
+ const query1 = await new Parse . Query ( 'Parent' )
436
+ . containedIn ( 'some.nested.key.child' , [ child ] )
437
+ . find ( ) ;
438
+
439
+ expect ( query1 . length ) . toEqual ( 1 ) ;
440
+ } )
441
+
442
+ it ( 'Parse query works when matchesQuery is used which in turn uses contained in' , async ( ) => {
443
+ const child = new Parse . Object ( 'Child' )
444
+ child . set ( 'key' , 'value' )
445
+ await child . save ( ) ;
446
+
447
+ const parent = new Parse . Object ( 'Parent' ) ;
448
+ parent . set ( 'some' , {
449
+ nested : {
450
+ key : {
451
+ child
452
+ }
453
+ }
454
+ } )
455
+ await parent . save ( ) ;
456
+
457
+ const query1 = await new Parse . Query ( 'Parent' )
458
+ . matchesQuery ( 'some.nested.key.child' , new Parse . Query ( 'Child' ) . equalTo ( 'key' , 'value' ) )
459
+ . find ( ) ;
460
+
461
+ expect ( query1 . length ) . toEqual ( 1 ) ;
462
+ } )
463
+
393
464
it_only_mongodb_version ( '<5.1 || >=6' ) ( 'should use index for caseInsensitive query' , async ( ) => {
394
465
const user = new Parse . User ( ) ;
395
466
user . set ( 'username' , 'Bugs' ) ;
0 commit comments