On Thu, 17 May 2018 11:12:45 +0200 do...@united-domains.de wrote:
> Is it possible to create a relationship which has, along with the
> join condition, an additional constraint where the value could
> somehow be passed when the search() method is called?

This should answer your question:


Interestingly the post has been updated since I last looked at it
saying that approach no longer works. I'm not sure why, as it still
seems to work for me. Frew - can you elaborate?

>  - Get a list of all movies, as well as a review by Sue if it exists 
>  - If a movie does not have a review by Sue then it should still be
> returned with reviews.text = NULL.
>  - If a movie does not have a review by Sue but it has a review by
> someone else then it should also be returned with reviews.text = NULL

The other method you might want to consider is using a correlated
sub-query. It's a little cleaner from a DBIx::Class viewpoint, but I
think you'd need to pull out each review column separately, so would
depend what you want to retrieve. Another excellent blog from Frew:


It allows you to do something like this (untested):

  '+columns' => {
     sue_review => $self->schema->resultset('Review')
       ->search({ person => 'sue' })


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

Reply via email to