From: Rafael Kitover Date: Sun, 23 Jan 2011 12:03:13 +0000 (-0500) Subject: Cleanup/extend blob/clob detection/checks X-Git-Tag: v0.08191~91 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8138f96a9bb627e9f27cf9908532021217eb89b9;p=dbsrgits%2FDBIx-Class.git Cleanup/extend blob/clob detection/checks --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index d6ef837..fc66f3b 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -2931,12 +2931,27 @@ sub _max_column_bytesize { } # Determine if a data_type is some type of BLOB +# FIXME: these regexes are expensive, result of these checks should be cached in +# the column_info . sub _is_lob_type { my ($self, $data_type) = @_; - $data_type && ($data_type =~ /(?:lob|bfile|text|image|bytea|memo)/i - || $data_type =~ /^long(?:\s*(?:raw|bit\s*varying|varbit|binary + $data_type && ($data_type =~ /lob|bfile|text|image|bytea|memo/i + || $data_type =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary |varchar|character\s*varying|nvarchar - |national\s*character\s*varying))?$/xi); + |national\s*character\s*varying))?\z/xi); +} + +sub _is_binary_lob_type { + my ($self, $data_type) = @_; + $data_type && ($data_type =~ /blob|bfile|image|bytea/i + || $data_type =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary))?\z/xi); +} + +sub _is_text_lob_type { + my ($self, $data_type) = @_; + $data_type && ($data_type =~ /^(?:clob|memo)\z/i + || $data_type =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar + |national\s*character\s*varying))\z/xi); } 1; diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 20dac87..79896d8 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -410,15 +410,14 @@ sub source_bind_attributes my $self = shift; my($source) = @_; - my %bind_attributes; + my %bind_attributes = %{ $self->next::method(@_) }; foreach my $column ($source->columns) { - my $data_type = $source->column_info($column)->{data_type} - or next; + my %column_bind_attrs = %{ $bind_attributes{$column} || {} }; - my %column_bind_attrs = $self->bind_attribute_by_data_type($data_type); + my $data_type = $source->column_info($column)->{data_type}; - if ($data_type =~ /^[BC]LOB$/i) { + if ($self->_is_lob_type($data_type)) { if ($DBD::Oracle::VERSION eq '1.23') { $self->throw_exception( "BLOB/CLOB support in DBD::Oracle == 1.23 is broken, use an earlier or later ". @@ -426,7 +425,7 @@ sub source_bind_attributes ); } - $column_bind_attrs{'ora_type'} = uc($data_type) eq 'CLOB' + $column_bind_attrs{'ora_type'} = $self->_is_text_lob_type($data_type) ? DBD::Oracle::ORA_CLOB() : DBD::Oracle::ORA_BLOB() ; diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 878ece9..c004c39 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -386,6 +386,8 @@ my @unimplemented = qw( _max_column_bytesize _is_lob_type + _is_binary_lob_type + _is_text_lob_type ); # the capability framework diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm index 2fae10f..52e90bf 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm @@ -1169,7 +1169,7 @@ bulk_insert using prepare_cached (see comments.) =head1 AUTHOR -See L. +See L and L. =head1 LICENSE