From: Peter Rabbitson Date: Sun, 30 May 2010 22:27:18 +0000 (+0000) Subject: Fix MC double-object creation (important for e.g. IC::FS which otherwise leaves orpha... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=65ee2b310ad73016954038d8504b6de5d4b10641;p=dbsrgits%2FDBIx-Class-Historic.git Fix MC double-object creation (important for e.g. IC::FS which otherwise leaves orphaned files) --- diff --git a/Changes b/Changes index 43c87a8..0ef7352 100644 --- a/Changes +++ b/Changes @@ -32,7 +32,10 @@ Revision history for DBIx::Class - update() on row not in_storage no longer throws an exception if there are no dirty columns to update (fixes cascaded update annoyances) - - Update Schema::Versioned to respect hashref style of connection_info + - Update Schema::Versioned to respect hashref style of + connection_info + - Do not recreate the same related object twice during MultiCreate + (solves the problem of orphaned IC::FS files) * Misc - Add a warning to load_namespaces if a class in ResultSet/ diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 6678a79..cf4c24c 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -405,18 +405,13 @@ sub insert { my $reverse = $source->reverse_relationship_info($relname); foreach my $obj (@cands) { $obj->set_from_related($_, $self) for keys %$reverse; - my $them = { %{$obj->{_relationship_data} || {} }, $obj->get_inflated_columns }; if ($self->__their_pk_needs_us($relname)) { if (exists $self->{_ignore_at_insert}{$relname}) { MULTICREATE_DEBUG and warn "MC $self skipping post-insert on $relname"; - } else { - MULTICREATE_DEBUG and warn "MC $self re-creating $relname $obj"; - my $re = $self->result_source - ->related_source($relname) - ->resultset - ->create($them); - %{$obj} = %{$re}; - MULTICREATE_DEBUG and warn "MC $self new $relname $obj"; + } + else { + MULTICREATE_DEBUG and warn "MC $self inserting $relname $obj"; + $obj->insert; } } else { MULTICREATE_DEBUG and warn "MC $self post-inserting $obj";