Fixed ‘oneWay’ relation creating unnecessary attr

When ‘oneWay’ relation is created the target model file is also updated with a reference to the relation. This is not required for a oneWay relation since it never will or can be populated from the other way around.
This commit is contained in:
Okaris 2018-05-17 11:27:39 +03:00
parent 0408368481
commit ae29802c07
10 changed files with 15 additions and 10 deletions

View File

@ -56,4 +56,4 @@
"npm": ">= 5.3.0" "npm": ">= 5.3.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -46,4 +46,4 @@
"npm": ">= 5.3.0" "npm": ">= 5.3.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -43,4 +43,4 @@
"npm": ">= 5.3.0" "npm": ">= 5.3.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -43,4 +43,4 @@
"npm": ">= 5.3.0" "npm": ">= 5.3.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -43,4 +43,4 @@
"npm": ">= 5.3.0" "npm": ">= 5.3.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -48,4 +48,4 @@
"npm": ">= 5.3.0" "npm": ">= 5.3.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -44,4 +44,4 @@
"npm": ">= 5.3.0" "npm": ">= 5.3.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -43,4 +43,4 @@
"npm": ">= 5.3.0" "npm": ">= 5.3.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -43,4 +43,4 @@
"npm": ">= 5.3.0" "npm": ">= 5.3.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -201,6 +201,7 @@ module.exports = {
}; };
switch (relation.nature) { switch (relation.nature) {
case 'oneWay':
case 'oneToOne': case 'oneToOne':
case 'manyToOne': case 'manyToOne':
attr.model = relation.target; attr.model = relation.target;
@ -212,7 +213,9 @@ module.exports = {
default: default:
} }
attr.via = relation.key; if(relation.nature !== 'oneWay') {
attr.via = relation.key;
}
attr.dominant = relation.dominant; attr.dominant = relation.dominant;
if (_.trim(relation.pluginValue)) { if (_.trim(relation.pluginValue)) {
@ -353,6 +356,8 @@ module.exports = {
const attr = {}; const attr = {};
switch (params.nature) { switch (params.nature) {
case 'oneWay':
return;
case 'oneToOne': case 'oneToOne':
case 'oneToMany': case 'oneToMany':
attr.model = model.toLowerCase(); attr.model = model.toLowerCase();