new dev release
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / MSSQL.pm
index 3409bf7..d9f0972 100644 (file)
@@ -2,11 +2,14 @@ package DBIx::Class::Schema::Loader::DBI::MSSQL;
 
 use strict;
 use warnings;
-use base 'DBIx::Class::Schema::Loader::DBI';
+use base qw/
+    DBIx::Class::Schema::Loader::DBI
+    DBIx::Class::Schema::Loader::DBI::Sybase::Common
+/;
 use Carp::Clan qw/^DBIx::Class/;
 use Class::C3;
 
-our $VERSION = '0.04999_06';
+our $VERSION = '0.04999_10';
 
 =head1 NAME
 
@@ -31,7 +34,20 @@ sub _setup {
     my $self = shift;
 
     $self->next::method(@_);
-    $self->{db_schema} ||= 'dbo';
+    $self->{db_schema} ||= $self->_build_db_schema;
+    $self->_set_quote_char_and_name_sep;
+}
+
+# remove 'IDENTITY' from column data_type
+sub _columns_info_for {
+    my $self   = shift;
+    my $result = $self->next::method(@_);
+
+    for my $col (keys %$result) {
+        $result->{$col}->{data_type} =~ s/\s* identity \s*//ix;
+    }
+
+    return $result;
 }
 
 sub _table_pk_info {
@@ -43,7 +59,7 @@ sub _table_pk_info {
     my @keydata;
 
     while (my $row = $sth->fetchrow_hashref) {
-      push @keydata, lc $row->{COLUMN_NAME};
+        push @keydata, lc $row->{COLUMN_NAME};
     }
 
     return \@keydata;
@@ -58,18 +74,18 @@ sub _table_fk_info {
     $sth->execute;
 
     while (my $row = $sth->fetchrow_hashref) {
-      my $fk = $row->{FK_NAME};
-      push @{$local_cols->{$fk}}, lc $row->{FKCOLUMN_NAME};
-      push @{$remote_cols->{$fk}}, lc $row->{PKCOLUMN_NAME};
-      $remote_table->{$fk} = $row->{PKTABLE_NAME};
+        my $fk = $row->{FK_NAME};
+        push @{$local_cols->{$fk}}, lc $row->{FKCOLUMN_NAME};
+        push @{$remote_cols->{$fk}}, lc $row->{PKCOLUMN_NAME};
+        $remote_table->{$fk} = $row->{PKTABLE_NAME};
     }
 
     foreach my $fk (keys %$remote_table) {
-      push @rels, {
-                    local_columns => \@{$local_cols->{$fk}},
-                    remote_columns => \@{$remote_cols->{$fk}},
-                    remote_table => $remote_table->{$fk},
-                  };
+        push @rels, {
+                      local_columns => \@{$local_cols->{$fk}},
+                      remote_columns => \@{$remote_cols->{$fk}},
+                      remote_table => $remote_table->{$fk},
+                    };
 
     }
     return \@rels;
@@ -125,6 +141,10 @@ L<DBIx::Class::Schema::Loader::DBI>
 
 Justin Hunter C<justin.d.hunter@gmail.com>
 
+=head1 CONTRIBUTORS
+
+Rafael Kitover <rkitover@cpan.org>
+
 =cut
 
 1;