[Dbix-class] Subquery question

Nigel Metheringham Nigel.Metheringham at dev.intechnology.co.uk
Fri May 19 09:55:48 CEST 2006


On Thu, 2006-05-18 at 18:12 +0200, A. Pagaltzis wrote:
> * 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.

It doesn't work as written - although I am sure I had it doing so at
some point, but that must be delusion since I really can't reproduce it
now.  See the messages I wrote yesterday for an alternative working
method.

	Nigel.

-- 
[ Nigel Metheringham           Nigel.Metheringham at InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]




More information about the Dbix-class mailing list