From c47cf7ecbd6ffdb5cdfb98d6da0fc7f20f97c5a3 Mon Sep 17 00:00:00 2001 From: Zotov Dmitry Date: Sat, 31 Mar 2018 11:56:57 +0500 Subject: [PATCH] added test for #1388 --- docker-compose.yml | 12 ++++++++++++ test/github-issues/1388/entity/Post.ts | 12 ++++++++++++ test/github-issues/1388/issue-1388.ts | 25 +++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 test/github-issues/1388/entity/Post.ts create mode 100644 test/github-issues/1388/issue-1388.ts diff --git a/docker-compose.yml b/docker-compose.yml index 3490c7917..4e95596f4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,18 @@ version: '3' services: + # mysql-5.5 + #mysql5.5: + # image: "mysql:5.5" + # container_name: "typeorm-mysql-5.5" + # ports: + # - "3306:3306" + # environment: + # MYSQL_ROOT_PASSWORD: "admin" + # MYSQL_USER: "test" + # MYSQL_PASSWORD: "test" + # MYSQL_DATABASE: "test" + # mysql mysql: image: "mysql:5.7.10" diff --git a/test/github-issues/1388/entity/Post.ts b/test/github-issues/1388/entity/Post.ts new file mode 100644 index 000000000..5d695d800 --- /dev/null +++ b/test/github-issues/1388/entity/Post.ts @@ -0,0 +1,12 @@ +import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src"; + +@Entity() +export class Post { + + @PrimaryGeneratedColumn() + id: number; + + @Column({ type: "timestamp", nullable: true }) + createdAt: Date; + +} \ No newline at end of file diff --git a/test/github-issues/1388/issue-1388.ts b/test/github-issues/1388/issue-1388.ts new file mode 100644 index 000000000..dbe658438 --- /dev/null +++ b/test/github-issues/1388/issue-1388.ts @@ -0,0 +1,25 @@ +import "reflect-metadata"; +import {Connection} from "../../../src/connection/Connection"; +import {closeTestingConnections, createTestingConnections} from "../../utils/test-utils"; + +describe("github issues > #1388 nullable: true dons't output 'NULL' in mysql", () => { + + let connections: Connection[]; + before(async () => { + connections = await createTestingConnections({ + entities: [__dirname + "/entity/*{.js,.ts}"], + enabledDrivers: ["mysql"], + schemaCreate: true, + dropSchema: true, + }); + }); + after(() => closeTestingConnections(connections)); + + it("should correctly create nullable column", () => Promise.all(connections.map(async connection => { + const queryRunner = connection.createQueryRunner(); + const table = await queryRunner.getTable("post"); + table!.findColumnByName("createdAt")!.isNullable.should.be.true; + await queryRunner.release(); + }))); + +});