mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
fixes #463
This commit is contained in:
parent
f536c1144d
commit
f2d958ebf7
@ -88,7 +88,7 @@ This code will log all queries which run more then `1 second`.
|
||||
There are several loggers TypeORM ships with 3 different types of loggers:
|
||||
|
||||
* `advanced-console` - this is default logger which logs all messages into console using color
|
||||
and sql syntax highlighting (using [chalk]() package)
|
||||
and sql syntax highlighting (using [chalk](https://github.com/chalk/chalk) package)
|
||||
* `simple-console` - this is simple console logger which is exactly the same as advanced, but it does not use any color highlighting.
|
||||
This logger can be used if you have problems / or don't like colorized logs
|
||||
* `file` - this logger writes all logs into `ormlogs.log` file in the root folder of your project (near `package.json` and `ormconfig.json`)
|
||||
|
||||
@ -161,7 +161,11 @@ export class DateUtils {
|
||||
*/
|
||||
static stringToSimpleArray(value: string|any): string|any {
|
||||
if (value instanceof String || typeof value === "string") {
|
||||
return value.split(",");
|
||||
if (value.length > 0) {
|
||||
return value.split(",");
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
14
test/github-issues/463/entity/Post.ts
Normal file
14
test/github-issues/463/entity/Post.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {Entity} from "../../../../src/decorator/entity/Entity";
|
||||
import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn";
|
||||
import {Column} from "../../../../src/decorator/columns/Column";
|
||||
|
||||
@Entity()
|
||||
export class Post {
|
||||
|
||||
@PrimaryColumn()
|
||||
id: number;
|
||||
|
||||
@Column("simple-array")
|
||||
names: string[];
|
||||
|
||||
}
|
||||
28
test/github-issues/463/issue-463.ts
Normal file
28
test/github-issues/463/issue-463.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import "reflect-metadata";
|
||||
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../utils/test-utils";
|
||||
import {Connection} from "../../../src/connection/Connection";
|
||||
import {Post} from "./entity/Post";
|
||||
|
||||
describe.only("github issues > #463 saving empty string array", () => {
|
||||
|
||||
let connections: Connection[];
|
||||
before(async () => connections = await createTestingConnections({
|
||||
entities: [__dirname + "/entity/*{.js,.ts}"],
|
||||
enabledDrivers: ["postgres"],
|
||||
schemaCreate: true,
|
||||
dropSchemaOnConnection: true,
|
||||
}));
|
||||
beforeEach(() => reloadTestingDatabases(connections));
|
||||
after(() => closeTestingConnections(connections));
|
||||
|
||||
it("should not return array with single empty string if empty array was saved", () => Promise.all(connections.map(async connection => {
|
||||
const post = new Post();
|
||||
post.id = 1;
|
||||
post.names = [];
|
||||
await connection.getRepository(Post).persist(post);
|
||||
const loadedPost = await connection.getRepository(Post).findOneById(1);
|
||||
console.log(loadedPost);
|
||||
loadedPost!.names.length.should.be.eql(0);
|
||||
})));
|
||||
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user