Just in case I’m not the only one who missed this.

Seems DBIx::Class, the greatest Perl object-relational mapper ever, has recently added support for subqueries:

22:04  * marcus looks at DBIC cookbook, realizes it has subquery support now.
          *head explosion*
22:04 < @mst> since 081, yes :)

Even tho most things can be rewritten as joins, this has been one of the few things I’ve been missing in this excellent ORM. It’s still marked as experimental, but I’m totally going to be using it from now on :) Apparently this is how it works:

  my $s_query = $c->model('DB::License')->search({ free => 1 });
  $c->stash->{apps}= $c-model('DB::App')->search(
    { license_id => { 'IN' => $s_query->get_column('id')->as_query },
  });

PS. Note the disclaimers below the cookbook example.

Copyright © marcus ramberg
nordaaker

Built on Notes Blog Core
Powered by WordPress