From: Peter Rabbitson Date: Mon, 23 Nov 2009 00:30:05 +0000 (+0000) Subject: refactor part 2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=95787afeb4ecec13279ab2fb26a407c0f971b7df;p=dbsrgits%2FDBIx-Class-Historic.git refactor part 2 --- diff --git a/Changes b/Changes index dafb2d5..f481e6e 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,8 @@ Revision history for DBIx::Class - Fix distinct => 1 with non-selecting order_by (the columns in order_by also need to be aded to the resulting group_by) - Do not attempt to deploy FK constraints pointing to a View + - Refactored Sybase storage driver into a central ::DBI::Sybase + dispatcher, and a sybase-specific ::DBI::Sybase::ASE 0.08114 2009-11-14 17:45:00 (UTC) - Preliminary support for MSSQL via DBD::ADO diff --git a/Makefile.PL b/Makefile.PL index 2332153..67ffeee 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -142,12 +142,9 @@ resources 'license' => 'http://dev.perl.org/licenses/'; resources 'repository' => 'http://dev.catalyst.perl.org/repos/bast/DBIx-Class/'; resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class'; -no_index 'DBIx::Class::Storage::DBI::Sybase::Common'; no_index 'DBIx::Class::SQLAHacks'; no_index 'DBIx::Class::SQLAHacks::MSSQL'; no_index 'DBIx::Class::Storage::DBI::AmbiguousGlob'; -no_index 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server'; -no_index 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars'; no_index 'DBIx::Class::Storage::DBIHacks'; # re-build README and require extra modules for testing if we're in a checkout diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 13eb432..7e60cbf 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -406,12 +406,10 @@ sub load_classes { Set the storage class that will be instantiated when L is called. If the classname starts with C<::>, the prefix C is -assumed by L. +assumed by L. You want to use this to set subclasses of L -in cases where the appropriate subclass is not autodetected, such as -when dealing with MSSQL via L, in which case you'd set it -to C<::DBI::Sybase::MSSQL>. +in cases where the appropriate subclass is not autodetected. If your storage type requires instantiation arguments, those are defined as a second argument in the form of a hashref and the entire diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 60c6277..1f7bab2 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1991,7 +1991,7 @@ sub last_insert_id { This API is B, will almost definitely change in the future, and currently only used by L<::AutoCast|DBIx::Class::Storage::DBI::AutoCast> and -L<::Sybase|DBIx::Class::Storage::DBI::Sybase>. +L<::Sybase::ASE|DBIx::Class::Storage::DBI::Sybase::ASE>. The default implementation returns C, implement in your Storage driver if you need this functionality. diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index ac3adf9..77b77e2 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -7,8 +7,8 @@ use base qw/DBIx::Class::Storage::DBI/; =head1 NAME -DBIx::Class::Storage::DBI::Sybase::Common - Base class for drivers using -DBD::Sybase +DBIx::Class::Storage::DBI::Sybase - Base class for drivers using +L =head1 DESCRIPTION diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm similarity index 100% rename from lib/DBIx/Class/Storage/DBI/Sybase/SQL_Server.pm rename to lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/SQL_Server/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/Sybase/ASE/NoBindVars.pm similarity index 100% rename from lib/DBIx/Class/Storage/DBI/Sybase/SQL_Server/NoBindVars.pm rename to lib/DBIx/Class/Storage/DBI/Sybase/ASE/NoBindVars.pm diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm index f762385..9666a00 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm @@ -4,7 +4,7 @@ use strict; use warnings; use base qw/ - DBIx::Class::Storage::DBI::Sybase::Common + DBIx::Class::Storage::DBI::Sybase DBIx::Class::Storage::DBI::MSSQL /; use mro 'c3'; @@ -25,7 +25,7 @@ sub _run_connection_actions { # LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is # huge on some versions of SQL server and can cause memory problems, so we - # fix it up here (see Sybase/Common.pm) + # fix it up here (see ::DBI::Sybase.pm) $self->set_textsize; $self->next::method(@_); diff --git a/t/746sybase.t b/t/746sybase.t index 295b76a..5afbf3a 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -7,9 +7,6 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; -require DBIx::Class::Storage::DBI::Sybase; -require DBIx::Class::Storage::DBI::Sybase::NoBindVars; - my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/}; my $TESTS = 63 + 2; @@ -24,9 +21,11 @@ if (not ($dsn && $user)) { } my @storage_types = ( - 'DBI::Sybase', - 'DBI::Sybase::NoBindVars', + 'DBI::Sybase::ASE', + 'DBI::Sybase::ASE::NoBindVars', ); +eval "require $_" for @storage_types; + my $schema; my $storage_idx = -1; @@ -40,8 +39,8 @@ sub get_schema { my $ping_count = 0; { - my $ping = DBIx::Class::Storage::DBI::Sybase->can('_ping'); - *DBIx::Class::Storage::DBI::Sybase::_ping = sub { + my $ping = DBIx::Class::Storage::DBI::Sybase::ASE->can('_ping'); + *DBIx::Class::Storage::DBI::Sybase::ASE::_ping = sub { $ping_count++; goto $ping; }; @@ -50,7 +49,7 @@ my $ping_count = 0; for my $storage_type (@storage_types) { $storage_idx++; - unless ($storage_type eq 'DBI::Sybase') { # autodetect + unless ($storage_type eq 'DBI::Sybase::ASE') { # autodetect DBICTest::Schema->storage_type("::$storage_type"); } @@ -59,7 +58,7 @@ for my $storage_type (@storage_types) { $schema->storage->ensure_connected; if ($storage_idx == 0 && - $schema->storage->isa('DBIx::Class::Storage::DBI::Sybase::NoBindVars')) { + $schema->storage->isa('DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars')) { # no placeholders in this version of Sybase or DBD::Sybase (or using FreeTDS) my $tb = Test::More->builder; $tb->skip('no placeholders') for 1..$TESTS; @@ -96,7 +95,7 @@ SQL $seen_id{$new->artistid}++; # check redispatch to storage-specific insert when auto-detected storage - if ($storage_type eq 'DBI::Sybase') { + if ($storage_type eq 'DBI::Sybase::ASE') { DBICTest::Schema->storage_type('::DBI'); $schema = get_schema(); } @@ -402,7 +401,7 @@ SQL my $new_str = $binstr{large} . 'mtfnpy'; # check redispatch to storage-specific update when auto-detected storage - if ($storage_type eq 'DBI::Sybase') { + if ($storage_type eq 'DBI::Sybase::ASE') { DBICTest::Schema->storage_type('::DBI'); $schema = get_schema(); } diff --git a/t/inflate/datetime_sybase.t b/t/inflate/datetime_sybase.t index 24d0f07..bbd603a 100644 --- a/t/inflate/datetime_sybase.t +++ b/t/inflate/datetime_sybase.t @@ -23,15 +23,15 @@ if (not ($dsn && $user)) { } my @storage_types = ( - 'DBI::Sybase', - 'DBI::Sybase::NoBindVars', + 'DBI::Sybase::ASE', + 'DBI::Sybase::ASE::NoBindVars', ); my $schema; for my $storage_type (@storage_types) { $schema = DBICTest::Schema->clone; - unless ($storage_type eq 'DBI::Sybase') { # autodetect + unless ($storage_type eq 'DBI::Sybase::ASE') { # autodetect $schema->storage_type("::$storage_type"); } $schema->connection($dsn, $user, $pass, {