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

Code before:
                if (this.connection.driver.options.type === "mssql")
                    selectionPath = `${selectionPath}.ToString()`
            }

            const selections = this.expressionMap.selects.filter(
                (select) =>
                    select.selection === aliasName + "." + column.propertyPath,
            )
            if (selections.length) {
                selections.forEach((selection) => {
                    finalSelects.push({
                        selection: selectionPath,
                        aliasName: selection.aliasName
                            ? selection.aliasName
                            : DriverUtils.buildAlias(
                                  this.connection.driver,
                                  undefined,
                                  aliasName,
                                  column.databaseName,
                              ),
                        // todo: need to keep in mind that custom selection.aliasName breaks hydrator. fix it later!
                        virtual: selection.virtual,
                    })
                })
            } else {
                finalSelects.push({
                    selection: selectionPath,
                    aliasName: DriverUtils.buildAlias(
                        this.connection.driver,
                        undefined,
                        aliasName,
                        column.databaseName,
                    ),
                    // todo: need to keep in mind that custom selection.aliasName breaks hydrator. fix it later!
                    virtual: hasMainAlias,
                })
            }
        })
        return finalSelects
    }

    protected findEntityColumnSelects(
        aliasName: string,
        metadata: EntityMetadata,
    ): SelectQuery[] {
        const mainSelect = this.expressionMap.selects.find(
            (select) => select.selection === aliasName,
        )
        if (mainSelect) return [mainSelect]

        return this.expressionMap.selects.filter((select) => {

Review comment (suggestion):
@tolgap This just disables the VirtualColumn feature instead of fixing the issue that it has.

Probably this should've been solved in `RawSqlResultsToEntityTransformer`.

Code after:
                if (this.connection.driver.options.type === "mssql")
                    selectionPath = `${selectionPath}.ToString()`
            }

            const selections = this.expressionMap.selects.filter(
                (select) =>
                    select.selection === aliasName + "." + column.propertyPath,
            )
            if (selections.length) {
                selections.forEach((selection) => {
                    finalSelects.push({
                        selection: selectionPath,
                        aliasName: selection.aliasName
                            ? selection.aliasName
                            : DriverUtils.buildAlias(
                                  this.connection.driver,
                                  undefined,
                                  aliasName,
                                  column.databaseName,
                              ),
                        // todo: need to keep in mind that custom selection.aliasName breaks hydrator. fix it later!
                        virtual: selection.virtual,
                    })
                })
            } else {
                if (column.isVirtualProperty) {
                    // Do not add unselected virtual properties to final select
                    return
                }

                finalSelects.push({
                    selection: selectionPath,
                    aliasName: DriverUtils.buildAlias(
                        this.connection.driver,
                        undefined,
                        aliasName,
                        column.databaseName,
                    ),
                    // todo: need to keep in mind that custom selection.aliasName breaks hydrator. fix it later!
                    virtual: hasMainAlias,
                })
            }
        })
        return finalSelects
    }

    protected findEntityColumnSelects(
        aliasName: string,
        metadata: EntityMetadata,
    ): SelectQuery[] {
        const mainSelect = this.expressionMap.selects.find(