added test for #1388

This commit is contained in:
Zotov Dmitry 2018-03-31 11:56:57 +05:00
parent 3e8ae180d5
commit c47cf7ecbd
3 changed files with 49 additions and 0 deletions

View File

@ -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"

View File

@ -0,0 +1,12 @@
import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src";
@Entity()
export class Post {
@PrimaryGeneratedColumn()
id: number;
@Column({ type: "timestamp", nullable: true })
createdAt: Date;
}

View File

@ -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();
})));
});