X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FMSSQL.pm;h=d9f09723001c3012ccb5d55215c885ec623fed93;hb=b1ad1a8402a5eb0955c6b76310809c2ab29291a9;hp=3409bf700e710beb930e606978252b0ecd2e75ab;hpb=fe67d3434ad62ea06e1a483429cb07c744d6c70d;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index 3409bf7..d9f0972 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -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 Justin Hunter C +=head1 CONTRIBUTORS + +Rafael Kitover + =cut 1;