feat: drop target column map (#4670)
This PR is dropping the column `targetColumnMap` of fieldMetadata entities. The goal of this column was to properly map field to their respecting column in the table. We decide to drop it and instead compute the column name on the fly when we need it, as it's more easier to support. Some parts of the code has been refactored to try making implementation of composite type more easier to understand and maintain. Fix #3760 --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -17,9 +17,6 @@ describe('deduceRelationDirection', () => {
|
||||
name: 'field_name',
|
||||
label: 'Field Name',
|
||||
description: 'Field Description',
|
||||
targetColumnMap: {
|
||||
default: 'default_column',
|
||||
},
|
||||
};
|
||||
|
||||
const relationMetadata = {
|
||||
@ -48,9 +45,6 @@ describe('deduceRelationDirection', () => {
|
||||
name: 'field_name',
|
||||
label: 'Field Name',
|
||||
description: 'Field Description',
|
||||
targetColumnMap: {
|
||||
default: 'default_column',
|
||||
},
|
||||
};
|
||||
|
||||
const relationMetadata = {
|
||||
@ -78,9 +72,6 @@ describe('deduceRelationDirection', () => {
|
||||
name: 'field_name',
|
||||
label: 'Field Name',
|
||||
description: 'Field Description',
|
||||
targetColumnMap: {
|
||||
default: 'default_column',
|
||||
},
|
||||
};
|
||||
|
||||
const relationMetadata = {
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface';
|
||||
|
||||
import { computeCustomName } from './compute-custom-name.util';
|
||||
import { computeTableName } from './compute-table-name.util';
|
||||
|
||||
export const computeObjectTargetTable = (
|
||||
objectMetadata: ObjectMetadataInterface,
|
||||
) => {
|
||||
return computeCustomName(
|
||||
objectMetadata.nameSingular,
|
||||
objectMetadata.isCustom,
|
||||
);
|
||||
return computeTableName(objectMetadata.nameSingular, objectMetadata.isCustom);
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
export const customNamePrefix = '_';
|
||||
|
||||
export const computeCustomName = (name: string, isCustom: boolean) => {
|
||||
export const computeTableName = (name: string, isCustom: boolean) => {
|
||||
return isCustom ? `${customNamePrefix}${name}` : name;
|
||||
};
|
||||
@ -1,3 +0,0 @@
|
||||
export const createCustomColumnName = (name: string) => {
|
||||
return `_${name}`;
|
||||
};
|
||||
Reference in New Issue
Block a user