use Carp;
use DBIx::DBSchema::_util qw(_load_driver _dbh);
-$VERSION = '0.12';
+$VERSION = '0.13';
=head1 NAME
my $default;
my $orig_default = $self->default;
if ( $driver_class->can("_column_value_needs_quoting") ) {
- if ($driver_class->_column_value_needs_quoting($self)) {
+ if ( $driver_class->_column_value_needs_quoting($self)
+ && !ref($self->default)
+ )
+ {
$default = $dbh->quote($self->default);
} else {
$default = ref($self->default) ? ${$self->default} : $self->default;
my $dbd = "DBIx::DBSchema::DBD::$driver";
my $hashref = $dbd->alter_column_callback( $dbh, $table, $self, $new );
- # change the name...
+ if ( $hashref->{'sql_alter'} ) {
- # change the type...
-
- if ( $hashref->{'sql_alter_null' } ) {
-
- push @sql, $hashref->{'sql_alter_null'};
+ push @sql, $hashref->{'sql_alter'};
} else {
- # change nullability from NOT NULL to NULL
- if ( ! $self->null && $new->null ) {
-
- push @sql, "ALTER TABLE $table ALTER COLUMN $name DROP NOT NULL";
-
+ # change the name...
+ # not yet implemented. how do we tell which old column it was?
+
+ # change the type...
+ if ( $hashref->{'sql_alter_type'} ) {
+ push @sql, $hashref->{'sql_alter_type'};
}
-
- # change nullability from NULL to NOT NULL...
- # this one could be more complicated, need to set a DEFAULT value and update
- # the table first...
- if ( $self->null && ! $new->null ) {
-
- push @sql, "ALTER TABLE $table ALTER COLUMN $name SET NOT NULL";
-
+
+ # change nullability...
+
+ if ( $hashref->{'sql_alter_null'} ) {
+
+ push @sql, $hashref->{'sql_alter_null'};
+
+ } else {
+
+ # change nullability from NOT NULL to NULL
+ if ( ! $self->null && $new->null ) {
+
+ push @sql, "ALTER TABLE $table ALTER COLUMN $name DROP NOT NULL";
+
+ }
+
+ # change nullability from NULL to NOT NULL...
+ # this one could be more complicated, need to set a DEFAULT value and update
+ # the table first...
+ if ( $self->null && ! $new->null ) {
+
+ push @sql, "ALTER TABLE $table ALTER COLUMN $name SET NOT NULL";
+
+ }
+
}
+ # change default
+
+ # change other stuff...
+
}
-
- # change other stuff...
@sql;