From: John Napiorkowski Date: Fri, 1 Dec 2006 04:35:26 +0000 (+0000) Subject: moved bind attributes to DBI.pm/DBI/Pg.pm X-Git-Tag: v0.08010~150^2~106^2~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a71859b4494bebdf765903546d332f9f3f805810;p=dbsrgits%2FDBIx-Class.git moved bind attributes to DBI.pm/DBI/Pg.pm --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index de21478..dfb5748 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -878,8 +878,9 @@ sub insert { my $bind_attributes; foreach my $column ($source->columns) { - $bind_attributes->{$column} = $source->column_info($column)->{bind_attributes} - if defined $source->column_info($column)->{bind_attributes}; + my $data_type = $source->column_info($column)->{data_type} || ''; + $bind_attributes->{$column} = $self->bind_attribute_by_data_type($data_type) + if $data_type; } $self->throw_exception( @@ -947,8 +948,9 @@ sub update { my $bind_attributes; foreach my $column ($source->columns) { - $bind_attributes->{$column} = $source->column_info($column)->{bind_attributes} - if defined $source->column_info($column)->{bind_attributes}; + my $data_type = $source->column_info($column)->{data_type} || ''; + $bind_attributes->{$column} = $self->bind_attribute_by_data_type($data_type) + if $data_type; } my $ident = $source->from; @@ -1132,6 +1134,20 @@ Returns the database driver name. sub sqlt_type { shift->dbh->{Driver}->{Name} } +=head2 bind_attribute_by_data_type + +Given a datatype from column info, returns a database specific bind attribute for +$dbh->bind_param($val,$attribute) or nothing if we will let the database planner +just handle it. + +Generally only needed for special case column types, like bytea in postgres. + +=cut + +sub bind_attribute_by_data_type { + return; +} + =head2 create_ddl_dir (EXPERIMENTAL) =over 4 diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index 0c98f91..8500767 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -3,7 +3,7 @@ package DBIx::Class::Storage::DBI::Pg; use strict; use warnings; -use DBD::Pg; +use DBD::Pg qw(:pg_types); use base qw/DBIx::Class::Storage::DBI/; @@ -55,6 +55,21 @@ sub sqlt_type { sub datetime_parser_type { return "DateTime::Format::Pg"; } +sub bind_attribute_by_data_type { + my ($self,$data_type) = @_; + + my $bind_attributes = { + bytea => { pg_type => DBD::Pg::PG_BYTEA }, + }; + + if( defined $bind_attributes->{$data_type} ) { + return $bind_attributes->{$data_type} + } + else { + return; + } +} + 1; =head1 NAME