@@ -419,7 +419,7 @@ class Service extends AdapterService {
419
419
const updateId = this . getIdsQuery ( id , undefined , false ) ;
420
420
Object . keys ( updateId ) . forEach ( key => {
421
421
if ( ! Object . prototype . hasOwnProperty . call ( newObject , key ) ) {
422
- newObject [ key ] = updateId [ key ] ; // id is missing in data, we had it
422
+ newObject [ key ] = updateId [ key ] ; // id is missing in data, we add it
423
423
} else if ( newObject [ key ] !== updateId [ key ] ) {
424
424
throw new errors . BadRequest ( `Id '${ key } ': values mismatch between data '${ newObject [ key ] } ' and request '${ updateId [ key ] } '` ) ;
425
425
}
@@ -602,7 +602,7 @@ class Service extends AdapterService {
602
602
_get ( id , params = { } ) {
603
603
// merge user query with the 'id' to get
604
604
const findQuery = Object . assign ( { } , { $and : [ ] } , params . query ) ;
605
- findQuery . $and . push ( this . getIdsQuery ( id ) ) ;
605
+ findQuery . $and . push ( this . getIdsQuery ( id ) ) ; // BUG will fail with composite primary key because table name will be missing
606
606
607
607
return this . _find ( Object . assign ( { } , params , { query : findQuery } ) )
608
608
. then ( page => {
@@ -848,11 +848,20 @@ class Service extends AdapterService {
848
848
const selectParam = filters . $select ? { $select : filters . $select } : undefined ;
849
849
const findParams = Object . assign ( { } , params , { query : Object . assign ( { } , params . query , this . getIdsQuery ( id , idList ) , selectParam ) } ) ;
850
850
851
- for ( const key of Object . keys ( dataCopy ) ) {
852
- if ( key in findParams . query ) {
853
- findParams . query [ key ] = dataCopy [ key ] ;
851
+ // Update find query if needed with patched values
852
+ const updateKeys = ( obj ) => {
853
+ for ( const key of Object . keys ( obj ) ) {
854
+ if ( key in dataCopy ) {
855
+ obj [ key ] = dataCopy [ key ] ;
856
+ } else {
857
+ if ( Array . isArray ( obj [ key ] ) ) {
858
+ obj [ key ] . forEach ( obj => updateKeys ( obj ) ) ;
859
+ }
860
+ }
854
861
}
855
- }
862
+ } ;
863
+ updateKeys ( findParams . query ) ;
864
+
856
865
return q . patch ( dataCopy ) . then ( ( ) => {
857
866
return params . query && params . query . $noSelect
858
867
? dataCopy
0 commit comments