@@ -5306,4 +5306,76 @@ describe('Parse.Query testing', () => {
5306
5306
expect ( score ) . toEqual ( [ 1 ] ) ;
5307
5307
} , { useMasterKey : true } ) ;
5308
5308
} ) ;
5309
+
5310
+ describe_only_db ( 'mongo' ) ( 'check if containedIn and matchesQuery works with nested keys' , async ( ) => {
5311
+ /**
5312
+ * If we use equalTo to compare the nested pointer it works
5313
+ * But it does not work with contained in or matchesQuery
5314
+ */
5315
+ it ( 'Parse query works with nested objects if equal to is used' , async ( ) => {
5316
+ const child = new Parse . Object ( 'Child' ) ;
5317
+ child . set ( 'key' , 'value' ) ;
5318
+ await child . save ( ) ;
5319
+
5320
+ const parent = new Parse . Object ( 'Parent' ) ;
5321
+ parent . set ( 'some' , {
5322
+ nested : {
5323
+ key : {
5324
+ child,
5325
+ } ,
5326
+ } ,
5327
+ } ) ;
5328
+ await parent . save ( ) ;
5329
+
5330
+ const query1 = await new Parse . Query ( 'Parent' )
5331
+ . equalTo ( 'some.nested.key.child' , child )
5332
+ . find ( ) ;
5333
+
5334
+ expect ( query1 . length ) . toEqual ( 1 ) ;
5335
+ } ) ;
5336
+
5337
+ it ( 'Parse query works when containedIn is used' , async ( ) => {
5338
+ const child = new Parse . Object ( 'Child' ) ;
5339
+ child . set ( 'key' , 'value' ) ;
5340
+ await child . save ( ) ;
5341
+
5342
+ const parent = new Parse . Object ( 'Parent' ) ;
5343
+ parent . set ( 'some' , {
5344
+ nested : {
5345
+ key : {
5346
+ child,
5347
+ } ,
5348
+ } ,
5349
+ } ) ;
5350
+ await parent . save ( ) ;
5351
+
5352
+ const query1 = await new Parse . Query ( 'Parent' )
5353
+ . containedIn ( 'some.nested.key.child' , [ child ] )
5354
+ . find ( ) ;
5355
+
5356
+ expect ( query1 . length ) . toEqual ( 1 ) ;
5357
+ } ) ;
5358
+
5359
+ it ( 'Parse query works when matchesQuery is used which in turn uses contained in' , async ( ) => {
5360
+ const child = new Parse . Object ( 'Child' ) ;
5361
+ child . set ( 'key' , 'value' ) ;
5362
+ await child . save ( ) ;
5363
+
5364
+ const parent = new Parse . Object ( 'Parent' ) ;
5365
+ parent . set ( 'some' , {
5366
+ nested : {
5367
+ key : {
5368
+ child,
5369
+ } ,
5370
+ } ,
5371
+ } ) ;
5372
+ await parent . save ( ) ;
5373
+
5374
+ const query1 = await new Parse . Query ( 'Parent' )
5375
+ . matchesQuery ( 'some.nested.key.child' , new Parse . Query ( 'Child' ) . equalTo ( 'key' , 'value' ) )
5376
+ . find ( ) ;
5377
+
5378
+ expect ( query1 . length ) . toEqual ( 1 ) ;
5379
+ } ) ;
5380
+ } ) ;
5309
5381
} ) ;
0 commit comments