from psycopg2.sql import SQL, Identifier

from .expression import Expression


class Alias(Expression):
    def __init__(self, term, column=None):
        super().__init__(term)
        self.expression = self.term  # TODO: Deprecate
        self.column = column

    # TODO: Deprecate
    @property
    def alias(self):
        return self.expression.alias

    def to_sql(self):
        if self.column:
            column_sql = SQL('.{}').format(Identifier(self.column))
        else:
            column_sql = SQL('')
        return (
            SQL('{}{}').format(
                Identifier(self.alias),
                column_sql
            ),
            ()
        )

e77bc5280c4594231e0a48a4947ce6c8280ecc2b
<mask token>


class Alias(Expression):
    <mask token>
    <mask token>

    def to_sql(self):
        if self.column:
            column_sql = SQL('.{}').format(Identifier(self.column))
        else:
            column_sql = SQL('')
        return SQL('{}{}').format(Identifier(self.alias), column_sql), ()

<mask token>


class Alias(Expression):

    def __init__(self, term, column=None):
        super().__init__(term)
        self.expression = self.term
        self.column = column
    <mask token>

    def to_sql(self):
        if self.column:
            column_sql = SQL('.{}').format(Identifier(self.column))
        else:
            column_sql = SQL('')
        return SQL('{}{}').format(Identifier(self.alias), column_sql), ()

<mask token>


class Alias(Expression):

    def __init__(self, term, column=None):
        super().__init__(term)
        self.expression = self.term
        self.column = column

    @property
    def alias(self):
        return self.expression.alias

    def to_sql(self):
        if self.column:
            column_sql = SQL('.{}').format(Identifier(self.column))
        else:
            column_sql = SQL('')
        return SQL('{}{}').format(Identifier(self.alias), column_sql), ()

from psycopg2.sql import SQL, Identifier
from .expression import Expression


class Alias(Expression):

    def __init__(self, term, column=None):
        super().__init__(term)
        self.expression = self.term
        self.column = column

    @property
    def alias(self):
        return self.expression.alias

    def to_sql(self):
        if self.column:
            column_sql = SQL('.{}').format(Identifier(self.column))
        else:
            column_sql = SQL('')
        return SQL('{}{}').format(Identifier(self.alias), column_sql), ()

from psycopg2.sql import SQL, Identifier

from .expression import Expression


class Alias(Expression):
    def __init__(self, term, column=None):
        super().__init__(term)
        self.expression = self.term  # TODO: Deprecate
        self.column = column

    # TODO: Deprecate
    @property
    def alias(self):
        return self.expression.alias

    def to_sql(self):
        if self.column:
            column_sql = SQL('.{}').format(Identifier(self.column))
        else:
            column_sql = SQL('')
        return (
            SQL('{}{}').format(
                Identifier(self.alias),
                column_sql
            ),
            ()
        )
