DBIx::Class - Related Tables

Raphael Mankin raph at mankin.org.uk
Tue Oct 7 12:08:03 BST 2008

On Tue, 2008-10-07 at 10:55 +0100, Paul Makepeace wrote:
> On Tue, Oct 7, 2008 at 10:10 AM, Minty <mintywalker at gmail.com> wrote:
> > On Tue, Oct 7, 2008 at 9:03 AM, Dave Hodgkinson <davehodg at gmail.com> wrote:
> >> Then what's the benefit of an ORM? (general question, not just to you :)
> >
> Let's say you have a page where there's a lot of dependency on the
> role of the account you're logged in as.
> [% IF c.check_user_roles('superhero') OR c.check_user_roles('crime_fighter') %]
> and other combinations peppered throughout your template, that's an
> SQL query per invocation. I recently had to fix up a template that was
> doing this by caching in local vars as the template was making over a
> dozen role authorization calls like this!

The problem here is not with the ORM but rather that you are breaking
the MVC separation and putting controller logic in the view. A good ORM
would have its data cached so that your test might not require two SQL
queries. However, the template is, in this instance, the wrong place to
put the test.

More information about the london.pm mailing list