[Dbix-class] Fine-tuning of prefetched relationships

Shea Levy shea.levy at logicblox.com
Mon Apr 1 12:54:55 GMT 2013


Hi Peter,

On 04/01/2013 08:46 AM, Peter Rabbitson wrote:
> On Mon, Apr 01, 2013 at 08:43:43AM -0400, Shea Levy wrote:
>> Hi all,
>>
>> In my db, a Project has many Jobs. I have a query on Projects where
>> I want to:
>>
>> 1. Sort the jobs of each project by a particular column on the Jobs table
>> 2. Only include jobs that satisfy some criterion, without excluding
>>     projects where no such jobs exist (i.e. add a condition to JOIN ON,
>>     not WHERE)
>>
>> Are either of these possible with a single search on Projects?
>> Currently we're breaking it up into two queries.
> Both are possible using usual syntax (and a custom-condition
> relationship) in a single query using the 0.08242 or greater (not yet
> released) version.

So something like (using Catalyst in my project):

$c->model('DB::Projects')->search({ "jobs.hidden" => 0} {order_by => 
"jobs.name" })

will work with that version?

Thanks,
Shea

>
> Cheers
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk




More information about the DBIx-Class mailing list