[Dbix-class] prefetch across multiple tables

John Stoffel john at stoffel.org
Wed Dec 17 14:57:02 GMT 2014


>>>>> "Dagfinn" == Dagfinn Ilmari Mannsåker <ilmari at ilmari.org> writes:

Dagfinn> "John Stoffel" <john at stoffel.org> writes:
>> Hi,

Dagfinn> Hi John,

>> I've been pounding my head trying to figure out what I'm doing wrong
>> here.  I've got a simple three table DB:
>> 
>> Names: full_name, name_id   
>> has_many:
>> Account: account_id, boxfolder_id, URL, comment
>> has_one:
>> Boxfolder:  boxfolder_id, volume, folder, range
Dagfinn> […]
>> Now when I try to use DBIx::Class (inside a Dancer web app) I just
>> can't make it work.  My code looks like this:
>> 
>> my $rs = $schema->resultset('Name')->search({ full_name => { like => $name }, },
>> { limit => 10,
>> order_by => { -asc => 'full_name' },
>> prefetch => [ 'account', { 'account' => 'boxfolder'}],

Dagfinn> This is not what you want, as that'll join twice to the account table,
Dagfinn> and then from one of those instances to the boxfolder table.

That's what I figured, esp when I got those errors.  Looking at my
system where I'm trying this, it's a Debian i686 running Wheezy, and
the DBIx::Class::VERSION is

   > perl -e 'use DBIx::Class; print "$DBIx::Class::VERSION\n";'
   0.08196

And the DBIx::Class stuff is:

  > dpkg-query -l | grep dbix
  ii  libdbix-class-cursor-cached-perl           1.001002-1
  all          cursor object with built-in caching support
  ii  libdbix-class-perl                         0.08196-3
  all          extensible and flexible object <-> relational mapper
  ii  libdbix-class-schema-loader-perl           0.07025-1
  all          module to automate definition of a DBIx::Class::Schema
  ii  libdbix-contextualfetch-perl               1.03-3
  all          module to add context aware fetches to DBI


Time to pull out CPAN and upgrade by hand.  Should have tried this
first.  Let me go do that update, and then I'll see what happens when
I have the prefetch set to just:

   prefetch => { 'account' => 'boxfolder' }

Dagfinn> This is the correct one and should work. Can you run this with the
Dagfinn> DBI_TRACE environment variable set to 1, and show us the full output?

Thanks for the reminder, I'll send that info along too if version
0.082810 of DBIx::Class (and dependencies) doesn't work for me.

Thanks!
John



More information about the DBIx-Class mailing list