fix: do not automatically generate target, when target exists
This commit is contained in:
parent
ecab106c3c
commit
2a383e2142
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user