[Dbix-class] Passing values to a custom join condition
Andrew Beverley
andy at andybev.com
Sun Jan 5 21:44:13 GMT 2014
I'm using add_relationship to create a custom join condition, as
described at
https://metacpan.org/pod/DBIx::Class::Relationship::Base#condition
In a similar vein to the example in the manual, I have created the
following relationship:
__PACKAGE__->has_many(
"site_single_tasks",
"Lenio::Schema::Result::SiteTask",
sub {
my $args = shift;
return {
"$args->{foreign_alias}.task_id" =>
{ -ident => "$args->{self_alias}.id" },
"$args->{foreign_alias}.site_id" =>
{ '=', "100" },
};
},
{ cascade_copy => 0, cascade_delete => 0 },
);
My question: is it possible for the value "100" in my code above to be a
variable, with the value passed from ->search (or otherwise). I can't
see anything in the args that are passed to the function that could be
used.
The reason I'd like to do this, is that in my join I only want certain
values from the table being joined; I want the missing ones to have a
value of NULL, which would not be possible with a simple WHERE
condition.
Thanks,
Andy
More information about the DBIx-Class
mailing list