Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 125313
Status: open
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: rrwo [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: cascade_copy should default to false when the mas_many relationship is a virtual view
Date: Mon, 14 May 2018 11:13:57 +0100
To: bug-DBIx-Class [...] rt.cpan.org
From: Robert Rothenberg <rrwo [...] cpan.org>
I have a virtual view in the database schema, e.g. __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); __PACKAGE__->table("fake_table_name"); __PACKAGE__->result_source_instance->is_virtual(1); __PACKAGE__->result_source_instance->view_definition( q{ SELECT ... } } ); In one of the Result classes I have a has_many relationship: __PACKAGE__->has_many( "fake_table_name", "My::Schema::Result::FakeTableName", { "foreign.fake_id" => "self.id" }, { cascade_copy => 0 } # this is a view, so we should not copy it ); The cascade_copy had to be manually set when I found that copy did not work. Ideally, cascade_copy should default to false if it is unset and the result_source_instance is_virtual. If that is too difficult to implement, then at least make a note of this issue in the DBIx::Class::ResultSource POD.
Subject: Re: [rt.cpan.org #125313] cascade_copy should default to false when the mas_many relationship is a virtual view
Date: Mon, 14 May 2018 12:33:44 +0200
To: bug-DBIx-Class [...] rt.cpan.org
From: Peter Rabbitson <ribasushi [...] leporine.io>
On 05/14/2018 12:21 PM, Robert Rothenberg via RT wrote: Show quoted text
> > In one of the Result classes I have a has_many relationship: > > __PACKAGE__->has_many( > "fake_table_name", > "My::Schema::Result::FakeTableName", > { "foreign.fake_id" => "self.id" }, > { cascade_copy => 0 } # this is a view, so we should not copy it > ); > > The cascade_copy had to be manually set when I found that copy did not work. > > Ideally, cascade_copy should default to false if it is unset and the > result_source_instance is_virtual. >
Thank you for the report! Yes this is a good point. A bit hairy to implement due to how the default is set during source-instance-definition time ( at which time we are precluded from even attempting to look at My::Schema::Result::FakeTableName ). But it is doable nevertheless with tracked-boolean-objects used as defaults. This will be circled back to once a way out of the present backlogjam is found.