[Dbix-class] implicit joins?

Jason Gottshall jgottshall at capwiz.com
Wed Jul 18 18:56:26 GMT 2007


When I perform a search using criteria from a related table, why doesn't
DBIC pick up on that hint and automatically do the join? Example:

  my @cds = $schema->resultset('Albums')->search(
    { 'artist.name' => 'Billy Joel' },
    { join => 'artist' }
  );

If I'm already saying "artist.name" in the search criteria, shouldn't it
be fairly trivial for DBIC to notice the table-specific qualification
and setup the join for me?

Since DBIC is so smart about so many other things, I'm guessing that the
answer to my question will be something like "the criteria-processing
code doesn't have access to the join-making code," or "the joins happen
before the criteria are evaluated," or even "duh, foo.bar doesn't
necessarily imply a join to the foo table." But I'm not yet familiar
enough with the internals to know where to start looking for the answer
myself. I would be up for some code diving if someone wanted to give me
hint rather than a full explanation, though...

--Jason



More information about the Dbix-class mailing list