X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRow.pm;h=3e0bf64da6983bf46a60adfe1cf92e111218a69e;hb=da7372ac69dbef985a717b955e1b00510e17835f;hp=424d750eab6c7b1665474be292421b39e873c233;hpb=370f2ba2727791641c350a20e4fd09469503dbae;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 424d750..3e0bf64 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -58,7 +58,7 @@ sub __new_related_find_or_new_helper { return $self->result_source ->related_source($relname) ->resultset - ->find_or_new($data); + ->find_or_create($data); } return $self->find_or_new_related($relname, $data); } @@ -265,7 +265,7 @@ sub insert { my $reverse = $source->reverse_relationship_info($relname); foreach my $obj (@cands) { $obj->set_from_related($_, $self) for keys %$reverse; - my $them = { $obj->get_columns }; + my $them = { $obj->get_inflated_columns }; if ($self->__their_pk_needs_us($relname, $them)) { $obj = $self->find_or_create_related($relname, $them); } else { @@ -378,7 +378,7 @@ sub delete { my $self = shift; if (ref $self) { $self->throw_exception( "Not in database" ) unless $self->in_storage; - my $ident_cond = $self->ident_condition; + my $ident_cond = $self->{_orig_ident} || $self->ident_condition; $self->throw_exception("Cannot safely delete a row in a PK-less table") if ! keys %$ident_cond; foreach my $column (keys %$ident_cond) { @@ -836,14 +836,13 @@ second argument to $resultset->search($cond, $attrs); sub get_from_storage { my $self = shift @_; my $attrs = shift @_; - my @primary_columns = map { $self->$_ } $self->primary_columns; my $resultset = $self->result_source->resultset; if(defined $attrs) { $resultset = $resultset->search(undef, $attrs); } - return $resultset->find(@primary_columns); + return $resultset->find($self->{_orig_ident} || $self->ident_condition); } =head2 throw_exception