forked from typeorm/typeorm
/
issue-6399.ts
49 lines (42 loc) · 1.59 KB
/
issue-6399.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
48
49
import {Connection} from "../../../src";
import {expect} from "chai";
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../utils/test-utils";
import {Post, TargetPost, Comment} from "./entities";
describe("github issues > #6399 Process extraAppendedAndWhereCondition for inherited entity", () => {
let connections: Connection[];
before(async () => {
return connections = await createTestingConnections({
entities: [Post, TargetPost, Comment],
schemaCreate: true,
dropSchema: true,
enabledDrivers: ["mysql"]
});
});
beforeEach(() => reloadTestingDatabases(connections));
after(() => closeTestingConnections(connections));
it("Query with join and limit for inhered entity", () => Promise.all(connections.map(async (connection) => {
const targetPostRepo = connection.getRepository(TargetPost);
const posts: TargetPost[] = [
{
id: 1,
title: "Post 1",
postType: "TargetPost",
},
{ id: 2,
title: "Post 2",
postType: "TargetPost",
},
{
id: 3,
title: "Post 3",
postType: "TargetPost",
},
];
await targetPostRepo.save(posts);
const result = await targetPostRepo.createQueryBuilder("targetPosts")
.leftJoinAndSelect("targetPosts.comments", "comments")
.take(2)
.getMany();
expect(result.length).eq(2);
})));
});