I have just learned, that the JOIN syntax was improved recently, so it is possible to specify more than just the equality of column values, as shown in the example from DBIx::Class::Relationship::Base:

My::Schema::Artist->has_many(
  cds_80s => 'My::Schema::CD',
  sub {
    my $args = shift;

    return {
"$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
      "$args->{foreign_alias}.year"   => { '>', "1979", '<', "1990" },
    };
  }
);

...

$artist_rs->search_related('cds_80s')->next;


The example above still requires the bind values to be defined statically in the schema. I couldn't find any examples, about how to specify bind values at execution time - e.g. likes this:

My::Schema::Artist->has_many(
  cds_era => 'My::Schema::CD',
  sub {
    my $args = shift;

    return {
"$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
      "$args->{foreign_alias}.year"   => { '>', \'?', '<', \'?' },
    };
  }
);

...

$artist_rs->search_related('cds_era', {}, {bind => ['1979', '1990'])->next;


Isn't something like this possible?


Bernhard

_______________________________________________
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/[email protected]

Reply via email to