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:
@ -24,7 +24,7 @@ export const validateOptionsForType = (
|
||||
if (options === null) return true;
|
||||
|
||||
if (!Array.isArray(options)) {
|
||||
return false;
|
||||
throw new Error('Options must be an array');
|
||||
}
|
||||
|
||||
if (!isEnumFieldMetadataType(type)) {
|
||||
@ -35,6 +35,13 @@ export const validateOptionsForType = (
|
||||
return true;
|
||||
}
|
||||
|
||||
const values = options.map(({ value }) => value);
|
||||
|
||||
// Check if all options are unique
|
||||
if (new Set(values).size !== options.length) {
|
||||
throw new Error('Options must be unique');
|
||||
}
|
||||
|
||||
const validators = optionsValidatorsMap[type];
|
||||
|
||||
if (!validators) return false;
|
||||
|
||||
Reference in New Issue
Block a user