[Dbix-class] Subquery question

A. Pagaltzis pagaltzis at gmx.de
Thu May 18 18:12:20 CEST 2006


* Nigel Metheringham <Nigel.Metheringham at dev.intechnology.co.uk> [2006-05-16 15:00]:
> Here's an example I have it returns all items in one table
> (TaskLog) old than $fromdate and not referenced by another
> (task_last_run)
> 
>     my $rs     = $schema->resultset('TaskLog');
>     my $subsel = '(SELECT tl_id FROM task_last_run)';
>     my $qry    = $rs->search(
>         {
>             tl_timestamp => { '<=',   $fromdate },
>             tl_id        => { -not_in => \$subsel }
>         }
>     );
> 
> The magic trick is the reference to a string containing raw SQL
> - this is documented in the SQL::Abstract documentation.

Are you sure that this works? Has SQL::Abstract had an API
upgrade while I wasn’t looking? A year ago, I spent several
evenings trying to coerce it to do subqueries sanely but failed.

(At the time, my conclusion was that using pure anonymous data
structures as an abstraction is broken and that a sane API would
have to use objects to represent aspects of a query in order to
facilitate proper composition. I sighed, stuck it into my project
idea list along with a few conceptual notes, and found other
things to do.)

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



More information about the Dbix-class mailing list