#58 primary keys on join columns
This commit is contained in:
parent
a1b5e68ea8
commit
6e15eb08d1
@ -24,7 +24,7 @@ import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, Man
|
||||
})
|
||||
{{toPropertyName name}}:{{ts_type}};
|
||||
{{/relations}}{{#relations}}
|
||||
@{{relationType}}(type=>{{toEntityName relatedTable}}, {{toPropertyName ../name}}=>{{toPropertyName ../name}}.{{#if isOwner}}{{toPropertyName ownerColumn}}{{else}}{{toPropertyName relatedColumn}}{{/if}}){{#isOwner}}
|
||||
@{{relationType}}(type=>{{toEntityName relatedTable}}, {{toPropertyName ../name}}=>{{toPropertyName ../name}}.{{#if isOwner}}{{toPropertyName ownerColumn}}{{#../isPrimary}},{primary:true{{^is_nullable}}, nullable:false,{{/is_nullable}} }{{/../isPrimary}}{{else}}{{toPropertyName relatedColumn}}{{/if}}){{#isOwner}}
|
||||
{{#if isManyToMany}}@JoinTable(){{else}}@JoinColumn({ name:'{{ ../name}}'}){{/if}}{{/isOwner}}
|
||||
{{#if (or isOneToMany isManyToMany)}}{{toPropertyName ../name}}:{{toEntityName relatedTable}}[];
|
||||
{{else}}{{toPropertyName ../name}}:{{toEntityName relatedTable}};
|
||||
|
36
test/integration/github-issues/58/entity/feedextrainfo.ts
Normal file
36
test/integration/github-issues/58/entity/feedextrainfo.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm";
|
||||
import {users} from "./users";
|
||||
import {quests} from "./quests";
|
||||
|
||||
|
||||
@Entity("feedextrainfo")
|
||||
@Index("feedExtraInfo_FeedOwnerId_idx",["FeedOwnerId",])
|
||||
@Index("feedExtraInfo_ReaderId_idx",["ReaderId",])
|
||||
@Index("feedExtraInfo_QuestId_idx",["QuestId",])
|
||||
export class feedextrainfo {
|
||||
|
||||
|
||||
@OneToOne(type=>users, FeedOwnerId=>FeedOwnerId.feedextrainfo,{primary:true, nullable:false, })
|
||||
@JoinColumn({ name:'FeedOwnerId'})
|
||||
FeedOwnerId:users;
|
||||
|
||||
|
||||
|
||||
@OneToOne(type=>quests, QuestId=>QuestId.feedextrainfo,{primary:true, nullable:false, })
|
||||
@JoinColumn({ name:'QuestId'})
|
||||
QuestId:quests;
|
||||
|
||||
|
||||
|
||||
@OneToOne(type=>users, ReaderId=>ReaderId.feedextrainfo2,{primary:true, nullable:false, })
|
||||
@JoinColumn({ name:'ReaderId'})
|
||||
ReaderId:users;
|
||||
|
||||
|
||||
@Column("int",{
|
||||
nullable:false,
|
||||
name:"MostUpdatedFeedEntryIdUserRead"
|
||||
})
|
||||
MostUpdatedFeedEntryIdUserRead:number;
|
||||
|
||||
}
|
20
test/integration/github-issues/58/entity/quests.ts
Normal file
20
test/integration/github-issues/58/entity/quests.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm";
|
||||
import {feedextrainfo} from "./feedextrainfo";
|
||||
|
||||
|
||||
@Entity("quests")
|
||||
export class quests {
|
||||
|
||||
@Column("int",{
|
||||
nullable:false,
|
||||
primary:true,
|
||||
name:"QuestId"
|
||||
})
|
||||
QuestId:number;
|
||||
|
||||
|
||||
|
||||
@OneToOne(type=>feedextrainfo, feedextrainfo=>feedextrainfo.QuestId)
|
||||
feedextrainfo:feedextrainfo;
|
||||
|
||||
}
|
25
test/integration/github-issues/58/entity/users.ts
Normal file
25
test/integration/github-issues/58/entity/users.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm";
|
||||
import {feedextrainfo} from "./feedextrainfo";
|
||||
|
||||
|
||||
@Entity("users")
|
||||
export class users {
|
||||
|
||||
@Column("int",{
|
||||
nullable:false,
|
||||
primary:true,
|
||||
name:"UserId"
|
||||
})
|
||||
UserId:number;
|
||||
|
||||
|
||||
|
||||
@OneToOne(type=>feedextrainfo, feedextrainfo=>feedextrainfo.FeedOwnerId)
|
||||
feedextrainfo:feedextrainfo;
|
||||
|
||||
|
||||
|
||||
@OneToOne(type=>feedextrainfo, feedextrainfo2=>feedextrainfo2.ReaderId)
|
||||
feedextrainfo2:feedextrainfo;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user