[Dbix-class] prefetch syntax
Jason Galea
lists at eightdegrees.com.au
Fri Apr 7 01:13:08 CEST 2006
not much more than a shot in the dark, but something similar to this
worked for me the other day..
my $rs = $schema->resultset('Foo')->search(
{ 'me.foo_id' => $foo_id },
{ prefetch => [
'baz',
{ bar => 'biz' }
],
},
);
cheers,
J
Mark Hedges wrote:
> 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
>
> _______________________________________________
> 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/
>
>
More information about the Dbix-class
mailing list