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

Peter Rabbitson rabbit+dbic at rabbit.us
Sun Nov 25 15:27:50 GMT 2012

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;

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.


[1] https://github.com/dbsrgits/dbix-class/blob/rfc/todo_list/lib/DBIx/Class/Manual/Dev/TODO.pod#relationship-arguments

More information about the DBIx-Class mailing list