[Dbix-class] joining subqueries

Peter Rabbitson rabbit+dbic at rabbit.us
Fri Feb 2 22:24:29 GMT 2018


On 01/26/2018 10:12 PM, Diab Jerius wrote:
> Howdy!
> 

Hi!

I somehow marked your email is read without having read it D:

> 
> But now I'm stuck.  How do I perform a join with the second subquery?

Currently you can not do this with DBIC-level APIs alone. There is no 
quick fix for this. But that's ok because at any point you can feed 
arbitrary SQL to the chaining structure.

You will have to do some surgery to assemble the query you want, by 
extracting it from $rs1->as_query / $rs2->as_query, and mangling the 
first value of the returned structure.

Then once you have the \[ $sql, @binds ] that you want to see you'd 
simply feed them to:

->search( {}, { from => \[...], <rest of attrs> } );

Hope this helps!



More information about the DBIx-Class mailing list