Fix/enum bug (#4659)

* fix: sever not throwing when enum contains two identical values

* fix: enum column name cannot be change

* fix: put field create/update inside transactions

* fix: check for options duplicate values front-end

* fix: missing commit transaction
This commit is contained in:
Jérémy M
2024-03-26 16:16:29 +01:00
committed by GitHub
parent ab028b8c22
commit 3acec7731c
5 changed files with 329 additions and 206 deletions

View File

@ -26,6 +26,22 @@ export const formatFieldMetadataItemInput = (
) => {
const defaultOption = input.options?.find((option) => option.isDefault);
// Check if options has unique values
if (input.options !== undefined) {
// Compute the values based on the label
const values = input.options.map((option) =>
getOptionValueFromLabel(option.label),
);
if (new Set(values).size !== input.options.length) {
throw new Error(
`Options must have unique values, but contains the following duplicates ${values.join(
', ',
)}`,
);
}
}
return {
defaultValue: defaultOption
? getOptionValueFromLabel(defaultOption.label)