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