Skip to content

Commit

Permalink
Adjusts for one-to-one id relationships.
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Mar 1, 2021
1 parent 7a3229a commit da9ea65
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions utils/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,13 @@ function prepareEntityForTemplates(entityWithConfig, generator) {
autoGenerate: true,
readonly: true,
get fieldName() {
return idCount === 1 && !relationship.otherEntity.primaryKey.composite
? field.fieldName
: `${relationship.otherEntity.entityInstance}${field.fieldNameCapitalized}`;
return idCount === 1 ? field.fieldName : `${relationship.otherEntity.entityInstance}${field.fieldNameCapitalized}`;
},
get fieldNameCapitalized() {
return idCount === 1 && !relationship.otherEntity.primaryKey.composite
? field.fieldNameCapitalized
: `${relationship.otherEntity.entityClass}${field.fieldNameCapitalized}`;
return idCount === 1 ? field.fieldNameCapitalized : `${relationship.otherEntity.entityClass}${field.fieldNameCapitalized}`;
},
get columnName() {
return idCount === 1 && !relationship.otherEntity.primaryKey.composite
? field.columnName
: `${generator.getColumnName(relationship.relationshipName)}_${field.columnName}`;
return idCount === 1 ? field.columnName : `${generator.getColumnName(relationship.relationshipName)}_${field.columnName}`;
},
get reference() {
return fieldToReference(entityWithConfig, this);
Expand Down

0 comments on commit da9ea65

Please sign in to comment.