fix: do not automatically generate target, when target exists

This commit is contained in:
chenos 2020-12-20 17:24:12 +08:00
parent ecab106c3c
commit 2a383e2142

View File

@ -28,7 +28,9 @@ export class FieldModel extends BaseModel {
if (['hasOne', 'hasMany', 'belongsTo', 'belongsToMany'].includes(data.type)) {
if (!data.name) {
data.name = generateFieldName();
data.target = generateCollectionName();
if (!data.target) {
data.target = generateCollectionName();
}
}
if (!data.target) {
data.target = ['hasOne', 'belongsTo'].includes(data.type) ? Utils.pluralize(data.name) : data.name;