X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSybase.pm;h=41b0c81bb297e2557717b25f779ed064c3832335;hb=26283ee38f220f6c6bae720ea5a189c9c0f47f6f;hp=0a2617337322e7cff3ded3dc15ad75a931a7ea31;hpb=148e3b50385e4a39296fcddc886f92af683456d5;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 0a26173..41b0c81 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -3,26 +3,33 @@ package DBIx::Class::Storage::DBI::Sybase; use strict; use warnings; -use base qw/DBIx::Class::Storage::DBI::NoBindVars/; - -my $noquote = { - int => qr/^ \-? \d+ $/x, - integer => qr/^ \-? \d+ $/x, - - # TODO maybe need to add float/real/etc -}; - -sub should_quote_data_type { - my $self = shift; - my ($type, $value) = @_; - - return $self->next::method(@_) if not defined $value; - - if (my $re = $noquote->{$type}) { - return 0 if $value =~ $re; - } +use base qw/ + DBIx::Class::Storage::DBI::Sybase::Base + DBIx::Class::Storage::DBI::NoBindVars +/; +use mro 'c3'; + +sub _rebless { + my $self = shift; + + my $dbtype = eval { + @{$self->_get_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; + } + } +} - return $self->next::method(@_); +sub _dbh_last_insert_id { + my ($self, $dbh, $source, $col) = @_; + return ($dbh->selectrow_array('select @@identity'))[0]; } 1; @@ -37,10 +44,21 @@ This subclass supports L for real Sybase databases. If 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) +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. + =head1 AUTHORS Brandon L Black +Justin Hunter + =head1 LICENSE You may distribute this code under the same terms as Perl itself.