From: Peter Rabbitson Date: Wed, 9 Sep 2009 07:40:29 +0000 (+0000) Subject: Much simpler X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=37b17a93efef4652db90e299b247e55ab1145b0b;p=dbsrgits%2FDBIx-Class-Historic.git Much simpler --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 8829cb3..4990e78 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -836,7 +836,9 @@ sub sql_maker { return $self->_sql_maker; } +# nothing to do by default sub _rebless {} +sub _init {} sub _populate_dbh { my ($self) = @_; @@ -903,6 +905,8 @@ sub _determine_driver { $self->_driver_determined(1); + $self->_init; # run driver-specific initializations + $self->_run_connection_actions if $started_unconnected && defined $self->_dbh; } diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm index e29abec..8519ee5 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm @@ -102,8 +102,7 @@ EOF $self->_identity_method('@@identity'); } -sub _rebless { - no warnings 'uninitialized'; +sub _init { my $self = shift; if (ref($self->_dbi_connect_info->[0]) ne 'CODE' && diff --git a/lib/DBIx/Class/Storage/DBI/Oracle.pm b/lib/DBIx/Class/Storage/DBI/Oracle.pm index 7a49b50..da60a2d 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle.pm @@ -19,10 +19,8 @@ sub _rebless { ? 'DBIx::Class::Storage::DBI::Oracle::WhereJoins' : 'DBIx::Class::Storage::DBI::Oracle::Generic'; - # Load and rebless - eval "require $class"; - - bless $self, $class unless $@; + $self->ensure_class_loaded ($class); + bless $self, $class; } } diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 43932fa..041aa2c 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -88,9 +88,6 @@ EOF $self->_rebless; } } - - $self->set_textsize; # based on LongReadLen in connect_info - } elsif (not $self->_get_dbh->{syb_dynamic_supported}) { # not necessarily FreeTDS, but no placeholders nevertheless @@ -101,12 +98,18 @@ EOF # this is highly unlikely, but we check just in case $self->auto_cast(1); } - - $self->_set_max_connect(256); } } } +sub _init { + my $self = shift; + $self->_set_max_connect(256); + + # based on LongReadLen in connect_info + $self->set_textsize if $self->using_freetds; +} + # Make sure we have CHAINED mode turned on if AutoCommit is off in non-FreeTDS # DBD::Sybase (since we don't know how DBD::Sybase was compiled.) If however # we're using FreeTDS, CHAINED mode turns on an implicit transaction which we diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Common.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Common.pm index 1f69d81..af4c916 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Common.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Common.pm @@ -71,7 +71,7 @@ the Sybase OpenClient libraries were used. sub using_freetds { my $self = shift; - return $self->_dbh->{syb_oc_version} =~ /freetds/i; + return $self->_get_dbh->{syb_oc_version} =~ /freetds/i; } =head2 set_textsize 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 22661a8..3d83020 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm @@ -9,12 +9,6 @@ use base qw/ /; use mro 'c3'; -sub new { - my $self = shift->next::method(@_); - $self->_rebless; - return $self; -} - sub _rebless { my $self = shift; my $dbh = $self->_get_dbh; @@ -24,10 +18,14 @@ sub _rebless { 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars'; $self->_rebless; } +} + +sub _init { + my $self = shift; -# 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 .) + # 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) $self->set_textsize; } diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server/NoBindVars.pm index 4fc6f6d..622cf1e 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server/NoBindVars.pm @@ -9,15 +9,8 @@ use base qw/ /; use mro 'c3'; -sub new { - my $self = shift->next::method(@_); - $self->_rebless; - return $self; -} - -sub _rebless { +sub _init { my $self = shift; - $self->disable_sth_caching(1); } diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm index 7737d95..32908ee 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm @@ -8,16 +8,11 @@ use mro 'c3'; use List::Util (); use Scalar::Util (); -sub new { - my $self = shift->next::method(@_); - $self->_rebless; - return $self; -} - -sub _rebless { +sub _init { my $self = shift; $self->disable_sth_caching(1); $self->_identity_method('@@IDENTITY'); + $self->next::method (@_); } sub _fetch_identity_sql { 'SELECT ' . $_[0]->_identity_method }