Repository: typeorm/typeorm
File: test/other-issues/lazy-count/lazy-count.ts (TypeScript)

Code before:
        Promise.all(
            connections.map(async function (connection) {
                await savePostEntities(connection, 2)

                const afterQuery = connection
                    .subscribers[0] as AfterQuerySubscriber
                afterQuery.clear()

                const [entities, count] = await connection.manager
                    .createQueryBuilder(Post, "post")
                    .take(2)
                    .orderBy("post.id")
                    .getManyAndCount()

                expect(count).to.be.equal(2)
                expect(entities.length).to.be.equal(2)

                expect(
                    afterQuery
                        .getCalledQueries()
                        .filter((query) => query.match(/(count|cnt)/i)),
                ).not.to.be.empty
            }),
        ))

    it("skip count query when joining a subentity with a take", () =>
        Promise.all(
            connections.map(async function (connection) {
                await savePostEntities(connection, 5)

                const afterQuery = connection
                    .subscribers[0] as AfterQuerySubscriber
                afterQuery.clear()

                const [entities, count] = await connection.manager
                    .createQueryBuilder(Post, "post")
                    .innerJoin("post.comments", "comments")
                    .take(20)
                    .orderBy("post.id")
                    .getManyAndCount()

                expect(count).to.be.equal(5)
                expect(entities.length).to.be.equal(5)

                expect(
                    afterQuery
                        .getCalledQueries()
                        .filter((query) => query.match(/(count|cnt)/i)),
                ).to.be.empty
            }),
        ))

Review comment (suggestion):
```suggestion
    it("skip count query when joining a relation with a take", () =>
```

Code after:
        Promise.all(
            connections.map(async function (connection) {
                await savePostEntities(connection, 2)

                const afterQuery = connection
                    .subscribers[0] as AfterQuerySubscriber
                afterQuery.clear()

                const [entities, count] = await connection.manager
                    .createQueryBuilder(Post, "post")
                    .take(2)
                    .orderBy("post.id")
                    .getManyAndCount()

                expect(count).to.be.equal(2)
                expect(entities.length).to.be.equal(2)

                expect(
                    afterQuery
                        .getCalledQueries()
                        .filter((query) => query.match(/(count|cnt)/i)),
                ).not.to.be.empty
            }),
        ))

    it("skip count query when joining a relation with a take", () =>
        Promise.all(
            connections.map(async function (connection) {
                await savePostEntities(connection, 5)

                const afterQuery = connection
                    .subscribers[0] as AfterQuerySubscriber
                afterQuery.clear()

                const [entities, count] = await connection.manager
                    .createQueryBuilder(Post, "post")
                    .innerJoin("post.comments", "comments")
                    .take(20)
                    .orderBy("post.id")
                    .getManyAndCount()

                expect(count).to.be.equal(5)
                expect(entities.length).to.be.equal(5)

                expect(
                    afterQuery
                        .getCalledQueries()
                        .filter((query) => query.match(/(count|cnt)/i)),
                ).to.be.empty
            }),
        ))