Repository: typeorm/typeorm
File: src/query-builder/SelectQueryBuilder.ts (TypeScript)

Code before:
        queryRunner: QueryRunner,
    ): Promise<number> {
        const countSql = this.computeCountExpression()

        const results = await this.clone()
            .orderBy()
            .groupBy()
            .offset(undefined)
            .limit(undefined)
            .skip(undefined)
            .take(undefined)
            .select(countSql, "cnt")
            .setOption("disable-global-order")
            .loadRawResults(queryRunner)

        if (!results || !results[0] || !results[0]["cnt"]) return 0

        return parseInt(results[0]["cnt"])
    }

    protected async executeExistsQuery(
        queryRunner: QueryRunner,
    ): Promise<boolean> {
        const results = await this.connection
            .createQueryBuilder()
            .from("(SELECT 1 AS row_exists)", "row_exists_tbl")
            .select("*")
            .whereExists(this)
            .limit(1)
            .loadRawResults(queryRunner)

        return results.length > 0
    }

    protected applyFindOptions() {
        // todo: convert relations: string[] to object map to simplify code
        // todo: same with selects

        if (this.expressionMap.mainAlias!.metadata) {
            if (this.findOptions.relationLoadStrategy) {
                this.expressionMap.relationLoadStrategy =
                    this.findOptions.relationLoadStrategy
            }

            if (this.findOptions.comment) {
                this.comment(this.findOptions.comment)
            }

            if (this.findOptions.withDeleted) {
                this.withDeleted()
            }

Review comment (suggestion):
The `FROM` clause is missing. Some dialects allow it, some not. The best thing is to add it manually:
```ts
qb
  .select("1", "row_exists")
  .from("DUMMY", "dummy_tbl")
  .whereExists(this)
``` 

_Later edit:_ The dummy table might be driver-dependent. Maybe the drivers should be able to handle such thing, either by adding `FROM DUMMY` (or something else) when `QueryBuilder#from()` is missing, or `QueryBuilder` could add `fromDummy()`. See https://github.com/typeorm/typeorm/issues/2815#issuecomment-1247843558.

Code after:
        return (
            `COUNT(DISTINCT(` +
            primaryColumns
                .map((c) => `${distinctAlias}.${this.escape(c.databaseName)}`)
                .join(" || '|;|' || ") +
            "))"
        )
    }

    protected async executeCountQuery(
        queryRunner: QueryRunner,
    ): Promise<number> {
        const countSql = this.computeCountExpression()

        const results = await this.clone()
            .orderBy()
            .groupBy()
            .offset(undefined)
            .limit(undefined)
            .skip(undefined)
            .take(undefined)
            .select(countSql, "cnt")
            .setOption("disable-global-order")
            .loadRawResults(queryRunner)

        if (!results || !results[0] || !results[0]["cnt"]) return 0

        return parseInt(results[0]["cnt"])
    }

    protected async executeExistsQuery(
        queryRunner: QueryRunner,
    ): Promise<boolean> {
        const results = await this.connection
            .createQueryBuilder()
            .fromDummy()
            .select("1", "row_exists")
            .whereExists(this)
            .limit(1)
            .loadRawResults(queryRunner)

        return results.length > 0
    }

    protected applyFindOptions() {
        // todo: convert relations: string[] to object map to simplify code
        // todo: same with selects

        if (this.expressionMap.mainAlias!.metadata) {
            if (this.findOptions.relationLoadStrategy) {
                this.expressionMap.relationLoadStrategy =