From 577266a03bf231bbd0cfe969a345e35450643bd5 Mon Sep 17 00:00:00 2001 From: Kononnable Date: Mon, 7 Oct 2019 13:51:39 +0200 Subject: [PATCH] removed unnecessary nullable:false - default behavior --- .../github-issues/135/entity/Post.ts | 24 +++++-- .../github-issues/135/entity/PostAuthor.ts | 32 +++++---- .../github-issues/135/entity/PostCategory.ts | 32 +++++---- .../github-issues/39/entity/Post.ts | 48 +++++++------- .../github-issues/39/entity/User.ts | 1 - .../github-issues/57/entity/Post.ts | 31 +++++---- .../github-issues/58/entity/feedextrainfo.ts | 65 ++++++++++--------- .../github-issues/58/entity/quests.ts | 35 +++++----- .../github-issues/58/entity/users.ts | 41 ++++++------ .../github-issues/65/entity/Post.ts | 29 +++++---- .../github-issues/65/entity/PostAuthor.ts | 31 +++++---- .../github-issues/65/entity/PostReader.ts | 29 ++++++--- .../github-issues/71/entity/PostAuthor.ts | 36 +++++----- .../github-issues/71/entity/PostCategory.ts | 41 +++++++----- .../github-issues/71/entity/PostDetails.ts | 39 ++++++----- .../github-issues/71/entity/PostReader.ts | 30 +++++---- 16 files changed, 317 insertions(+), 227 deletions(-) diff --git a/test/integration/github-issues/135/entity/Post.ts b/test/integration/github-issues/135/entity/Post.ts index cdce663..16e94c3 100644 --- a/test/integration/github-issues/135/entity/Post.ts +++ b/test/integration/github-issues/135/entity/Post.ts @@ -1,14 +1,26 @@ -import { Index, Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable } from "typeorm"; +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}) +@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" }) @@ -18,9 +30,7 @@ export class Post { @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 index db8ca99..5b8998f 100644 --- a/test/integration/github-issues/135/entity/PostAuthor.ts +++ b/test/integration/github-issues/135/entity/PostAuthor.ts @@ -1,20 +1,26 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +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; - - + @Column("int", { + primary: true, + name: "Id" + }) + Id: number; @OneToMany(type => Post, Post => Post.Id) - posts:Post[]; - + posts: Post[]; } diff --git a/test/integration/github-issues/135/entity/PostCategory.ts b/test/integration/github-issues/135/entity/PostCategory.ts index 5804e3f..7d61e7e 100644 --- a/test/integration/github-issues/135/entity/PostCategory.ts +++ b/test/integration/github-issues/135/entity/PostCategory.ts @@ -1,20 +1,26 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +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; - - + @Column("int", { + primary: true, + name: "Id" + }) + Id: number; @OneToMany(type => Post, Post => Post.Id) - posts:Post[]; - + posts: Post[]; } diff --git a/test/integration/github-issues/39/entity/Post.ts b/test/integration/github-issues/39/entity/Post.ts index 378587a..f5ad32b 100644 --- a/test/integration/github-issues/39/entity/Post.ts +++ b/test/integration/github-issues/39/entity/Post.ts @@ -1,28 +1,30 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, JoinColumn} from "typeorm"; -import {User} from "./User"; +import { + Index, + Entity, + PrimaryColumn, + Column, + OneToOne, + OneToMany, + ManyToOne, + JoinColumn +} from "typeorm"; +import { User } from "./User"; - -@Entity("Post",{schema:"sch1"}) +@Entity("Post", { schema: "sch1" }) export class Post { + @Column("integer", { + primary: true, + name: "id" + }) + id: number; - @Column("integer",{ - nullable:false, - primary:true, - name:"id" - }) - id:number; - - - - @ManyToOne(type=>User, userId=>userId.posts) - @JoinColumn({ name:"userId"}) - userId:User; - - - @Column("text",{ - nullable:true, - name:"body" - }) - body:string; + @ManyToOne(type => User, userId => userId.posts) + @JoinColumn({ name: "userId" }) + userId: User; + @Column("text", { + nullable: true, + name: "body" + }) + body: string; } diff --git a/test/integration/github-issues/39/entity/User.ts b/test/integration/github-issues/39/entity/User.ts index a709565..6736995 100644 --- a/test/integration/github-issues/39/entity/User.ts +++ b/test/integration/github-issues/39/entity/User.ts @@ -6,7 +6,6 @@ import {Post} from "./Post"; export class User { @Column("integer",{ - nullable:false, primary:true, name:"id" }) diff --git a/test/integration/github-issues/57/entity/Post.ts b/test/integration/github-issues/57/entity/Post.ts index b7fdf4e..69eee28 100644 --- a/test/integration/github-issues/57/entity/Post.ts +++ b/test/integration/github-issues/57/entity/Post.ts @@ -1,20 +1,25 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, JoinColumn} from "typeorm"; - +import { + Index, + Entity, + PrimaryColumn, + Column, + OneToOne, + OneToMany, + ManyToOne, + JoinColumn +} from "typeorm"; @Entity("Post") export class Post { + @Column("integer", { + primary: true, + name: "id" + }) + id: number; - @Column("integer",{ - nullable:false, - primary:true, - name:"id" - }) - id:number; + @Column({ unique: true }) + body: string; - @Column({unique:true}) - body:string; - @Column() - body2:string; - + body2: string; } diff --git a/test/integration/github-issues/58/entity/feedextrainfo.ts b/test/integration/github-issues/58/entity/feedextrainfo.ts index 2721cb9..02f141c 100644 --- a/test/integration/github-issues/58/entity/feedextrainfo.ts +++ b/test/integration/github-issues/58/entity/feedextrainfo.ts @@ -1,36 +1,43 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm"; -import {users} from "./users"; -import {quests} from "./quests"; - +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",],{unique:true}) -@Index("feedExtraInfo_ReaderId_idx",["readerId",],{unique:true}) -@Index("feedExtraInfo_QuestId_idx",["questId",],{unique:true}) +@Index("feedExtraInfo_FeedOwnerId_idx", ["feedOwnerId"], { unique: true }) +@Index("feedExtraInfo_ReaderId_idx", ["readerId"], { unique: true }) +@Index("feedExtraInfo_QuestId_idx", ["questId"], { unique: true }) export class feedextrainfo { + @OneToOne(type => users, FeedOwnerId => FeedOwnerId.feedextrainfo, { + primary: true + }) + @JoinColumn({ name: "FeedOwnerId" }) + feedOwnerId: users; + @OneToOne(type => quests, QuestId => QuestId.feedextrainfo, { + primary: true + }) + @JoinColumn({ name: "QuestId" }) + questId: quests; - @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; + @OneToOne(type => users, ReaderId => ReaderId.feedextrainfo2, { + primary: true + }) + @JoinColumn({ name: "ReaderId" }) + readerId: users; + @Column("int", { + name: "MostUpdatedFeedEntryIdUserRead" + }) + MostUpdatedFeedEntryIdUserRead: number; } diff --git a/test/integration/github-issues/58/entity/quests.ts b/test/integration/github-issues/58/entity/quests.ts index acdc56d..6c8e0bc 100644 --- a/test/integration/github-issues/58/entity/quests.ts +++ b/test/integration/github-issues/58/entity/quests.ts @@ -1,20 +1,25 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm"; -import {feedextrainfo} from "./feedextrainfo"; - +import { + Index, + Entity, + PrimaryColumn, + Column, + OneToOne, + OneToMany, + ManyToOne, + ManyToMany, + JoinColumn, + JoinTable +} from "typeorm"; +import { feedextrainfo } from "./feedextrainfo"; @Entity("quests") export class quests { + @Column("int", { + primary: true, + name: "QuestId" + }) + QuestId: number; - @Column("int",{ - nullable:false, - primary:true, - name:"QuestId" - }) - QuestId:number; - - - - @OneToOne(type=>feedextrainfo, feedextrainfo=>feedextrainfo.questId) - feedextrainfo:feedextrainfo; - + @OneToOne(type => feedextrainfo, feedextrainfo => feedextrainfo.questId) + feedextrainfo: feedextrainfo; } diff --git a/test/integration/github-issues/58/entity/users.ts b/test/integration/github-issues/58/entity/users.ts index 754e1e1..fe57631 100644 --- a/test/integration/github-issues/58/entity/users.ts +++ b/test/integration/github-issues/58/entity/users.ts @@ -1,25 +1,28 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm"; -import {feedextrainfo} from "./feedextrainfo"; - +import { + Index, + Entity, + PrimaryColumn, + Column, + OneToOne, + OneToMany, + ManyToOne, + ManyToMany, + JoinColumn, + JoinTable +} from "typeorm"; +import { feedextrainfo } from "./feedextrainfo"; @Entity("users") export class users { + @Column("int", { + primary: true, + name: "UserId" + }) + UserId: number; - @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; + @OneToOne(type => feedextrainfo, feedextrainfo => feedextrainfo.feedOwnerId) + feedextrainfo: feedextrainfo; + @OneToOne(type => feedextrainfo, feedextrainfo2 => feedextrainfo2.readerId) + feedextrainfo2: feedextrainfo; } diff --git a/test/integration/github-issues/65/entity/Post.ts b/test/integration/github-issues/65/entity/Post.ts index abe57e9..2596c9e 100644 --- a/test/integration/github-issues/65/entity/Post.ts +++ b/test/integration/github-issues/65/entity/Post.ts @@ -1,24 +1,29 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm"; +import { + Index, + Entity, + PrimaryColumn, + Column, + OneToOne, + OneToMany, + ManyToOne, + ManyToMany, + JoinColumn, + JoinTable +} from "typeorm"; import { PostAuthor } from "./PostAuthor"; import { PostReader } from "./PostReader"; - @Entity("Post") export class Post { - - @Column("int",{ - nullable:false, - primary:true, - name:"Id" - }) - Id:number; - - + @Column("int", { + primary: true, + name: "Id" + }) + Id: number; @OneToOne(type => PostAuthor, PostAuthor => PostAuthor.Id) postAuthor: PostAuthor; @OneToMany(type => PostReader, PostReader => PostReader.Id) postReaders: PostReader[]; - } diff --git a/test/integration/github-issues/65/entity/PostAuthor.ts b/test/integration/github-issues/65/entity/PostAuthor.ts index 8ff3809..ab27fd7 100644 --- a/test/integration/github-issues/65/entity/PostAuthor.ts +++ b/test/integration/github-issues/65/entity/PostAuthor.ts @@ -1,22 +1,29 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +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; - - + @Column("int", { + primary: true, + name: "Id" + }) + Id: number; @OneToOne(type => Post, Post => Post.Id) @JoinColumn() - post:Post; + post: Post; @RelationId((postAuthor: PostAuthor) => postAuthor.post) postId: number; diff --git a/test/integration/github-issues/65/entity/PostReader.ts b/test/integration/github-issues/65/entity/PostReader.ts index 1fcc60e..864a73b 100644 --- a/test/integration/github-issues/65/entity/PostReader.ts +++ b/test/integration/github-issues/65/entity/PostReader.ts @@ -1,20 +1,29 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +import { + Index, + Entity, + PrimaryColumn, + Column, + OneToOne, + OneToMany, + ManyToOne, + ManyToMany, + JoinColumn, + JoinTable, + RelationId +} from "typeorm"; import { Post } from "./Post"; - @Entity("PostReader") export class PostReader { - - @Column("int",{ - nullable:false, - primary:true, - name:"Id" - }) - Id:number; + @Column("int", { + primary: true, + name: "Id" + }) + Id: number; @ManyToOne(type => Post, Post => Post.Id) @JoinColumn() - post:Post; + post: Post; @RelationId((postReader: PostReader) => postReader.post) postId: number[]; diff --git a/test/integration/github-issues/71/entity/PostAuthor.ts b/test/integration/github-issues/71/entity/PostAuthor.ts index 70fcfc7..18a2431 100644 --- a/test/integration/github-issues/71/entity/PostAuthor.ts +++ b/test/integration/github-issues/71/entity/PostAuthor.ts @@ -1,24 +1,30 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +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", { + primary: true, + name: "Id" + }) + Id: number; - @Column("int",{ - nullable:false, - primary:true, - name:"Id" - }) - Id:number; - - - - @OneToOne(type => Post, Post => Post.Id,{ - onDelete: "CASCADE", + @OneToOne(type => Post, Post => Post.Id, { + onDelete: "CASCADE" // onUpdate: "CASCADE" }) @JoinColumn() - post:Post; - + post: Post; } diff --git a/test/integration/github-issues/71/entity/PostCategory.ts b/test/integration/github-issues/71/entity/PostCategory.ts index 688d343..25f36fb 100644 --- a/test/integration/github-issues/71/entity/PostCategory.ts +++ b/test/integration/github-issues/71/entity/PostCategory.ts @@ -1,25 +1,30 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +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", { + primary: true, + name: "Id" + }) + Id: number; - @Column("int",{ - nullable:false, - primary:true, - name:"Id" - }) - Id:number; - - - - @OneToOne(type => Post, Post => Post.Id, - { - // onDelete: "RESTRICT", - // onUpdate: "RESTRICT" - }) + @OneToOne(type => Post, Post => Post.Id, { + // onDelete: "RESTRICT", + // onUpdate: "RESTRICT" + }) @JoinColumn() - post:Post; - + post: Post; } diff --git a/test/integration/github-issues/71/entity/PostDetails.ts b/test/integration/github-issues/71/entity/PostDetails.ts index 7935433..dc9d754 100644 --- a/test/integration/github-issues/71/entity/PostDetails.ts +++ b/test/integration/github-issues/71/entity/PostDetails.ts @@ -1,23 +1,30 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +import { + Index, + Entity, + PrimaryColumn, + Column, + OneToOne, + OneToMany, + ManyToOne, + ManyToMany, + JoinColumn, + JoinTable, + RelationId +} from "typeorm"; import { Post } from "./Post"; - @Entity("PostDetails") export class PostDetails { + @Column("int", { + primary: true, + name: "Id" + }) + Id: number; - @Column("int",{ - nullable:false, - primary:true, - name:"Id" - }) - Id:number; - - @OneToOne(type => Post, Post => Post.Id, - { - onDelete: "SET NULL", - // onUpdate: "SET NULL" - }) + @OneToOne(type => Post, Post => Post.Id, { + onDelete: "SET NULL" + // onUpdate: "SET NULL" + }) @JoinColumn() - post:Post; - + post: Post; } diff --git a/test/integration/github-issues/71/entity/PostReader.ts b/test/integration/github-issues/71/entity/PostReader.ts index 9e91689..ef232be 100644 --- a/test/integration/github-issues/71/entity/PostReader.ts +++ b/test/integration/github-issues/71/entity/PostReader.ts @@ -1,19 +1,27 @@ -import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm"; +import { + Index, + Entity, + PrimaryColumn, + Column, + OneToOne, + OneToMany, + ManyToOne, + ManyToMany, + JoinColumn, + JoinTable, + RelationId +} from "typeorm"; import { Post } from "./Post"; - @Entity("PostReader") export class PostReader { - - @Column("int",{ - nullable:false, - primary:true, - name:"Id" - }) - Id:number; + @Column("int", { + primary: true, + name: "Id" + }) + Id: number; @OneToOne(type => Post, Post => Post.Id) @JoinColumn() - post:Post; - + post: Post; }