Repository: typeorm/typeorm
File: src/driver/DriverUtils.ts (TypeScript)

Code before:
    /**
     * Joins and shortens alias if needed.
     *
     * If the alias length is greater than the limit allowed by the current
     * driver, replaces it with a shortend string, if the shortend string
     * is still too long, it will then hash the alias.
     *
     * @param driver Current `Driver`.
     * @param buildOptions Optional settings.
     * @param alias Alias parts.
     *
     * @return An alias that is no longer than the divers max alias length.
     */
    static buildAlias(
        { maxAliasLength }: Driver,
        buildOptions: { shorten?: boolean; joiner?: string } | undefined,
        ...alias: string[]
    ): string {
        const joiner =
            buildOptions && buildOptions.joiner ? buildOptions.joiner : "_"

        let newAlias = alias.length === 1 ? alias[0] : alias.join(joiner)

        const hasNestedRelations = newAlias.includes(".")
        if (hasNestedRelations) {
            newAlias = newAlias.replace(/\./g, joiner)
        }

        if (
            maxAliasLength &&
            maxAliasLength > 0 &&
            newAlias.length > maxAliasLength
        ) {
            if (buildOptions && buildOptions.shorten === true) {
                const shortenedAlias = shorten(newAlias)
                if (shortenedAlias.length < maxAliasLength) {
                    return shortenedAlias
                }
            }

            return hash(newAlias, { length: maxAliasLength })
        }

        return newAlias
    }

    /**
     * @deprecated use `buildAlias` instead.
     */
    static buildColumnAlias(
        { maxAliasLength }: Driver,

Review comment (bug):
Are there some edge cases like dots in table names that would be affected by this? At least in postgres, I am able to create tables with dots and then use double quote marks to show that this is a name.

Code after:
    /**
     * Joins and shortens alias if needed.
     *
     * If the alias length is greater than the limit allowed by the current
     * driver, replaces it with a shortend string, if the shortend string
     * is still too long, it will then hash the alias.
     *
     * @param driver Current `Driver`.
     * @param buildOptions Optional settings.
     * @param alias Alias parts.
     *
     * @return An alias that is no longer than the divers max alias length.
     */
    static buildAlias(
        { maxAliasLength }: Driver,
        buildOptions: { shorten?: boolean; joiner?: string } | undefined,
        ...alias: string[]
    ): string {
        const joiner =
            buildOptions && buildOptions.joiner ? buildOptions.joiner : "_"

        let newAlias = alias.length === 1 ? alias[0] : alias.join(joiner)

        if (
            maxAliasLength &&
            maxAliasLength > 0 &&
            newAlias.length > maxAliasLength
        ) {
            if (buildOptions && buildOptions.shorten === true) {
                const shortenedAlias = shorten(newAlias)
                if (shortenedAlias.length < maxAliasLength) {
                    return shortenedAlias
                }
            }

            return hash(newAlias, { length: maxAliasLength })
        }

        return newAlias
    }

    /**
     * @deprecated use `buildAlias` instead.
     */
    static buildColumnAlias(
        { maxAliasLength }: Driver,
        buildOptions: { shorten?: boolean; joiner?: string } | string,
        ...alias: string[]
    ) {
        if (typeof buildOptions === "string") {
            alias.unshift(buildOptions)