[Catalyst] Re: $row->copy causing exit from controller(!)

Paul Makepeace paulm at paulm.com
Thu May 8 10:42:06 BST 2008

On Thu, May 1, 2008 at 11:31 AM, Paul Makepeace <paulm at paulm.com> wrote:
> I'm seeing something exceedingly odd: copying data causing a premature
>  return from the controller, like a detach(),
>         foreach my $table (@chart_related_tables) {
>           my $rs = $ds->resultset($table);
>           warn "copying $table for ", $new_chart->uid;
>           for my $row ($rs->search({web_chart_spec_uid => $chart->uid})) {
>             warn "..row ", $row->web_chart_spec_uid, $row;
>             $row->copy({web_chart_spec_uid => $new_chart->uid});  # XXX
>           }
>           #$_->copy({web_chart_spec_uid => $new_chart->uid})
>               #for $rs->search({web_chart_spec_uid => $chart->uid});
>           die "cloned", $new_chart->uid;
>         }
>  There's no further execution past the line marked XXX: the template is
>  rendered from that point on. The die is never called.
>  I have a feeling it's something to do with has_many
>  Chart:
>  __PACKAGE__->has_many(chartview_company => 'IDL::Schema::ChartCompany'
>  => 'web_chart_spec_uid', {cascade_delete => 0});
>  If I exclude from @chart_related_tables ChartCompany it works.

I had the stroke of intuition to wrap the call to copy() in an "eval
{}; warn @$ if $@;" and saw what is going on. It seems like the copy()
is not just copying the row but other rows as well, which is in turn
causing duplicate key errors, in particular the rels mentioned above
that have has_many. The controller at least completes now. (Why an
error like this would bypass the exception handler is a mystery and
presumably a bug.)

There's a series of BEGIN/COMMIT/ROLLBACK lines coming out of
somewhere in the FastCGI screen too, FWIW.

doesn't give any hint that multiple rows would be inserted.

Does this sound plausible?

Sorry I haven't got more debug, I'm squeezing this into occasional
spare minutes here and there. If there's something specific I can try
or provide, let me know. Unfortunately getting the fastcgi working
with perl -d isn't likely any time soon. I don't think it's there in
any case; it feels more DBIx::Class related.


>  **
>  I realize there's scads of debug I could provide but wanted to check
>  first this wasn't something someone had run into before. If not, what
>  kind of debug can I provide?
>  DBIC $VERSION = '0.08009';
>  Catalyst 5.7012
>  Paul

More information about the Catalyst mailing list