From 100d79c5e2e450655023e9c2d23b8c9775f03c85 Mon Sep 17 00:00:00 2001 From: Vasil Rangelov Date: Tue, 18 Jun 2019 15:56:52 +0300 Subject: [PATCH 1/7] Added property visibility to RelationId properties --- src/entity.mst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entity.mst b/src/entity.mst index 5a49072..719c657 100644 --- a/src/entity.mst +++ b/src/entity.mst @@ -33,7 +33,7 @@ import {BaseEntity,Column,Entity,Index,JoinColumn,JoinTable,ManyToMany,ManyToOne {{#if relationIdField }} @RelationId(({{../../tsEntityName}}: {{toEntityName ../../tsEntityName}}) => {{../../tsEntityName}}.{{toPropertyName ../tsName}}) - {{toPropertyName ../tsName}}Id: {{#if isOneToOne}}{{toLazy ../tsType}}{{else}}{{toLazy (concat ../tsType "[]")}}{{/if}};{{/if}}{{/relations}} + {{printPropertyVisibility}}{{toPropertyName ../tsName}}Id: {{#if isOneToOne}}{{toLazy ../tsType}}{{else}}{{toLazy (concat ../tsType "[]")}}{{/if}};{{/if}}{{/relations}} {{/Columns}} {{#if GenerateConstructor}} constructor(init?: Partial<{{toEntityName tsEntityName}}>) { From 4868dcbdfa2b98a108569b81f1172f0a805f7a73 Mon Sep 17 00:00:00 2001 From: Vasil Rangelov Date: Thu, 20 Jun 2019 15:54:33 +0300 Subject: [PATCH 2/7] Replaced "Object" with "object" for the generated JSON column type, so that TSLint does not complain about it being too general, while still preserving the same semantics. --- src/drivers/MysqlDriver.ts | 2 +- src/drivers/PostgresDriver.ts | 14 +++++++------- src/models/ColumnInfo.ts | 4 ++-- .../integration/entityTypes/mariadb/entity/Post.ts | 2 +- .../entityTypes/postgres/entity/Post.ts | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/drivers/MysqlDriver.ts b/src/drivers/MysqlDriver.ts index 11e43a4..23c0c0f 100644 --- a/src/drivers/MysqlDriver.ts +++ b/src/drivers/MysqlDriver.ts @@ -163,7 +163,7 @@ export class MysqlDriver extends AbstractDriver { ).replace(/\'/gi, '"'); break; case "json": - colInfo.tsType = "Object"; + colInfo.tsType = "object"; break; case "binary": colInfo.tsType = "Buffer"; diff --git a/src/drivers/PostgresDriver.ts b/src/drivers/PostgresDriver.ts index 2c2fd0c..6881b91 100644 --- a/src/drivers/PostgresDriver.ts +++ b/src/drivers/PostgresDriver.ts @@ -159,8 +159,8 @@ export class PostgresDriver extends AbstractDriver { | "boolean" | "Date" | "Buffer" - | "Object" - | "string | Object" + | "object" + | "string | object" | "string | string[]" | "any" | null; @@ -288,7 +288,7 @@ export class PostgresDriver extends AbstractDriver { ret.ts_type = "string"; break; case "point": - ret.ts_type = "string | Object"; + ret.ts_type = "string | object"; break; case "line": ret.ts_type = "string"; @@ -297,7 +297,7 @@ export class PostgresDriver extends AbstractDriver { ret.ts_type = "string | string[]"; break; case "box": - ret.ts_type = "string | Object"; + ret.ts_type = "string | object"; break; case "path": ret.ts_type = "string"; @@ -306,7 +306,7 @@ export class PostgresDriver extends AbstractDriver { ret.ts_type = "string"; break; case "circle": - ret.ts_type = "string | Object"; + ret.ts_type = "string | object"; break; case "cidr": ret.ts_type = "string"; @@ -330,10 +330,10 @@ export class PostgresDriver extends AbstractDriver { ret.ts_type = "string"; break; case "json": - ret.ts_type = "Object"; + ret.ts_type = "object"; break; case "jsonb": - ret.ts_type = "Object"; + ret.ts_type = "object"; break; case "int4range": ret.ts_type = "string"; diff --git a/src/models/ColumnInfo.ts b/src/models/ColumnInfo.ts index 24307c6..6b7f167 100644 --- a/src/models/ColumnInfo.ts +++ b/src/models/ColumnInfo.ts @@ -10,8 +10,8 @@ export class ColumnInfo { | "boolean" | "Date" | "Buffer" - | "Object" - | "string | Object" + | "object" + | "string | object" | "string | string[]" | "any"; public relations: RelationInfo[] = []; diff --git a/test/integration/entityTypes/mariadb/entity/Post.ts b/test/integration/entityTypes/mariadb/entity/Post.ts index 491f16b..bdd5343 100644 --- a/test/integration/entityTypes/mariadb/entity/Post.ts +++ b/test/integration/entityTypes/mariadb/entity/Post.ts @@ -89,7 +89,7 @@ export class Post { // In mariaDb Json is recognized as longtext // @Column("json") - // json: Object; + // json: object; @Column("binary") binary: Buffer; diff --git a/test/integration/entityTypes/postgres/entity/Post.ts b/test/integration/entityTypes/postgres/entity/Post.ts index 79f26dc..c422050 100644 --- a/test/integration/entityTypes/postgres/entity/Post.ts +++ b/test/integration/entityTypes/postgres/entity/Post.ts @@ -123,7 +123,7 @@ export class Post { // enum: string; @Column("point") - point: string | Object; + point: string | object; @Column("line") line: string; @@ -132,7 +132,7 @@ export class Post { lseg: string | string[]; @Column("box") - box: string | Object; + box: string | object; @Column("path") path: string; @@ -141,7 +141,7 @@ export class Post { polygon: string; @Column("circle") - circle: string | Object; + circle: string | object; @Column("cidr") cidr: string; From 2240cc3aebd2c9e90c9a6862851af1cf6cee4ec2 Mon Sep 17 00:00:00 2001 From: Vasil Rangelov Date: Tue, 2 Jul 2019 15:18:47 +0300 Subject: [PATCH 3/7] Added support for UNSIGNED columns in MySQL. --- src/drivers/MysqlDriver.ts | 3 +++ src/entity.mst | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/drivers/MysqlDriver.ts b/src/drivers/MysqlDriver.ts index 11e43a4..3ba911f 100644 --- a/src/drivers/MysqlDriver.ts +++ b/src/drivers/MysqlDriver.ts @@ -72,6 +72,9 @@ export class MysqlDriver extends AbstractDriver { resp.COLUMN_DEFAULT ); colInfo.options.type = resp.DATA_TYPE as any; + colInfo.options.unsigned = resp.COLUMN_TYPE.endsWith( + " unsigned" + ); switch (resp.DATA_TYPE) { case "int": colInfo.tsType = "number"; diff --git a/src/entity.mst b/src/entity.mst index 5a49072..eacaa33 100644 --- a/src/entity.mst +++ b/src/entity.mst @@ -15,7 +15,8 @@ import {BaseEntity,Column,Entity,Index,JoinColumn,JoinTable,ManyToMany,ManyToOne primary:{{primary}},{{/primary}}{{/generated}}{{#unique}} unique: true,{{/unique}}{{#length}} length:{{.}},{{/length}}{{#width}} - width:{{.}},{{/width}}{{#default}} + width:{{.}},{{/width}}{{#unsigned}} + unsigned: true,{{/unsigned}}{{#default}} default: {{.}},{{/default}}{{#precision}} precision:{{.}},{{/precision}}{{#scale}} scale:{{.}},{{/scale}}{{#enum}} From ac985b0a61d0e338b95387de19933486b40d84d6 Mon Sep 17 00:00:00 2001 From: Kononnable Date: Tue, 9 Jul 2019 22:31:04 +0200 Subject: [PATCH 4/7] fixing tests --- test/integration/entityTypes/mysql/entity/Post.ts | 2 +- test/integration/entityTypes/postgres/entity/Post.ts | 4 ++-- .../entityTypes/postgres/entity/PostArrays.ts | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integration/entityTypes/mysql/entity/Post.ts b/test/integration/entityTypes/mysql/entity/Post.ts index 6e468d9..60c5282 100644 --- a/test/integration/entityTypes/mysql/entity/Post.ts +++ b/test/integration/entityTypes/mysql/entity/Post.ts @@ -88,7 +88,7 @@ export class Post { enum: string; @Column("json") - json: Object; + json: object; @Column("binary") binary: Buffer; diff --git a/test/integration/entityTypes/postgres/entity/Post.ts b/test/integration/entityTypes/postgres/entity/Post.ts index c422050..3bf7985 100644 --- a/test/integration/entityTypes/postgres/entity/Post.ts +++ b/test/integration/entityTypes/postgres/entity/Post.ts @@ -165,10 +165,10 @@ export class Post { xml: string; @Column("json") - json: Object; + json: object; @Column("jsonb") - jsonb: Object; + jsonb: object; @Column("int4range") int4range: string; diff --git a/test/integration/entityTypes/postgres/entity/PostArrays.ts b/test/integration/entityTypes/postgres/entity/PostArrays.ts index d880503..fde1012 100644 --- a/test/integration/entityTypes/postgres/entity/PostArrays.ts +++ b/test/integration/entityTypes/postgres/entity/PostArrays.ts @@ -123,7 +123,7 @@ export class PostArrays { // enum: string[]; @Column("point", { array: true }) - point: string[] | Object[]; + point: string[] | object[]; @Column("line", { array: true }) line: string[]; @@ -132,7 +132,7 @@ export class PostArrays { lseg: string[] | string[][]; @Column("box", { array: true }) - box: string[] | Object[]; + box: string[] | object[]; @Column("path", { array: true }) path: string[]; @@ -141,7 +141,7 @@ export class PostArrays { polygon: string[]; @Column("circle", { array: true }) - circle: string[] | Object[]; + circle: string[] | object[]; @Column("cidr", { array: true }) cidr: string[]; @@ -165,10 +165,10 @@ export class PostArrays { xml: string[]; @Column("json", { array: true }) - json: Object[]; + json: object[]; @Column("jsonb", { array: true }) - jsonb: Object[]; + jsonb: object[]; @Column("int4range", { array: true }) int4range: string[]; From b89542a4d1b7223637d0df7595e74852131339f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jul 2019 07:33:13 +0000 Subject: [PATCH 5/7] Bump lodash from 4.17.11 to 4.17.14 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.14. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.14) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index ec320e4..56ee124 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2959,9 +2959,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==" }, "lodash.flattendeep": { "version": "4.4.0", From df20deef142dab4f4e92383ae1849702d4ca2b83 Mon Sep 17 00:00:00 2001 From: Kononnable Date: Fri, 19 Jul 2019 10:48:21 +0200 Subject: [PATCH 6/7] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index a57a805..1e09d79 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # typeorm-model-generator -[![Greenkeeper badge](https://badges.greenkeeper.io/Kononnable/typeorm-model-generator.svg)](https://greenkeeper.io/) [![Build Status](https://travis-ci.org/Kononnable/typeorm-model-generator.svg?branch=master)](https://travis-ci.org/Kononnable/typeorm-model-generator) [![npm version](https://badge.fury.io/js/typeorm-model-generator.svg)](https://badge.fury.io/js/typeorm-model-generator) [![codecov](https://codecov.io/gh/Kononnable/typeorm-model-generator/branch/master/graph/badge.svg)](https://codecov.io/gh/Kononnable/typeorm-model-generator) From 71c4f0ea7329f90aa53da77b94da8f3e95e6067d Mon Sep 17 00:00:00 2001 From: Pawe Kotarski Date: Fri, 19 Jul 2019 11:21:33 +0200 Subject: [PATCH 7/7] add test --- test/integration/entityTypes/mysql/entity/Post.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/integration/entityTypes/mysql/entity/Post.ts b/test/integration/entityTypes/mysql/entity/Post.ts index 6e468d9..9b71cbf 100644 --- a/test/integration/entityTypes/mysql/entity/Post.ts +++ b/test/integration/entityTypes/mysql/entity/Post.ts @@ -15,10 +15,13 @@ export class Post { @Column("int") int: number; + @Column("int", { unsigned: true }) + uint: number; + @Column("tinyint") tinyint: number; - @Column("tinyint",{width:1}) + @Column("tinyint", { width: 1 }) boolean: boolean; @Column("smallint")