File tree 1 file changed +11
-3
lines changed
packages/server/src/api/rest
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1236,11 +1236,11 @@ class RequestHandler extends APIHandlerBase {
1236
1236
return r . toString ( ) ;
1237
1237
}
1238
1238
1239
- private makePrismaIdFilter ( idFields : FieldInfo [ ] , resourceId : string ) {
1239
+ private makePrismaIdFilter ( idFields : FieldInfo [ ] , resourceId : string , nested : boolean = true ) {
1240
1240
const decodedId = decodeURIComponent ( resourceId ) ;
1241
1241
if ( idFields . length === 1 ) {
1242
1242
return { [ idFields [ 0 ] . name ] : this . coerce ( idFields [ 0 ] . type , decodedId ) } ;
1243
- } else {
1243
+ } else if ( nested ) {
1244
1244
return {
1245
1245
// TODO: support `@@id` with custom name
1246
1246
[ idFields . map ( ( idf ) => idf . name ) . join ( prismaIdDivider ) ] : idFields . reduce (
@@ -1251,6 +1251,14 @@ class RequestHandler extends APIHandlerBase {
1251
1251
{ }
1252
1252
) ,
1253
1253
} ;
1254
+ } else {
1255
+ return idFields . reduce (
1256
+ ( acc , curr , idx ) => ( {
1257
+ ...acc ,
1258
+ [ curr . name ] : this . coerce ( curr . type , decodedId . split ( this . idDivider ) [ idx ] ) ,
1259
+ } ) ,
1260
+ { }
1261
+ ) ;
1254
1262
}
1255
1263
}
1256
1264
@@ -1598,7 +1606,7 @@ class RequestHandler extends APIHandlerBase {
1598
1606
: this . makePrismaIdFilter ( info . idFields , value ) ;
1599
1607
return { some : filterValue } ;
1600
1608
} else {
1601
- return { is : this . makePrismaIdFilter ( info . idFields , value ) } ;
1609
+ return { is : this . makePrismaIdFilter ( info . idFields , value , false ) } ;
1602
1610
}
1603
1611
} else {
1604
1612
const coerced = this . coerce ( fieldInfo . type , value ) ;
You can’t perform that action at this time.
0 commit comments