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.