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

@ -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;