From: Rafael Kitover Date: Sat, 20 Mar 2010 01:42:13 +0000 (-0400) Subject: better _tables_list for MSSQL X-Git-Tag: 0.06000~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=acfcc1fb32b80628b8fb50258d90bc1e8a72f9e0;p=dbsrgits%2FDBIx-Class-Schema-Loader.git better _tables_list for MSSQL --- diff --git a/Changes b/Changes index a93df57..b6e72c7 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - better _tables_list for MSSQL - pick up views in SQLite too - better rel inflection using Lingua::EN::Inflect::Phrase - cascade_delete and cascade_copy are turned off for has_many/might_have diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index a0a1785..bfc2053 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -12,20 +12,34 @@ our $VERSION = '0.05003'; DBIx::Class::Schema::Loader::DBI::MSSQL - DBIx::Class::Schema::Loader::DBI MSSQL Implementation. -=head1 SYNOPSIS +=head1 DESCRIPTION - package My::Schema; - use base qw/DBIx::Class::Schema::Loader/; +Base driver for Microsoft SQL Server, used by +L for support +via L and +L for support via +L. - __PACKAGE__->loader_options( debug => 1 ); +See L and L for +usage information. - 1; +=cut -=head1 DESCRIPTION +sub _tables_list { + my $self = shift; -See L. + my $dbh = $self->schema->storage->dbh; + my $sth = $dbh->prepare(<<'EOF'); +select t.table_name +from information_schema.tables t +where t.table_schema = ? +EOF + $sth->execute($self->db_schema); -=cut + my @tables = map lc $_, map @$_, @{ $sth->fetchall_arrayref }; + + return $self->_filter_tables(@tables); +} sub _table_pk_info { my ($self, $table) = @_; @@ -130,6 +144,8 @@ sub _extra_column_info { =head1 SEE ALSO +L, +L, L, L, L diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm index 30ffbc4..1aa59a0 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm @@ -10,33 +10,20 @@ our $VERSION = '0.05003'; =head1 NAME -DBIx::Class::Schema::Loader::DBI::Sybase::Microsoft_SQL_Server - Subclass for -using MSSQL through DBD::Sybase +DBIx::Class::Schema::Loader::DBI::Sybase::Microsoft_SQL_Server - Driver for +using Microsoft SQL Server through DBD::Sybase =head1 DESCRIPTION -See L. - Subclasses L. -=cut - -# Returns an array of table names -sub _tables_list { - my $self = shift; - - my ($table, $type) = @_ ? @_ : ('%', '%'); - - my $dbh = $self->schema->storage->dbh; - my @tables = $dbh->tables(undef, $self->db_schema, $table, $type); - - return $self->_filter_tables(@tables); -} +See L and L. =head1 SEE ALSO -L, L, +L, +L, L L, L, diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 155a12a..44fbea3 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -148,7 +148,7 @@ sub setup_schema { }; ok(!$@, "Loader initialization") or diag $@; - + find sub { return if -d; $file_count++ }, $DUMP_DIR; $expected_count += grep /CREATE (?:TABLE|VIEW)/i,