So I have this code:

    my $rs = $self->search_related('watching', {},
        {
            select => [
                { distinct => 'item.id' }
            ],
            prefetch => { person => { relations => 'item' } },
            join => {
                'person' => {
                    'relations' => 'item'
                }
            },
            order_by => 'item.releasedate DESC',
            page => 1,
            rows => $count
        }
    );

    $thing = $rs->first;


Which produces this SQL on trace:

SELECT DISTINCT( item.id ), person.id, person.mtime, person.title, person.photo, person.refresh, relations.person, relations.item, relations.role, item.id, item.mtime, item.title, item.releasedate, item.type, item.manufacturer, item.asin, item.itms, item.photo, item.universal FROM watching me JOIN persons person ON ( person.id = me.person ) LEFT JOIN relations relations ON ( relations.person = person.id ) JOIN items item ON ( item.id = relations.item ) WHERE ( me.user = ? ) ORDER BY item.releasedate DESC, relations.person LIMIT 1: '1'


What I can't figure out is how to display the 'item.title' field from the $thing object. All the person.* things are available, but not item.*

        $thing->person->title;    # works
        $thing->item->title; # Can't locate object method "item"

Do I need to do something different with my prefetch definition to get DBIx::Class to notice that I fetched the items table?

Thanks!

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to