[Dbix-class] How to create a row object that contains related objects in DBIx::Class?

Will Crawford billcrawford1970 at gmail.com
Thu Aug 16 11:54:36 GMT 2012

On 16 August 2012 12:21, Ian Docherty <dbix-class at iandocherty.com> wrote:
> One technique I have seen used is as follows.
> my $author = $authors_rs->find(1);
> my $book = $books_rs->create({ author => $author, title => 'title' });
> $book->author($author);
> Be warned however, in some circumstances this can lead to circular
> dependencies causing memory leaks.

That wouldn't likely be an issue in the use case I have. The one thing
I really would like to able to do is pass a related object to a create
like that (or to new_result on a resultset), and _use one of its
columns to DynamicSubclass the new object_. Which I still can't do
with the pattern above (but I'll use that where it's appropriate;
it'll save us some queries - thankyou).

More information about the DBIx-Class mailing list