fixes #151 - generation of ManyToMany relation with custom table names
This commit is contained in:
parent
3cce3d2071
commit
aba47cc9b8
@ -1,5 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
* fixed generation of ManyToMany relations on junction tables with custom names(#151)
|
||||
|
||||
## 0.3.1
|
||||
* Fixed npx ussage(#146)
|
||||
|
||||
|
@ -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];
|
||||
|
@ -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}}
|
||||
|
Loading…
Reference in New Issue
Block a user