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.

Cheers

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


_______________________________________________
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