[Dbix-class] LEFT OUT JOIN with custom condition/bind value

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Nov 26 06:50:12 GMT 2012


On Sun, Nov 25, 2012 at 09:40:19PM +0000, Aaron Trevena wrote:
> On 25 November 2012 15:27, Peter Rabbitson <rabbit+dbic at rabbit.us> wrote:
> > On Sat, Nov 24, 2012 at 04:26:37PM +0100, Sven Eppler wrote:
> >> I know about the CODEREF-Option for defining Relationship-Conditions.
> >> But they don't seem to solve my problem, right?
> >
> > Not entirely. The coderef is invoked every time a query is generated,
> > and the contents of the coderef are made of perl ;)
> >
> > So the short-term ugly-as-fuck-but-usable solution is:
> >
> > ...->has_many(... sub {
> >   my $varcond = $My::Secret::Global::varcond
> >     or die 'You forgot to set $My::Secret::Global::varcond';
> >   ...
> > });
> >
> > and then:
> >
> > my @res = do {
> >   local $My::Secret::Global::varcond = 42;
> >   $rs->search(...)->all;
> > };
> >
> > Long term the plan is to have something along these lines[1]. The reason
> > this is not yet imlemented is the usual - tuits. It is also not a trivial
> > task as the underpinnings are not yet smart eniough to handle something
> > of this complexity.
> 
> Presumably you could use a method in the resultset to take an arg and
> wrap it transparently so you never see the fugly in the rest of your
> code?

Of course, hence the "made of perl" part. The only thing I am pointing out
is that DBIC itself does not yet provide a *scalable* solution for this,
and punts situation-specific micro-solutions to the user.

Naturally patches implementing the feature as described in the link I
gave earlier are beyond welcome.

Cheers





More information about the DBIx-Class mailing list