Prevent field name conflicts (#13280)

Fixes https://github.com/twentyhq/twenty/issues/13184
This commit is contained in:
Charles Bochet
2025-07-18 21:38:36 +02:00
committed by GitHub
parent fdf958bb27
commit 191bbb9e12
10 changed files with 402 additions and 88 deletions

View File

@ -17,6 +17,7 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
import { View } from '@/views/types/View';
import { ViewType } from '@/views/types/ViewType';
import { ApolloError } from '@apollo/client';
import { zodResolver } from '@hookform/resolvers/zod';
import { useLingui } from '@lingui/react/macro';
import { useEffect, useState } from 'react';
@ -149,14 +150,8 @@ export const SettingsObjectNewFieldConfigure = () => {
setIsSaving(false);
} catch (error) {
setIsSaving(false);
const isDuplicateFieldNameInObject = (error as Error).message.includes(
'duplicate key value violates unique constraint "IndexOnNameObjectMetadataIdAndWorkspaceIdUnique"',
);
enqueueErrorSnackBar({
message: isDuplicateFieldNameInObject
? t`Please use different names for your source and destination fields`
: undefined,
apolloError: error instanceof ApolloError ? error : undefined,
});
}
};