[CDBI] might_have being fetched

Bill Moseley moseley at hank.org
Fri Oct 28 04:41:52 BST 2005

By the way, if you read my last post about CDBI::Loader and db_Main,
how that popped up was I have might_have relationship on a table.

    Music::CD->might_have( notes => 'Music::Notes' );

I thought notes would only be fetched if doing:

    my $cd = Music::CD->retrieve( $id );
    $cd->notes;  # now do the select on Music::Notes

turns out an update causes a select on the might have table.

    my $cd = Music::CD->retrieve( $id );
    $cd->update;  # causes a select on Music::Notes.

That update was causing Music::Notes->db_Main to be called, and since
it was the first time for that class connect_cached() get called and
reset AutoCommit.

Anyway, why does an update require a select on the might_have

Bill Moseley
moseley at hank.org

More information about the ClassDBI mailing list