1 package DBIx::Class::SQLMaker::Role::SQLA2Passthrough;
13 $args->{self_resultsource}
14 ->schema->storage->sql_maker
15 ->expand_join_condition(
24 around select => sub {
25 my ($orig, $self, $table, $fields, $where, $rs_attrs, $limit, $offset) = @_;
27 $fields = \[ $self->render_expr({ -list => [
29 map +(ref($_) eq 'HASH'
32 my $as = delete $f{-as};
34 my $func = +{ ($f =~ /^-/ ? $f : "-${f}") => $rhs };
36 ? +{ -op => [ 'as', $func, { -ident => [ $as ] } ] }
39 : $_), ref($fields) eq 'ARRAY' ? @$fields : $fields
42 if (my $gb = $rs_attrs->{group_by}) {
45 group_by => \[ $self->render_expr({ -list => $gb }, -ident) ]
48 $self->$orig($table, $fields, $where, $rs_attrs, $limit, $offset);
51 sub expand_join_condition {
52 my ($self, $cond, $args) = @_;
56 my $res = $orig->(@_);
57 my ($name, @rest) = @{$res->{-ident}};
58 if ($name eq 'self' or $name eq 'foreign') {
59 $res->{-ident} = [ $args->{"${name}_alias"}, @rest ];
64 my $sqla = $self->clone->wrap_op_expander(ident => $wrap);
65 $sqla->expand_expr($cond, -ident);
74 (on_connect_call => sub {
77 ->with::roles('DBIx::Class::SQLMaker::Role::SQLA2Passthrough');
80 =head2 expand_join_condition
82 __PACKAGE__->has_many(minions => 'Blah::Person' => sub {
84 $args->{self_resultsource}
85 ->schema->storage->sql_maker
86 ->expand_join_condition(
93 __PACKAGE__->has_many(minions => 'Blah::Person' => on {
94 { 'self.group_id' => 'foreign.group_id',
95 'self.rank' => { '>', 'foreign.rank' } }
98 Or with ParameterizedJoinHack,
100 __PACKAGE__->parameterized_has_many(
101 priority_tasks => 'MySchema::Result::Task',
102 [['min_priority'] => sub {
105 "$args->{foreign_alias}.owner_id" => {
106 -ident => "$args->{self_alias}.id",
108 "$args->{foreign_alias}.priority" => {
109 '>=' => $_{min_priority},
117 __PACKAGE__->parameterized_has_many(
118 priority_tasks => 'MySchema::Result::Task',
119 [['min_priority'] => on {
120 { 'foreign.owner_id' => 'self.id',
121 'foreign.priority' => { '>=', { -value => $_{min_priority} } } }