bbc55193f5
## Summary Closes #20195 Fix phone field unique constraints so phone numbers are considered unique by both `primaryPhoneNumber` and `primaryPhoneCallingCode`. - Include `primaryPhoneCallingCode` in the shared phone composite unique constraint metadata - Align the frontend settings composite field config with the backend metadata - Return all included unique composite subfields when building create-many conflict fields - Match composite unique conflict fields as a group during create-many upserts ## Root Cause Phone composite metadata only marked `primaryPhoneNumber` as part of the unique constraint. That made different international phone numbers with the same national number conflict, for example `+1 123456789` and `+32 123456789`. ## Test Plan - `yarn workspace twenty-shared build` - `jest --runTestsByPath <index action handler and create-many utility specs>` - `prettier --check <touched files>` - `oxlint --type-aware <touched files>` - `nx run twenty-shared:typecheck` - `nx run twenty-server:typecheck` - `nx run twenty-front:typecheck` --------- Co-authored-by: mkdev11 <MkDev11@users.noreply.github.com> Co-authored-by: Etienne <45695613+etiennejouan@users.noreply.github.com> Co-authored-by: prastoin <paul@twenty.com>
31 lines
846 B
TypeScript
31 lines
846 B
TypeScript
import { type FieldMetadataDefaultValueForAnyType } from 'twenty-shared/types';
|
|
import { isDefined } from 'twenty-shared/utils';
|
|
|
|
import { isNullEquivalentTextDefaultValue } from './is-null-equivalent-text-default-value.util';
|
|
|
|
export const nullifyEmptyFullNameDefaultValue = (
|
|
defaultValue: FieldMetadataDefaultValueForAnyType,
|
|
): FieldMetadataDefaultValueForAnyType => {
|
|
if (!isDefined(defaultValue)) {
|
|
return null;
|
|
}
|
|
|
|
const v = defaultValue as {
|
|
firstName?: string | null;
|
|
lastName?: string | null;
|
|
};
|
|
|
|
const firstName = isNullEquivalentTextDefaultValue(v.firstName)
|
|
? null
|
|
: (v.firstName ?? null);
|
|
const lastName = isNullEquivalentTextDefaultValue(v.lastName)
|
|
? null
|
|
: (v.lastName ?? null);
|
|
|
|
if (firstName === null && lastName === null) {
|
|
return null;
|
|
}
|
|
|
|
return { firstName, lastName };
|
|
};
|