[Dbix-class] prefetch syntax

Mark Hedges hedges at ucsd.edu
Fri Apr 7 00:50:37 CEST 2006


I want to prefetch both a single hop relation and a two-hop 
relation.

I.e. I want to combine this:

    my $rs = $schema->resultset('Foo')->search(
        {   'me.foo_id' => $foo_id, },
        {   prefetch    => {
                bar         => 'biz',
            },
        },
    );

with this:

    my $rs = $schema->resultset('Foo')->search(
        {   'me.foo_id' => $foo_id, },
        {   prefetch    => 'baz',   },
    );

But this doesn't work, probably obviously:

    my $rs = $schema->resultset('Foo')->search(
        {   'me.foo_id' => $foo_id  },
        {   prefetch    => {
                bar         => 'biz',
            },
        },
        {   prefetch    => 'baz'    },
    );

But this doesn't work either, because there is no 'baz to baz':

    my $rs = $schema->resultset('Foo')->search(
        {   'me.foo_id' => $foo_id  },
        {   prefetch    => {
                bar         => 'biz',
                baz         => 'baz',
            },
        },
    );

Any way to do this?

I still don't follow adding joins.  If I add the second one as
a join, it doesn't work either, and no error - just an empty $rs.

Mark



More information about the Dbix-class mailing list