proper colum names in ManyToMany relationships

This commit is contained in:
Kononnable 2019-11-10 17:28:56 +01:00
parent 5cdf4691f4
commit d797c3d06d
2 changed files with 11 additions and 8 deletions

View File

@ -140,18 +140,18 @@ export default abstract class AbstractDriver {
joinColumns: junctionEntity.relations[0].joinColumnOptions!.map(
(v, i) => {
return {
name: v.referencedColumnName,
referencedColumnName: junctionEntity.relations[1]
.joinColumnOptions![i].referencedColumnName
referencedColumnName: v.referencedColumnName,
name: junctionEntity.relations[0]
.joinColumnOptions![i].name
};
}
),
inverseJoinColumns: junctionEntity.relations[1].joinColumnOptions!.map(
(v, i) => {
return {
name: v.referencedColumnName,
referencedColumnName: junctionEntity.relations[0]
.joinColumnOptions![i].referencedColumnName
referencedColumnName: v.referencedColumnName,
name: junctionEntity.relations[1]
.joinColumnOptions![i].name
};
}
)

View File

@ -8,11 +8,14 @@ import { {{toEntityName .}} } from './{{toFileName .}}'
{{#generated}}@PrimaryGeneratedColumn({ type:"{{type}}", {{/generated}}{{^generated}}@Column("{{type}}",{ {{#primary}}primary:{{primary}},{{/primary}}{{/generated}}{{json options}}{{#default}},default: {{.}},{{/default}} })
{{printPropertyVisibility}}{{toPropertyName tscName}}{{strictMode}}:{{tscType}};
{{/inline}}
{{#*inline "JoinColumnOptions"}}
{ name: "{{name}}", referencedColumnName: "{{toPropertyName referencedColumnName}}" },
{{/inline}}
{{#*inline "Relation"}}
@{{relationType}}(()=>{{toEntityName relatedTable}},{{toEntityName relatedTable}}=>{{toEntityName relatedTable}}.{{toPropertyName relatedField}}{{#if relationOptions}},{ {{json relationOptions}} }{{/if}})
{{#if joinColumnOptions}}@JoinColumn([{{#joinColumnOptions}}{ name: "{{name}}", referencedColumnName: "{{toPropertyName referencedColumnName}}" },{{/joinColumnOptions}}]){{/if}}
{{#if joinTableOptions}}@JoinTable({ {{json joinTableOptions}} }){{/if}}
{{#if joinColumnOptions}}@JoinColumn([{{#joinColumnOptions}}{{> JoinColumnOptions}}{{/joinColumnOptions}}]){{/if}}
{{#joinTableOptions}}@JoinTable({ name:"{{name}}", joinColumns:[{{#joinColumns}}{{> JoinColumnOptions}}{{/joinColumns}}],inverseJoinColumns:[{{#inverseJoinColumns}}{{> JoinColumnOptions}}{{/inverseJoinColumns}}],{{#database}}database:"{{.}}",{{/database}}{{#schema}}schema:"{{.}}"{{/schema}} }){{/joinTableOptions}}
{{printPropertyVisibility}}{{toPropertyName fieldName}}{{strictMode}}:{{toRelation (toEntityName relatedTable) relationType}};
{{/inline}}