[Dbix-class] Problem prefetching more than one relation

Jon Warbrick jw35 at cam.ac.uk
Wed Nov 8 17:56:22 GMT 2006


Am I limited to pre-fetching only one has_many relation? I have something 
like:

  package Ucam::LookupDB::Person;
  use base 'Ucam::LookupDBBase';
  my $keep = { cascade_delete => 0 };
  __PACKAGE__->load_components("PK::Auto", "Core");
  __PACKAGE__->table("people");
  __PACKAGE__->add_columns("uid");
  __PACKAGE__->set_primary_key("uid");
  __PACKAGE__->has_many    ("title",
                            "Ucam::LookupDB::PersonTitle",
                            "uid",
                            $keep);
  __PACKAGE__->has_many    ("mail",
                            "Ucam::LookupDB::PersonMail",
                            "uid",
                            $keep);

but attempts to do:

  $db->resultset("Person")->search
      ({ "me.uid" => 'fjc55' },
       { prefetch => [qw/title mail/]})->single

result in:

  DBIx::Class::ResultSet::single(): Prefetch not supported with accessor 
  'multi' at t/person.t line 118

and dito with '->first'. I expect I'm doing something stupid, or 
misunderstanding something fundamental. Any pointers, or just confirmation 
that I can't do what I'm trying to do, would be very welcome.

This with DBIx::Class version 0.07001.

Jon.

-- 
Jon Warbrick
Web/News Development, Computing Service, University of Cambridge



More information about the Dbix-class mailing list