Le 02.04.2013 06:45, Ross Attrill a �crit :
> Hi Laurent,
>
> DBIDM very neatly provides cascaded insert capability for
> Composition() relationships. Unfortunately, however, cascaded insert
> is not available for Association() relationships.
>
> Is it intentional that cascaded insert not be available for Associations?
Hi Ross,
Yes it was intentional, not for technical reasons, but for conceptual
reasons. Cascaded inserts and deletes are implemented only for
compositions, in order to emphasize that the lifetime of components is
strictly included in the lifetime of the composite. The restriction was
also meant to prevent unintentional inserts (because a record hash could
easily be expanded with some keys that are named after association
names). So to use cascaded inserts or deletes, the design was to require
an explicit declaration of a composition. It would be quite easy to
change the implementation, but I'm rather reluctant to do so. If you
really need that, you could subclass Source/Table.pm and reimplement
_weed_out_subtreees; then give this class name as argument to
DBIx::DataModel->define_schema(
class => 'MySchema',
table_parent => 'My:Subclass::Of::Source::Table',
...
);
> Since the schema generator creates Assocations by default, I don't
> get cascaded inserts unless I hand change my auto generated schema.
Just out of curiosity : why do you autogenerate the schema at each time,
instead of dumping it into a file that you could customize to your
needs ? Do you change your database structure very frequently ?
Cheers, Laurent D.