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



_______________________________________________
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