Fix consistency issuesin relation onDelete behavior while creating a new relation (#4372)

* Fix consistency issuesin relation onDelete behavior while creating a new relation

* Fix according to review
This commit is contained in:
Charles Bochet 2024-03-08 11:49:42 +01:00 committed by GitHub
parent 92aa0bd888
commit d2e2e50d8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 8 deletions

View File

@ -9,7 +9,6 @@ import { ObjectTasks } from '@/activities/tasks/components/ObjectTasks';
import { Timeline } from '@/activities/timeline/components/Timeline';
import { TimelineQueryEffect } from '@/activities/timeline/components/TimelineQueryEffect';
import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import {
IconCalendarEvent,
@ -65,11 +64,6 @@ export const ShowPageRightContainer = ({
const { getActiveTabIdState } = useTabList(TAB_LIST_COMPONENT_ID);
const activeTabId = useRecoilValue(getActiveTabIdState());
const { objectMetadataItem: targetableObjectMetadataItem } =
useObjectMetadataItem({
objectNameSingular: targetableObject.targetObjectNameSingular,
});
const shouldDisplayCalendarTab = useIsFeatureEnabled('IS_CALENDAR_ENABLED');
const shouldDisplayEmailsTab =
(emails &&
@ -101,7 +95,6 @@ export const ShowPageRightContainer = ({
title: 'Files',
Icon: IconPaperclip,
hide: !notes,
disabled: targetableObjectMetadataItem.isCustom,
},
{
id: 'emails',

View File

@ -397,6 +397,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
createdObjectMetadata,
),
referencedTableColumnName: 'id',
onDelete: RelationOnDeleteAction.CASCADE,
},
],
},

View File

@ -26,6 +26,7 @@ import { generateMigrationName } from 'src/metadata/workspace-migration/utils/ge
import {
RelationMetadataEntity,
RelationMetadataType,
RelationOnDeleteAction,
} from './relation-metadata.entity';
@Injectable()
@ -209,6 +210,7 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
isUnique:
relationMetadataInput.relationType ===
RelationMetadataType.ONE_TO_ONE,
onDelete: RelationOnDeleteAction.SET_NULL,
},
],
},

View File

@ -4,7 +4,7 @@ export const convertOnDeleteActionToOnDelete = (
onDeleteAction: RelationOnDeleteAction | undefined,
): 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION' | undefined => {
if (!onDeleteAction) {
return;
return 'SET NULL';
}
switch (onDeleteAction) {