[fix] Nullable fields must have default values (#7522)

This commit is contained in:
Marie
2024-10-09 14:02:35 +02:00
committed by GitHub
parent 58cbcbfe70
commit 798722179e

View File

@@ -745,6 +745,15 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
}
}
if (!fieldMetadataInput.isNullable) {
if (!fieldMetadataInput.defaultValue) {
throw new FieldMetadataException(
'Default value is required for non nullable fields',
FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
);
}
}
if (fieldMetadataInput.options) {
for (const option of fieldMetadataInput.options) {
if (exceedsDatabaseIdentifierMaximumLength(option.value)) {