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

Code before:
        }

        if (
            maxResults !== undefined &&
            entitiesAndRaw.entities.length == maxResults
        ) {
            return undefined
        }

        let previousResults = 0
        if (
            this.expressionMap.skip !== undefined &&
            this.expressionMap.skip !== null &&
            this.expressionMap.skip > 0
        ) {
            previousResults = this.expressionMap.skip
        }

        if (
            this.expressionMap.offset !== undefined &&
            this.expressionMap.offset !== null &&
            this.expressionMap.offset > 0
        ) {
            // offset overrides skip when no join is defined
            previousResults = this.expressionMap.offset
        }

        return entitiesAndRaw.entities.length + previousResults
    }

    /**
     * Executes built SQL query and returns raw data stream.
     */
    async stream(): Promise<ReadStream> {
        this.expressionMap.queryEntity = false
        const [sql, parameters] = this.getQueryAndParameters()
        const queryRunner = this.obtainQueryRunner()
        let transactionStartedByUs: boolean = false
        try {
            // start transaction if it was enabled
            if (
                this.expressionMap.useTransaction === true &&
                queryRunner.isTransactionActive === false
            ) {
                await queryRunner.startTransaction()
                transactionStartedByUs = true
            }

            const releaseFn = () => {
                if (queryRunner !== this.queryRunner)
                    // means we created our own query runner

Review comment (suggestion):
```suggestion
        const hasSkip = this.expressionMap.skip !== undefined &&
            this.expressionMap.skip !== null &&
            this.expressionMap.skip > 0
        const hasOffset = this.expressionMap.offset !== undefined &&
            this.expressionMap.offset !== null &&
            this.expressionMap.offset > 0
        // offset overrides skip when no join is defined
        const previousResults = hasOffset
            ? this.expressionMap.offset
            : hasSkip
            ? this.expressionMap.skip
            : 0;
```

Code after:
            maxResults !== undefined &&
            entitiesAndRaw.entities.length === maxResults
        ) {
            // stop here when the result set contains the max number of rows; we need to execute a full count
            return undefined
        }

        const hasSkip =
            this.expressionMap.skip !== undefined &&
            this.expressionMap.skip !== null &&
            this.expressionMap.skip > 0
        const hasOffset =
            this.expressionMap.offset !== undefined &&
            this.expressionMap.offset !== null &&
            this.expressionMap.offset > 0

        // offset overrides skip when no join is defined
        const previousResults: number = hasOffset
            ? this.expressionMap.offset!
            : hasSkip
            ? this.expressionMap.skip!
            : 0

        return entitiesAndRaw.entities.length + previousResults
    }

    /**
     * Executes built SQL query and returns raw data stream.
     */
    async stream(): Promise<ReadStream> {
        this.expressionMap.queryEntity = false
        const [sql, parameters] = this.getQueryAndParameters()
        const queryRunner = this.obtainQueryRunner()
        let transactionStartedByUs: boolean = false
        try {
            // start transaction if it was enabled
            if (
                this.expressionMap.useTransaction === true &&
                queryRunner.isTransactionActive === false
            ) {
                await queryRunner.startTransaction()
                transactionStartedByUs = true
            }

            const releaseFn = () => {
                if (queryRunner !== this.queryRunner)
                    // means we created our own query runner
                    return queryRunner.release()
                return
            }
            const results = queryRunner.stream(