diff --git a/src/drivers/AbstractDriver.ts b/src/drivers/AbstractDriver.ts index 1557341..6a699cb 100644 --- a/src/drivers/AbstractDriver.ts +++ b/src/drivers/AbstractDriver.ts @@ -358,9 +358,8 @@ export abstract class AbstractDriver { const index = ownerEntity.Indexes.find( ind => ind.isUnique && - ind.columns.some( - col => col.name === ownerColumn!.tsName - ) + ind.columns.length === 1 && + ind.columns[0].name === ownerColumn!.tsName ); isOneToMany = !index; diff --git a/test/integration/github-issues/135/entity/Post.ts b/test/integration/github-issues/135/entity/Post.ts new file mode 100644 index 0000000..cdce663 --- /dev/null +++ b/test/integration/github-issues/135/entity/Post.ts @@ -0,0 +1,26 @@ +import { Index, Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable } from "typeorm"; +import { PostAuthor } from "./PostAuthor"; +import { PostCategory } from "./PostCategory"; + + +@Index("travel_travelplanextra_travel_plan_id_extra_id_f825ca51_uniq",["postAuthor","postCategory",],{unique:true}) +@Entity("Post") +export class Post { + + @Column("int", { + nullable: false, + primary: true, + name: "Id" + }) + Id: number; + + @ManyToOne(type => PostAuthor, PostAuthor => PostAuthor.Id) + @JoinColumn() + postAuthor: PostAuthor; + + + @ManyToOne(type => PostCategory, PostCategory => PostCategory.Id) + @JoinColumn() + postCategory: PostCategory; + +} diff --git a/test/integration/github-issues/135/entity/PostAuthor.ts b/test/integration/github-issues/135/entity/PostAuthor.ts new file mode 100644 index 0000000..db8ca99 --- /dev/null +++ b/test/integration/github-issues/135/entity/PostAuthor.ts @@ -0,0 +1,20 @@ +import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +import { Post } from "./Post"; + + +@Entity("PostAuthor") +export class PostAuthor { + + @Column("int",{ + nullable:false, + primary:true, + name:"Id" + }) + Id:number; + + + + @OneToMany(type => Post, Post => Post.Id) + posts:Post[]; + +} diff --git a/test/integration/github-issues/135/entity/PostCategory.ts b/test/integration/github-issues/135/entity/PostCategory.ts new file mode 100644 index 0000000..5804e3f --- /dev/null +++ b/test/integration/github-issues/135/entity/PostCategory.ts @@ -0,0 +1,20 @@ +import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +import { Post } from "./Post"; + + +@Entity("PostCategory") +export class PostCategory { + + @Column("int",{ + nullable:false, + primary:true, + name:"Id" + }) + Id:number; + + + + @OneToMany(type => Post, Post => Post.Id) + posts:Post[]; + +} diff --git a/test/integration/github-issues/58/entity/feedextrainfo.ts b/test/integration/github-issues/58/entity/feedextrainfo.ts index 7413759..2721cb9 100644 --- a/test/integration/github-issues/58/entity/feedextrainfo.ts +++ b/test/integration/github-issues/58/entity/feedextrainfo.ts @@ -4,9 +4,9 @@ import {quests} from "./quests"; @Entity("feedextrainfo") -@Index("feedExtraInfo_FeedOwnerId_idx",["feedOwnerId",]) -@Index("feedExtraInfo_ReaderId_idx",["readerId",]) -@Index("feedExtraInfo_QuestId_idx",["questId",]) +@Index("feedExtraInfo_FeedOwnerId_idx",["feedOwnerId",],{unique:true}) +@Index("feedExtraInfo_ReaderId_idx",["readerId",],{unique:true}) +@Index("feedExtraInfo_QuestId_idx",["questId",],{unique:true}) export class feedextrainfo {