From: Rafael Kitover Date: Sat, 23 May 2009 20:48:06 +0000 (+0000) Subject: Merge 'trunk' into 'sybase' X-Git-Tag: v0.08112~14^2~166 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c5ce7cd6bbb375009987f267fd8af28292b38930;p=dbsrgits%2FDBIx-Class.git Merge 'trunk' into 'sybase' --- c5ce7cd6bbb375009987f267fd8af28292b38930 diff --cc Makefile.PL index 4e279a6,8b730ca..7d8175f --- a/Makefile.PL +++ b/Makefile.PL @@@ -60,9 -70,24 +70,25 @@@ my %force_requires_if_author = # t/52cycle.t 'Test::Memory::Cycle' => 0, + # t/60core.t + 'DateTime::Format::MySQL' => 0, + + # t/72pg.t + $ENV{DBICTEST_PG_DSN} + ? ('Sys::SigAction'=> 0) + : () + , + # t/93storage_replication.t - 'Moose', => 0, - 'MooseX::AttributeHelpers' => 0.12, + 'Moose', => 0.77, + 'MooseX::AttributeHelpers' => 0.12, + 'MooseX::Types', => 0.10, + 'namespace::clean' => 0.11, + 'Hash::Merge', => 0.11, + + # t/96_is_deteministic_value.t ++ # t/746sybase.t + 'DateTime::Format::Strptime' => 0, ); if ($Module::Install::AUTHOR) { diff --cc lib/DBIx/Class/Storage/DBI/Sybase.pm index f18de95,0c18d6b..28b4059 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@@ -3,17 -3,27 +3,51 @@@ package DBIx::Class::Storage::DBI::Syba use strict; use warnings; --use base qw/DBIx::Class::Storage::DBI::NoBindVars/; ++use base qw/DBIx::Class::Storage::DBI/; - my %noquote = map ($_ => 1), qw(int integer); - - sub should_quote_data_type { + sub _rebless { - my $self = shift; - - my $dbtype = eval { @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] }; - unless ( $@ ) { - $dbtype =~ s/\W/_/gi; - my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}"; - if ($self->load_optional_class($subclass) && !$self->isa($subclass)) { - bless $self, $subclass; - $self->_rebless; - } + my $self = shift; - my ($type) = @_; - return 0 if $noquote{$type}; - return $self->next::method(@_); ++ ++ if (ref($self) eq 'DBIx::Class::Storage::DBI::Sybase') { ++ my $dbtype = eval { ++ @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] ++ } || ''; ++ ++ my $exception = $@; ++ $dbtype =~ s/\W/_/gi; ++ my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}"; ++ ++ if (!$exception && $dbtype && $self->load_optional_class($subclass)) { ++ bless $self, $subclass; ++ $self->_rebless; ++ } else { # probably real Sybase ++ if (not $self->dbh->{syb_dynamic_supported}) { ++ bless $self, 'DBIx::Class::Storage:DBI::Sybase::NoBindVars'; ++ $self->_rebless; ++ } ++ ++ $self->dbh->syb_date_fmt('ISO_strict'); ++ $self->dbh->do('set dateformat mdy'); + } ++ } } + sub _dbh_last_insert_id { - my $self = shift; - ($self->_dbh->selectrow_array('select @@identity'))[0]; ++ my ($self, $dbh, $source, $col) = @_; ++ ++ if (not $self->dbh->{syb_dynamic_supported}) { ++ # @@identity works only if not using placeholders ++ # Should this query be cached? ++ return ($dbh->selectrow_array('select @@identity'))[0]; ++ } ++ ++ # sorry, there's no other way! ++ my $sth = $dbh->prepare_cached("select max($col) from ".$source->from); ++ return ($dbh->selectrow_array($sth))[0]; + } + ++sub datetime_parser_type { "DBIx::Class::Storage::DBI::Sybase::DateTime" } ++ 1; =head1 NAME @@@ -26,12 -36,23 +60,43 @@@ This subclass supports L f you are using an MSSQL database via L, see L. + =head1 CAVEATS + -This storage driver uses L as a base. -This means that bind variables will be interpolated (properly quoted of course) ++If your version of Sybase does not support placeholders, then this storage ++driver uses L as a base, ++ ++In which case, bind variables will be interpolated (properly quoted of course) + into the SQL query itself, without using bind placeholders. + + More importantly this means that caching of prepared statements is explicitly + disabled, as the interpolation renders it useless. + ++If your version of Sybase B support placeholders (check ++C<<$dbh->{syb_dynamic_supported}>> then unfortunately there's no way to get the ++C without doing a C