Skip to content

Commit a54fb5a

Browse files
HCK-12556: Technical name property in relationships with coupling and naming convention (#162)
* HCK-12556: Technical name property in relationships with coupling and naming convention * fix: get code
1 parent fd114fa commit a54fb5a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

forward_engineering/helpers/alterScriptHelpers/alterRelationshipsHelper.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { AlterScriptDto } = require('./types/AlterScriptDto');
77
* @return string
88
* */
99
const getRelationshipName = relationship => {
10-
return relationship.role.name;
10+
return relationship.role.code || relationship.role.name;
1111
};
1212

1313
/**
@@ -31,7 +31,7 @@ const getFullChildTableName = _ => relationship => {
3131
const getAddSingleForeignKeyStatementDto = (ddlProvider, _) => relationship => {
3232
const compMod = relationship.role.compMod;
3333

34-
const relationshipName = compMod.name?.new || getRelationshipName(relationship) || '';
34+
const relationshipName = compMod.code?.new || compMod.name?.new || getRelationshipName(relationship) || '';
3535
const schemaName = compMod.parent.bucket.name;
3636

3737
return ddlProvider.createForeignKey(
@@ -98,7 +98,7 @@ const getDeleteSingleForeignKeyStatementDto = (ddlProvider, _) => relationship =
9898

9999
const ddlChildEntityName = getFullChildTableName(_)(relationship);
100100

101-
const relationshipName = compMod.name?.old || getRelationshipName(relationship) || '';
101+
const relationshipName = compMod.code?.old || compMod.name?.old || getRelationshipName(relationship) || '';
102102
const ddlRelationshipName = wrapInBrackets(relationshipName);
103103
const statement = ddlProvider.dropForeignKey(ddlChildEntityName, ddlRelationshipName);
104104

@@ -120,7 +120,7 @@ const canRelationshipBeDeleted = relationship => {
120120
return false;
121121
}
122122
return [
123-
compMod.name?.old || getRelationshipName(relationship),
123+
compMod.code?.old || compMod.name?.old || getRelationshipName(relationship),
124124
compMod.child?.bucket,
125125
compMod.child?.collection,
126126
].every(property => Boolean(property));

0 commit comments

Comments
 (0)