1DBIx::Class::SQLMaker::URsoelre:C:oSnQtDLrBAiI2bxPu:at:seCsdltahPsresor:ul:gShDQ(oL3cM)uamkeenrt:a:tRioolne::SQLA2Passthrough(3)
2
3
4

NAME

6       DBIx::Class::SQLMaker::Role::SQLA2Passthrough - A test of future
7       possibilities
8

SYNOPSIS

10       •   select and group_by options are processed using the richer SQLA2
11           code
12
13       •   expand_join_condition is provided to more easily express rich joins
14
15       See "examples/sqla2passthrough.pl" for a small amount of running code.
16

SETUP

18         (on_connect_call => sub {
19            my ($storage) = @_;
20            $storage->sql_maker
21                    ->with::roles('DBIx::Class::SQLMaker::Role::SQLA2Passthrough');
22         })
23
24   expand_join_condition
25         __PACKAGE__->has_many(minions => 'Blah::Person' => sub {
26           my ($args) = @_;
27           $args->{self_resultsource}
28                ->schema->storage->sql_maker
29                ->expand_join_condition(
30                    $args
31                  );
32         });
33
34   on
35         __PACKAGE__->has_many(minions => 'Blah::Person' => on {
36           { 'self.group_id' => 'foreign.group_id',
37             'self.rank' => { '>', 'foreign.rank' } }
38         });
39
40       Or with ParameterizedJoinHack,
41
42         __PACKAGE__->parameterized_has_many(
43             priority_tasks => 'MySchema::Result::Task',
44             [['min_priority'] => sub {
45                 my $args = shift;
46                 return +{
47                     "$args->{foreign_alias}.owner_id" => {
48                         -ident => "$args->{self_alias}.id",
49                     },
50                     "$args->{foreign_alias}.priority" => {
51                         '>=' => $_{min_priority},
52                     },
53                 };
54             }],
55         );
56
57       becomes
58
59         __PACKAGE__->parameterized_has_many(
60             priority_tasks => 'MySchema::Result::Task',
61             [['min_priority'] => on {
62               { 'foreign.owner_id' => 'self.id',
63                 'foreign.priority' => { '>=', { -value => $_{min_priority} } } }
64             }]
65         );
66
67       Note that foreign/self can appear in such a condition on either side,
68       BUT if you want DBIx::Class to be able to use a join-less version you
69       must ensure that the LHS is all foreign columns, i.e.
70
71         on {
72           +{
73             'foreign.x' => 'self.x',
74             'self.y' => { -between => [ 'foreign.y1', 'foreign.y2' ] }
75           }
76         }
77
78       is completely valid but DBIC will insist on doing a JOIN even if you
79       have a fully populated row object to call "search_related" on - to
80       avoid the spurious JOIN, you must specify it with explicit LHS foreign
81       cols as:
82
83         on {
84           +{
85             'foreign.x' => 'self.x',
86             'foreign.y1' => { '<=', 'self.y' },
87             'foreign.y2' => { '>=', 'self.y' },
88           }
89         }
90
91
92
93perl v5.36.0                  DBIx2:0:2C3l-a0s1s-:2:0SQLMaker::Role::SQLA2Passthrough(3)
Impressum