From: Peter Rabbitson Date: Wed, 4 Jun 2014 11:28:42 +0000 (+0200) Subject: Reorganize IC column setters X-Git-Tag: v0.082800~190 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b342451e92ea65394993accbf0a79cc53e2b4dc6;p=dbsrgits%2FDBIx-Class.git Reorganize IC column setters Should again result in no functional changes --- diff --git a/lib/DBIx/Class/InflateColumn.pm b/lib/DBIx/Class/InflateColumn.pm index d84af86..3236b1c 100644 --- a/lib/DBIx/Class/InflateColumn.pm +++ b/lib/DBIx/Class/InflateColumn.pm @@ -104,7 +104,12 @@ sub inflate_column { sub _inflated_column { my ($self, $col, $value) = @_; - return $value unless defined $value; # NULL is NULL is NULL + + return $value if ( + ! defined $value # NULL is NULL is NULL + or + is_literal_value($value) #that would be a not-yet-reloaded literal update + ); my $info = $self->column_info($col) or $self->throw_exception("No column info for $col"); @@ -163,8 +168,6 @@ sub get_inflated_column { my $val = $self->get_column($col); - return $val if is_literal_value($val); #that would be a not-yet-reloaded literal update - return $self->{_inflated_column}{$col} = $self->_inflated_column($col, $val); } @@ -180,13 +183,19 @@ analogous to L. sub set_inflated_column { my ($self, $col, $value) = @_; - $self->set_column($col, $self->_deflated_column($col, $value)); - - if (length ref $value and ! is_literal_value($value) ) { - $self->{_inflated_column}{$col} = $value; - } else { + # pass through deflated stuff + if (! length ref $value or is_literal_value($value)) { + $self->set_column($col, $value); delete $self->{_inflated_column}{$col}; } + # need to call set_column with the deflate cycle so that + # relationship caches are nuked if any + # also does the compare-for-dirtyness and change tracking dance + else { + $self->set_column($col, $self->_deflated_column($col, $value)); + $self->{_inflated_column}{$col} = $value; + } + return $value; } @@ -202,7 +211,7 @@ as dirty. This is directly analogous to L. sub store_inflated_column { my ($self, $col, $value) = @_; - if (is_literal_value($value)) { + if (! length ref $value or is_literal_value($value)) { delete $self->{_inflated_column}{$col}; $self->store_column($col => $value); }