From: Rafael Kitover Date: Thu, 20 Jan 2011 23:29:28 +0000 (-0500) Subject: improve sybase/mssql db_schema detection X-Git-Tag: 0.07003~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=23ed3da17e63d836f8b3699764ea4c5493aee776;p=dbsrgits%2FDBIx-Class-Schema-Loader.git improve sybase/mssql db_schema detection --- diff --git a/Changes b/Changes index 4a8206e..35d3300 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - improve sybase/mssql db_schema detection - remove MooseX::NonMoose from Schema files under use_moose=1 - better _tables_list for Sybase ASE - add datetime_undef_if_invalid => 1 for MySQL datetime data types diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm index 6d163ec..5a3b72e 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm @@ -27,9 +27,6 @@ sub _setup { if (not defined $self->preserve_case) { $self->preserve_case(1); } - - $self->{db_schema} ||= - ($self->schema->storage->dbh->selectrow_array('select user_name()'))[0]; } sub _rebless { diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm b/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm index 7c66aef..d9bcf9e 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm @@ -37,29 +37,7 @@ sub _build_db_schema { my $self = shift; my $dbh = $self->schema->storage->dbh; - local $dbh->{FetchHashKeyName} = 'NAME_lc'; - - my $test_table = "_loader_test_$$"; - - my $db_schema = 'dbo'; # default - - eval { - $dbh->do("create table $test_table (id integer)"); - 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; - $dbh->do("drop table $test_table"); - }; - my $exception = $@; - eval { $dbh->do("drop table $test_table") }; - carp "Could not determine db_schema, defaulting to $db_schema : $exception" - if $exception; + my ($db_schema) = $dbh->selectrow_array('select user_name()'); return $db_schema; }