forked from typeorm/typeorm
/
issue-2703.ts
42 lines (34 loc) · 1.56 KB
/
issue-2703.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {expect} from "chai";
import {Connection} from "../../../src/connection/Connection";
import {createTestingConnections, reloadTestingDatabases, closeTestingConnections} from "../../utils/test-utils";
import {Dummy} from "./entity/Dummy";
import {WrappedString} from "./wrapped-string";
import {MemoryLogger} from "./memory-logger";
describe.only("github issues > #2703 Column with transformer is not normalized for update", () => {
let connections: Connection[];
before(async () => connections = await createTestingConnections({
entities: [`${__dirname}/entity/*{.js,.ts}`],
schemaCreate: true,
dropSchema: true,
createLogger: () => new MemoryLogger(false),
}));
beforeEach(() => reloadTestingDatabases(connections));
after(() => closeTestingConnections(connections));
afterEach(() => connections.forEach(connection => {
const logger = connection.logger as MemoryLogger;
logger.enabled = false;
logger.clear();
}));
it("should transform values when computing changed columns", () => Promise.all(connections.map(async connection => {
const repository = connection.getRepository(Dummy);
const dummy = repository.create({
value: new WrappedString("test"),
});
await repository.save(dummy);
const logger = connection.logger as MemoryLogger;
logger.enabled = true;
await repository.save(dummy);
const updateQueries = logger.queries.filter(q => q.startsWith("UPDATE"));
expect(updateQueries).to.be.empty;
})));
});