[Dbix-class] custom join condition weirdness
Peter Rabbitson
rabbit+dbic at rabbit.us
Sat Dec 20 16:14:19 GMT 2014
On 12/01/2014 07:31 PM, Peter Mottram wrote:
> I'm working on a custom join condition for use in
> https://metacpan.org/pod/Interchange6::Schema full reasons for which are
> hard to explain - maybe we'll get to that in a later email if
> explanation is needed.
>
> I've added a new relationship to my Product class:
>
> has_many
> current_price_modifiers => "Interchange6::Schema::Result::PriceModifier",
> sub {
> ...
> },
> );
> };
>
> ....
> bind => [
> [ end_date => $today ],
> [ quantity => $args->{quantity} ],
> [ { sqlt_datatype => "integer" } => $args->{users_id} ],
> [ start_date => $today ],
> ],
>
Sorry for the late reply. The gist is that the 'bind' attribute does not
do what you think it does. It is essentially a "Static list to add to
pre-from bind's (that is between SELECT and FROM)". I have a half
finished branch that updates this documentation, I will try to get it in
today/tomorrow.
Anyway - the above could never work. There is a slowly progressing way
to pass args to the custom cond, but the rabbit hole keeps going deeper
and deeper, though I hope to be able to push a preliminary version
before FOSDEM.
In the meantime your solution using a view is likely better than the
currently recommended workaround (which I am the first to admit is
hideous):
https://blog.afoolishmanifesto.com/posts/dbix-class-parameterized-relationships/
Sorry for the API not being awesome enough yet :)
Cheers
More information about the DBIx-Class
mailing list