File tree 2 files changed +38
-1
lines changed
2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -3524,4 +3524,23 @@ describe('sendEmail', () => {
3524
3524
'Failed to send email because no mail adapter is configured for Parse Server.'
3525
3525
) ;
3526
3526
} ) ;
3527
+
3528
+ it ( 'should have object found with nested relational data query' , async ( ) => {
3529
+ const obj1 = Parse . Object . extend ( 'TestObject' ) ;
3530
+ const obj2 = Parse . Object . extend ( 'TestObject2' ) ;
3531
+ let item2 = new obj2 ( ) ;
3532
+ item2 = await item2 . save ( ) ;
3533
+ let item1 = new obj1 ( ) ;
3534
+ const relation = item1 . relation ( 'rel' ) ;
3535
+ relation . add ( item2 ) ;
3536
+ item1 = await item1 . save ( ) ;
3537
+ Parse . Cloud . beforeFind ( 'TestObject' , req => {
3538
+ const additionalQ = new Parse . Query ( 'TestObject' ) ;
3539
+ additionalQ . equalTo ( 'rel' , item2 ) ;
3540
+ return Parse . Query . and ( req . query , additionalQ ) ;
3541
+ } ) ;
3542
+ const q = new Parse . Query ( 'TestObject' ) ;
3543
+ const res = await q . first ( ) ;
3544
+ expect ( res . id ) . toEqual ( item1 . id ) ;
3545
+ } ) ;
3527
3546
} ) ;
Original file line number Diff line number Diff line change @@ -971,6 +971,18 @@ class DatabaseController {
971
971
return Promise . resolve ( query ) ;
972
972
} ) ;
973
973
}
974
+ if ( query [ '$and' ] ) {
975
+ const ors = query [ '$and' ] ;
976
+ return Promise . all (
977
+ ors . map ( ( aQuery , index ) => {
978
+ return this . reduceInRelation ( className , aQuery , schema ) . then ( aQuery => {
979
+ query [ '$and' ] [ index ] = aQuery ;
980
+ } ) ;
981
+ } )
982
+ ) . then ( ( ) => {
983
+ return Promise . resolve ( query ) ;
984
+ } ) ;
985
+ }
974
986
975
987
const promises = Object . keys ( query ) . map ( key => {
976
988
const t = schema . getExpectedType ( className , key ) ;
@@ -1049,7 +1061,13 @@ class DatabaseController {
1049
1061
} )
1050
1062
) ;
1051
1063
}
1052
-
1064
+ if ( query [ '$and' ] ) {
1065
+ return Promise . all (
1066
+ query [ '$and' ] . map ( aQuery => {
1067
+ return this . reduceRelationKeys ( className , aQuery , queryOptions ) ;
1068
+ } )
1069
+ ) ;
1070
+ }
1053
1071
var relatedTo = query [ '$relatedTo' ] ;
1054
1072
if ( relatedTo ) {
1055
1073
return this . relatedIds (
You can’t perform that action at this time.
0 commit comments