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:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user