@@ -369,7 +369,9 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
369
369
370
370
const updatedObject = await super . updateOne ( input . id , input . update ) ;
371
371
372
- await this . updateObjectRelationships ( input ) ;
372
+ if ( input . update . isActive !== undefined ) {
373
+ await this . updateObjectRelationships ( input . id , input . update . isActive ) ;
374
+ }
373
375
374
376
await this . workspaceMetadataVersionService . incrementMetadataVersion (
375
377
workspaceId ,
@@ -1241,30 +1243,31 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
1241
1243
) ;
1242
1244
}
1243
1245
1244
- private async updateObjectRelationships ( input : UpdateOneObjectInput ) {
1245
- if ( input . update . isActive !== undefined ) {
1246
- const affectedRelations = await this . relationMetadataRepository . find ( {
1247
- where : [
1248
- { fromObjectMetadataId : input . id } ,
1249
- { toObjectMetadataId : input . id } ,
1250
- ] ,
1251
- } ) ;
1246
+ private async updateObjectRelationships (
1247
+ objectMetadataId : string ,
1248
+ isActive : boolean ,
1249
+ ) {
1250
+ const affectedRelations = await this . relationMetadataRepository . find ( {
1251
+ where : [
1252
+ { fromObjectMetadataId : objectMetadataId } ,
1253
+ { toObjectMetadataId : objectMetadataId } ,
1254
+ ] ,
1255
+ } ) ;
1252
1256
1253
- const affectedFieldIds = affectedRelations . reduce (
1254
- ( acc , { fromFieldMetadataId, toFieldMetadataId } ) => {
1255
- acc . push ( fromFieldMetadataId , toFieldMetadataId ) ;
1257
+ const affectedFieldIds = affectedRelations . reduce (
1258
+ ( acc , { fromFieldMetadataId, toFieldMetadataId } ) => {
1259
+ acc . push ( fromFieldMetadataId , toFieldMetadataId ) ;
1256
1260
1257
- return acc ;
1258
- } ,
1259
- [ ] as string [ ] ,
1260
- ) ;
1261
+ return acc ;
1262
+ } ,
1263
+ [ ] as string [ ] ,
1264
+ ) ;
1261
1265
1262
- if ( affectedFieldIds . length > 0 ) {
1263
- await this . fieldMetadataRepository . update (
1264
- { id : In ( affectedFieldIds ) } ,
1265
- { isActive : input . update . isActive } ,
1266
- ) ;
1267
- }
1266
+ if ( affectedFieldIds . length > 0 ) {
1267
+ await this . fieldMetadataRepository . update (
1268
+ { id : In ( affectedFieldIds ) } ,
1269
+ { isActive : isActive } ,
1270
+ ) ;
1268
1271
}
1269
1272
}
1270
1273
}
0 commit comments