is_auto_increment for Firebird, refactor _extra_column_info
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / mysql.pm
index 6e26917..f102b3f 100644 (file)
@@ -6,7 +6,7 @@ use base 'DBIx::Class::Schema::Loader::DBI';
 use Carp::Clan qw/^DBIx::Class/;
 use Class::C3;
 
-our $VERSION = '0.04999_12';
+our $VERSION = '0.05003';
 
 =head1 NAME
 
@@ -77,7 +77,7 @@ sub _mysql_table_get_keys {
     if(!exists($self->{_cache}->{_mysql_keys}->{$table})) {
         my %keydata;
         my $dbh = $self->schema->storage->dbh;
-        my $sth = $dbh->prepare("SHOW INDEX FROM `$table`");
+        my $sth = $dbh->prepare('SHOW INDEX FROM '.$self->_table_as_sql($table));
         $sth->execute;
         while(my $row = $sth->fetchrow_hashref) {
             next if $row->{Non_unique};
@@ -117,21 +117,21 @@ sub _table_uniq_info {
 
 sub _extra_column_info {
     no warnings 'uninitialized';
-    my ($self, $info) = @_;
+    my ($self, $table, $col, $info, $dbi_info) = @_;
     my %extra_info;
 
-    if ($info->{mysql_is_auto_increment}) {
+    if ($dbi_info->{mysql_is_auto_increment}) {
         $extra_info{is_auto_increment} = 1
     }
-    if ($info->{mysql_type_name} =~ /\bunsigned\b/i) {
+    if ($dbi_info->{mysql_type_name} =~ /\bunsigned\b/i) {
         $extra_info{extra}{unsigned} = 1;
     }
-    if ($info->{mysql_values}) {
-        $extra_info{extra}{list} = $info->{mysql_values};
+    if ($dbi_info->{mysql_values}) {
+        $extra_info{extra}{list} = $dbi_info->{mysql_values};
     }
-# XXX we need to distinguish between DEFAULT CURRENT_TIMESTAMP and DEFAULT 'foo'
-# somehow, but DBI column_info doesn't preserve quotes.
-    if ($info->{COLUMN_DEF} =~ /^CURRENT_TIMESTAMP\z/i) {
+    if (   $dbi_info->{COLUMN_DEF}      =~ /^CURRENT_TIMESTAMP\z/i
+        && $dbi_info->{mysql_type_name} =~ /^TIMESTAMP\z/i) {
+
         $extra_info{default_value} = \'CURRENT_TIMESTAMP';
     }