def diff_map(self, incol):
        stmts = []
        base = "ALTER COLUMN %s " % quote_id(self.name)
        # check NOT NULL
        if not hasattr(self, 'not_null') and hasattr(incol, 'not_null'):
            stmts.append(base + "SET NOT NULL")
        if hasattr(self, 'not_null') and not hasattr(incol, 'not_null'):
            stmts.append(base + "DROP NOT NULL")
        # check data types
        if not hasattr(self, 'type'):
            raise ValueError("Column '%s' missing datatype" % self.name)
        if not hasattr(incol, 'type'):
            raise ValueError("Input column '%s' missing datatype" % incol.name)
        if self.type != incol.type:
            # validate type conversion?
            stmts.append(base + "TYPE %s" % incol.type)
        # check DEFAULTs
        if not hasattr(self, 'default') and hasattr(incol, 'default'):
            stmts.append(base + "SET DEFAULT %s" % incol.default)
        if hasattr(self, 'default'):
            if not hasattr(incol, 'default'):
                stmts.append(base + "DROP DEFAULT")
            elif self.default != incol.default:
                stmts.append(base + "SET DEFAULT %s" % incol.default)
        # check STATISTICS
        if hasattr(self, 'statistics'):
            if self.statistics == -1 and (
                hasattr(incol, 'statistics') and incol.statistics != -1):
                stmts.append(base + "SET STATISTICS %d" % incol.statistics)
            if self.statistics != -1 and (
                not hasattr(incol, 'statistics') or incol.statistics == -1):
                stmts.append(base + "SET STATISTICS -1")

        return (", ".join(stmts), self.diff_description(incol))
Generate SQL to transform an existing column
dataset/ETHPy150Open perseas/Pyrseas/pyrseas/dbobject/column.py/Column.diff_map