From: Rafael Kitover Date: Mon, 2 May 2011 12:38:44 +0000 (-0400) Subject: Fix assumption in Sybase::ASE blob updater: cond is not always a HASHREF X-Git-Tag: v0.08191~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=564986d6d86e685c86f8b39ee3e36044315d5ac3;p=dbsrgits%2FDBIx-Class.git Fix assumption in Sybase::ASE blob updater: cond is not always a HASHREF --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm index a7cf298..ade2e19 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm @@ -730,26 +730,25 @@ sub _update_blobs { $self->throw_exception("Cannot update TEXT/IMAGE column(s): $_") }; -# check if we're updating a single row by PK - my $pk_cols_in_where = 0; - for my $col (@primary_cols) { - $pk_cols_in_where++ if defined $where->{$col}; - } - my @rows; - - if ($pk_cols_in_where == @primary_cols) { + my @pks_to_update; + if ( + ref $where eq 'HASH' + and + @primary_cols == grep { defined $where->{$_} } @primary_cols + ) { my %row_to_update; @row_to_update{@primary_cols} = @{$where}{@primary_cols}; - @rows = \%row_to_update; - } else { + @pks_to_update = \%row_to_update; + } + else { my $cursor = $self->select ($source, \@primary_cols, $where, {}); - @rows = map { + @pks_to_update = map { my %row; @row{@primary_cols} = @$_; \%row } $cursor->all; } - for my $row (@rows) { - $self->_insert_blobs($source, $blob_cols, $row); + for my $ident (@pks_to_update) { + $self->_insert_blobs($source, $blob_cols, $ident); } }