File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -3524,4 +3524,23 @@ describe('sendEmail', () => {
35243524 'Failed to send email because no mail adapter is configured for Parse Server.'
35253525 ) ;
35263526 } ) ;
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+ } ) ;
35273546} ) ;
Original file line number Diff line number Diff line change @@ -971,6 +971,18 @@ class DatabaseController {
971971 return Promise . resolve ( query ) ;
972972 } ) ;
973973 }
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+ }
974986
975987 const promises = Object . keys ( query ) . map ( key => {
976988 const t = schema . getExpectedType ( className , key ) ;
@@ -1049,7 +1061,13 @@ class DatabaseController {
10491061 } )
10501062 ) ;
10511063 }
1052-
1064+ if ( query [ '$and' ] ) {
1065+ return Promise . all (
1066+ query [ '$and' ] . map ( aQuery => {
1067+ return this . reduceRelationKeys ( className , aQuery , queryOptions ) ;
1068+ } )
1069+ ) ;
1070+ }
10531071 var relatedTo = query [ '$relatedTo' ] ;
10541072 if ( relatedTo ) {
10551073 return this . relatedIds (
You can’t perform that action at this time.
0 commit comments