fixes #151 - generation of ManyToMany relation with custom table names

This commit is contained in:
Kononnable 2019-02-25 23:23:07 +01:00
parent 3cce3d2071
commit aba47cc9b8
3 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,7 @@
# Changelog
* fixed generation of ManyToMany relations on junction tables with custom names(#151)
## 0.3.1
* Fixed npx ussage(#146)

View File

@ -113,6 +113,7 @@ export abstract class AbstractDriver {
const column1 = new ColumnInfo();
column1.tsName = namesOfRelatedTables[1];
column1.options.name = entity.sqlEntityName;
const col1Rel = new RelationInfo();
col1Rel.relatedTable = namesOfRelatedTables[1];

View File

@ -26,7 +26,7 @@ import {BaseEntity,Column,Entity,Index,JoinColumn,JoinTable,ManyToMany,ManyToOne
{{printPropertyVisibility}}{{toPropertyName tsName}}:{{tsType}}{{#options/nullable}} | null{{/options/nullable}};
{{/relations}}{{#relations}}
@{{relationType}}(type=>{{toEntityName relatedTable}}, {{toEntityName relatedTable}}=>{{toEntityName relatedTable}}.{{#if isOwner}}{{toPropertyName ownerColumn}},{ {{#../options/primary}}primary:true,{{/../options/primary}}{{^../options/nullable}} nullable:false,{{/../options/nullable}}{{#actionOnDelete}}onDelete: '{{.}}',{{/actionOnDelete}}{{#actionOnUpdate}}onUpdate: '{{.}}'{{/actionOnUpdate}} }{{else}}{{toPropertyName relatedColumn}}{{#if (or actionOnDelete actionOnUpdate ) }}{{#actionOnDelete}},{ onDelete: '{{.}}' ,{{/actionOnDelete}}{{#actionOnUpdate}}onUpdate: '{{.}}'{{/actionOnUpdate}} }{{/if}}{{/if}}){{#isOwner}}
{{#if isManyToMany}}@JoinTable(){{else}}@JoinColumn({ name:'{{ ../options/name}}'}){{/if}}{{/isOwner}}
{{#if isManyToMany}}@JoinTable({ name:'{{ ../options/name}}'}){{else}}@JoinColumn({ name:'{{ ../options/name}}'}){{/if}}{{/isOwner}}
{{#if (or isOneToMany isManyToMany)}}{{printPropertyVisibility}}{{toPropertyName ../tsName}}:{{toLazy (concat (toEntityName relatedTable) "[]")}};
{{else}}{{printPropertyVisibility}}{{toPropertyName ../tsName}}:{{toLazy (concat (toEntityName relatedTable) ' | null')}};
{{/if}}