fix: sync metadata shouldn't remove non custom fields (#3750)

* fix: sync metadata shouldn't remove non custom fields

* fix: filter out custom relations
This commit is contained in:
Jérémy M 2024-02-01 14:25:50 +01:00 committed by GitHub
parent bd5d930be2
commit 8abd5be4b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 5 deletions

View File

@ -39,8 +39,11 @@ export class WorkspaceFieldComparator {
string,
Partial<PartialFieldMetadata>
> = {};
// Double security to only compare non-custom fields
const filteredOriginalFieldCollection =
originalObjectMetadata.fields.filter((field) => !field.isCustom);
const originalFieldMetadataMap = transformMetadataForComparison(
originalObjectMetadata.fields,
filteredOriginalFieldCollection,
{
propertiesToIgnore: fieldPropertiesToIgnore,
propertiesToStringify: fieldPropertiesToStringify,

View File

@ -43,7 +43,11 @@ export class WorkspaceSyncObjectMetadataService {
// Retrieve object metadata collection from DB
const originalObjectMetadataCollection =
await objectMetadataRepository.find({
where: { workspaceId: context.workspaceId, isCustom: false },
where: {
workspaceId: context.workspaceId,
isCustom: false,
fields: { isCustom: false },
},
relations: ['dataSource', 'fields'],
});

View File

@ -44,7 +44,11 @@ export class WorkspaceSyncRelationMetadataService {
// Retrieve object metadata collection from DB
const originalObjectMetadataCollection =
await objectMetadataRepository.find({
where: { workspaceId: context.workspaceId, isCustom: false },
where: {
workspaceId: context.workspaceId,
isCustom: false,
fields: { isCustom: false },
},
relations: ['dataSource', 'fields'],
});
@ -58,10 +62,12 @@ export class WorkspaceSyncRelationMetadataService {
);
// Retrieve relation metadata collection from DB
// TODO: filter out custom relations once isCustom has been added to relationMetadata table
const originalRelationMetadataCollection =
await relationMetadataRepository.find({
where: { workspaceId: context.workspaceId },
where: {
workspaceId: context.workspaceId,
fromFieldMetadata: { isCustom: false },
},
});
// Create standard relation metadata collection