fix: remove required parameter from the field options

This commit is contained in:
chenos 2020-12-13 17:16:54 +08:00
parent a3107721c2
commit a7c9461cc0

View File

@ -95,14 +95,11 @@ export function getDataTypeKey(type: any): string {
* @param context * @param context
*/ */
export function buildField(options: FieldOptions, context: Fields.FieldContext) { export function buildField(options: FieldOptions, context: Fields.FieldContext) {
let { type, required } = options; let { type } = options;
if (type instanceof ABSTRACT) { if (type instanceof ABSTRACT) {
options = {...type.options, ...options}; options = {...type.options, ...options};
} }
type = getDataTypeKey(type); type = getDataTypeKey(type);
if (type !== 'VIRTUAL' && required) {
options.allowNull = false;
}
const Field = getField(type); const Field = getField(type);
return new Field({type, ...options}, context); return new Field({type, ...options}, context);
} }