-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
/
hstore-allow-transformer.ts
47 lines (41 loc) · 1.5 KB
/
hstore-allow-transformer.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
43
44
45
46
47
import "../../utils/test-setup"
import {
createTestingConnections,
closeTestingConnections,
reloadTestingDatabases,
} from "../../utils/test-utils"
import { DataSource } from "../../../src"
import { expect } from "chai"
import { DummyHSTOREEntity } from "./entity/hstore-entity"
describe("other issues > allow HSTORE column type to use transformers", () => {
let connections: DataSource[]
before(
async () =>
(connections = await createTestingConnections({
entities: [__dirname + "/entity/*{.js,.ts}"],
schemaCreate: true,
dropSchema: true,
enabledDrivers: ["postgres"],
})),
)
beforeEach(() => reloadTestingDatabases(connections))
after(() => closeTestingConnections(connections))
it("should use the transformer set in the column options", () =>
Promise.all(
connections.map(async (connection) => {
const repository = connection.getRepository(DummyHSTOREEntity)
const translation = {
en_US: "hello",
fr_FR: "salut",
}
const dummy = repository.create({
translation,
})
await repository.save(dummy)
const dummyEntity = await repository.findOneByOrFail({
id: dummy.id,
})
expect(dummyEntity.translation).to.equal("hello")
}),
))
})