(self, table, column, type, not_null=None)
return statements
get the statement for setting the column type
get the statement for setting the column type
get the statement for setting the column type
def get_modify_column(self, table, column, type, not_null=None):
        ''' get the statement for setting the column type '''
        # this may not return the type exacty like before like varchar is in place of
        # varchar(256) due to the column type returned from the sql impl
        statements = []
        statements.append('ALTER TABLE "%s" ALTER COLUMN "%s" %s' \
            % (table,column,type))
        if not_null == None:
            return statements
        if not_null:
            # In order to set the column to disallow NULL values,
            # we must first set any current NULL values to the empty string ''.
            statements.append('UPDATE "%s" SET "%s"=\'\' WHERE %s IS NULL' \
            % (table,column, column))

            # Now that any existing NULL values for that column are set to the empty string,
            # proceed to alter the column so that it disallows NULL values.
            statements.append('ALTER TABLE "%s" ALTER COLUMN "%s" %s NOT NULL' \
            % (table,column,type))
        else:
            statements.append('ALTER TABLE "%s" ALTER COLUMN "%s" %s' \
                % (table, column, type))
        return statements
def get_modify_column ( self , table , column , type , not_null = None ) : # this may not return the type exacty like before like varchar is in place of # varchar(256) due to the column type returned from the sql impl statements = [ ] statements . append ( 'ALTER TABLE "%s" ALTER COLUMN "%s" %s' % ( table , column , type ) ) if not_null == None : return statements if not_null : # In order to set the column to disallow NULL values, # we must first set any current NULL values to the empty string ''. statements . append ( 'UPDATE "%s" SET "%s"=\'\' WHERE %s IS NULL' % ( table , column , column ) ) # Now that any existing NULL values for that column are set to the empty string, # proceed to alter the column so that it disallows NULL values. statements . append ( 'ALTER TABLE "%s" ALTER COLUMN "%s" %s NOT NULL' % ( table , column , type ) ) else : statements . append ( 'ALTER TABLE "%s" ALTER COLUMN "%s" %s' % ( table , column , type ) ) return statements