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=8611bf734e0e8a5fdac1f55ced6195a33d872481;hpb=76503d57f3406c41298dee6f1230e691a878537c;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 8611bf7..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 @@ -27,56 +30,25 @@ See L. =cut -sub _rebless { - my $self = shift; - - $self->schema->storage->sql_maker->quote_char([qw/[ ]/]) - unless $self->schema->storage->sql_maker->quote_char; - - $self->schema->storage->sql_maker->name_sep('.') - unless $self->schema->storage->sql_maker->name_sep; -} - sub _setup { my $self = shift; $self->next::method(@_); - - $self->{db_schema} ||= $self->_determine_db_schema; + $self->{db_schema} ||= $self->_build_db_schema; + $self->_set_quote_char_and_name_sep; } -sub _determine_db_schema { - my $self = shift; - my $dbh = $self->schema->storage->dbh; - - my $test_table = "_loader_test_$$"; - $dbh->do("create table $test_table (id integer)"); - - my $db_schema = 'dbo'; # default - - eval { - my $sth = $dbh->prepare('sp_tables'); - $sth->execute; - while (my $row = $sth->fetchrow_hashref) { - next unless $row->{TABLE_NAME} eq $test_table; - - $db_schema = $row->{TABLE_OWNER}; - last; - } - $sth->finish; - }; - my $exception = $@; - $dbh->do("drop table $test_table"); - croak $exception if $exception; - - return $db_schema; -} +# 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; + } -# DBD::Sybase doesn't implement get_info properly -#sub _build_quoter { [qw/[ ]/] } -sub _build_quoter { '"' } -sub _build_namesep { '.' } + return $result; +} sub _table_pk_info { my ($self, $table) = @_; @@ -169,6 +141,10 @@ L Justin Hunter C +=head1 CONTRIBUTORS + +Rafael Kitover + =cut 1;