X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRow.pm;h=8b8f5fb08a28d8691d3ef72812064c41189b6f37;hb=367eaf50970dd3fd223ce5e1f0337703f2a6c70e;hp=5adf4eaf31cafed194b5160c6416c40cb1a20f37;hpb=09d2e66a5d5558ef9a19dc2ec510d5dafd2fb7d8;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 5adf4ea..8b8f5fb 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -556,7 +556,9 @@ sub update { my %to_update = $self->get_dirty_columns or return $self; - $self->throw_exception( "Not in database" ) unless $self->in_storage; + $self->throw_exception( + 'Result object not marked in_storage: an update() operation is not possible' + ) unless $self->in_storage; my $rows = $self->result_source->schema->storage->update( $self->result_source, \%to_update, $self->_storage_ident_condition @@ -618,7 +620,9 @@ See also L. sub delete { my $self = shift; if (ref $self) { - $self->throw_exception( "Not in database" ) unless $self->in_storage; + $self->throw_exception( + 'Result object not marked in_storage: a delete() operation is not possible' + ) unless $self->in_storage; $self->result_source->schema->storage->delete( $self->result_source, $self->_storage_ident_condition @@ -1193,15 +1197,15 @@ sub copy { $copied->{$_->ID}++ or $_->copy( - $foreign_vals ||= $rsrc->_resolve_relationship_condition( - infer_values_based_on => {}, + $foreign_vals ||= $rsrc->resolve_relationship_condition( + require_join_free_values => 1, rel_name => $rel_name, self_result_object => $new, # an API where these are optional would be too cumbersome, # instead always pass in some dummy values DUMMY_ALIASPAIR, - )->{inferred_values} + )->{join_free_values} ) for $self->related_resultset($rel_name)->all; } @@ -1517,15 +1521,16 @@ L. =cut sub get_from_storage { - my $self = shift @_; - my $attrs = shift @_; - my $resultset = $self->result_source->resultset; + my $self = shift; - if(defined $attrs) { - $resultset = $resultset->search(undef, $attrs); - } - - return $resultset->find($self->_storage_ident_condition); + # with or without attrs? + ( + defined( $_[0] ) + ? $self->result_source->resultset->search_rs( undef, $_[0] ) + : $self->result_source->resultset + )->find( + $self->_storage_ident_condition + ); } =head2 discard_changes