[Dbix-class] Subquery question
Matt S Trout
dbix-class at trout.me.uk
Tue May 16 15:24:05 CEST 2006
luke saunders wrote:
> On 5/16/06, *Dan Horne* <dan.horne at redbone.co.nz
> <mailto:dan.horne at redbone.co.nz>> wrote:
> Hi All
> I'm trying to figure out how to perform subqueries with DBIx::Class.
> example, I want to find all the roles that user 2 hasn't been assigned.
> The standard SQL is
> select role_id, display_name
> from app_role a
> where not exists
> (select 1
> from user_role u
> where u.user_id = 2
> and u.role_id = a.role_id);
> What would the DBIx::Class equivalent be?
> Dan Horne
> Hi Dan,
> Sadly subselects like this aren't possible with DBIC at the moment.
> It's definitely on the TODO list, I guess Matt will be able to tell you
> roughly when it'll be ready. Until then you'll have to find a way of
> doing it that doesn't require the subselect.
I'm pretty much sure I know how to implement this, but it's going to
mean messing around with DBIC::SQL::Abstract some more. If somebody
would care to volunteer to import as much of the SQL::Abstract test
suite onto -current as possible, I'll try and have a go at implementing
it with a target of 08 or so.
More information about the Dbix-class