[Dbix-class] Prefetch and From

Martinc martin.j.clayton at gmail.com
Tue Dec 23 11:10:53 GMT 2008


First post ... be gentle.

I've resorted to using DBIx::Class::ResultSet 'from' in a search.
There's an outer join with an IN list in an ON clause.
Being greedy, I want to prefetch too.

The only way I've got it to 'work' is to violate encapsulation and not
respect the privacy of the module as follows:

  my $rs = $result_set->search(
    {
      ... criteria ...
    },
    {
      prefetch => ... entities to prefetch ...
    }
  );
  $rs->_resolved_attrs();
  $rs->{_attrs}->{from} = ... manual FROM clause ...

  while ( $rs->next )
  {
    ...
  }

The manual 'from' clause ensures all the prefetched tables are included as
specified in prefetch.

Questions:

1) Is there a way to mix prefetch and manual 'from' that does not require
the hack above.
2) I don't need all the columns in the underlying (nested) tables, can I
prefetch a subset of columns?
 
Version is 0.08009.

Regards,

Martin.
-- 
View this message in context: http://n2.nabble.com/Prefetch-and-From-tp1693458p1693458.html
Sent from the DBIx-Class mailing list archive at Nabble.com.




More information about the DBIx-Class mailing list