| 1 | package SQL::Abstract::Plugin::ExtraClauses; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | our $VERSION = '2.000003'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | with 'SQL::Abstract::Role::Plugin'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | sub register_extensions { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_extensions: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | my ($self, $sqla) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | my @clauses = $sqla->clauses_of('select'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | my @before_setop; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | CLAUSE: foreach my $idx (0..$#clauses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | if ($clauses[$idx] eq 'order_by') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | @before_setop = @clauses[0..$idx-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | splice(@clauses, $idx, 0, qw(setop group_by having)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | last CLAUSE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | die "Huh?" unless @before_setop; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | $sqla->clauses_of(select => @clauses); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | $sqla->clauses_of(update => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my ($self, @clauses) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | splice(@clauses, 2, 0, 'from'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | @clauses; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | $sqla->clauses_of(delete => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | my ($self, @clauses) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | splice(@clauses, 1, 0, 'using'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | @clauses; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $self->register( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | (map +( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | "${_}er" => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | my $x = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | (map +($_ => "_${x}_${_}"), qw(join from_list alias)) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ), qw(expand render)), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | binop_expander => [ as => '_expand_op_as' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | renderer => [ as => '_render_as' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | expander => [ cast => '_expand_cast' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | clause_expanders => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'select.group_by' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | ▶ | => sub { $_[0]->expand_expr({ -list => $_[2] }, -ident) }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'select.having' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | ▶ | => sub { $_[0]->expand_expr($_[2]) }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'update.from' => '_expand_from_list', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | "update.target", '_expand_update_clause_target', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | "update.update", '_expand_update_clause_target', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'delete.using' => '_expand_from_list', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | 'insert.rowvalues' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | +(from => $_[0]->expand_expr({ -values => $_[2] })); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | ▶ | 'insert.select' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 3 | +(from => $_[0]->expand_expr({ -select => $_[2] })); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | $sqla->expander(old_from => $sqla->clause_expander('select.from')); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | $sqla->wrap_clause_expander('select.from', sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | my ($orig) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 46 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 46 | my ($sqla, undef, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 46 | ▶ | if (ref($args) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 7 | return $self->_expand_from_list(undef, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 39 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $args eq "ARRAY" and grep {not ref $_ and $_ =~ /^-/;} @$args
MC/DC100%2/2
ref $args eq "ARRAY" and grep {not ref $_ and $_ =~ /^-/;} @$args
ref $args eq "ARRAY"
grep {not ref $_ and $_ =~ /^-/;} @$args
Truth table100%3/3
A and B
A= ref $args eq "ARRAY"B= grep {not ref $_ and $_ =~ /^-/;} @$args
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ref($args) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 60 | ▶ | and grep { !ref($_) and $_ =~ /^-/ } @$args | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
!ref($_) && $_ =~ /^-/
MC/DC100%2/2
!ref($_) && $_ =~ /^-/
!ref($_)
$_ =~ /^-/
Truth table100%3/3
not(A) && B
A= !ref($_)B= $_ =~ /^-/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 15 | return $self->_expand_from_list(undef, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 24 | return $sqla->$orig(undef, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # set ops | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | $sqla->wrap_expander(select => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | $self->cb('_expand_select', $_[0], \@before_setop); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | $self->register( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | clause_renderer => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | ▶ | 'select.setop' => sub { $_[0]->render_aqt($_[2]) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | ], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | expander => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | map +($_ => '_expand_setop', "${_}_all" => '_expand_setop'), qw(union intersect except) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | renderer => [ map +($_ => '_render_setop'), qw(union intersect except) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | my $setop_expander = $self->cb('_expand_clause_setop'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | $sqla->clause_expanders( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | map +($_ => $setop_expander), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | map "select.${_}", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | map +($_, "${_}_all", "${_}_distinct"), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | qw(union intersect except) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | foreach my $stmt (qw(select insert update delete)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 8 | $sqla->clauses_of($stmt => 'with', $sqla->clauses_of($stmt)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 8 | $self->register( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | clause_expanders => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | "${stmt}.with" => '_expand_with', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | "${stmt}.with_recursive" => '_expand_with', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | clause_renderer => [ "${stmt}.with" => '_render_with' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | return $sqla; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 50 | ▶ | sub _expand_select { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_select: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 50 | my ($self, $orig, $before_setop, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 50 | my $exp = $self->sqla->$orig(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 49 | ▶ | return $exp unless my $setop = (my $sel = $exp->{-select})->{setop}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | ▶ | if (my @keys = grep $sel->{$_}, @$before_setop) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | my %inner; @inner{@keys} = delete @{$sel}{@keys}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | unshift @{(values(%$setop))[0]->{queries}}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | { -select => \%inner }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | return $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 60 | ▶ | sub _expand_from_list { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_from_list: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 60 | my ($self, undef, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 60 | ▶ | if (ref($args) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 24 | ▶ | return $args if $args->{-from_list}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 21 | return { -from_list => [ $self->expand_expr($args) ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 36 | my @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 36 | ▶ | my @args = ref($args) eq 'ARRAY' ? @$args : ($args); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 36 | ▶ | while (my $entry = shift @args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 61 | ▶ | if (!ref($entry) and $entry =~ /^-(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $entry and $entry =~ /^-(.*)/
MC/DC100%2/2
not ref $entry and $entry =~ /^-(.*)/
not ref $entry
$entry =~ /^-(.*)/
Truth table100%3/3
not(A) and B
A= not ref $entryB= $entry =~ /^-(.*)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 25 | ▶ | if ($1 eq 'as') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 10 | ▶ | $list[-1] = $self->expand_expr({ -as => [ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | $list[-1], map +(ref($_) eq 'ARRAY' ? @$_ : $_), shift(@args) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ]}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 10 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 15 | $entry = { $entry => shift @args }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 51 | my $aqt = $self->expand_expr($entry, -ident); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 50 | ▶ | if ($aqt->{-join} and not $aqt->{-join}{from}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$aqt->{"-join"} and not $aqt->{"-join"}{"from"}
MC/DC50%1/2
$aqt->{"-join"} and not $aqt->{"-join"}{"from"}
$aqt->{"-join"}
not $aqt->{"-join"}{"from"}
Truth table66%2/3
A and not(B)
A= $aqt->{"-join"}B= not $aqt->{"-join"}{"from"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 13 | $aqt->{-join}{from} = pop @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 50 | push @list, $aqt; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 35 | ▶ | return $list[0] if @list == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | return { -from_list => \@list }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | my %known_join_keys = map +($_ => 1), qw(from type to as on using); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 17 | ▶ | sub _expand_join { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_join: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 17 | my ($self, undef, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 17 | ▶ | my %proto = ( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ref($args) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ? %$args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | : (to => @$args) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # accept the dashed spellings (-as, -on, ...) as well, since a from_list | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # is written with -as and -join; and refuse anything unknown instead of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # silently dropping it on render (RT#148271) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 17 | for my $k (keys %proto) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 52 | (my $bare = $k) =~ s/^-//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | $self->sqla->puke("Unknown key '$k' in -join (known: from, type, to, as, on, using)") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 52 | ▶ | unless $known_join_keys{$bare}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 51 | ▶ | $proto{$bare} = delete $proto{$k} if $bare ne $k; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 16 | ▶ | if (my $as = delete $proto{as}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | $proto{to} = $self->expand_expr( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 12 | { -as => [ { -from_list => $proto{to} }, $as ] } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 16 | ▶ | if (defined($proto{using}) and ref(my $using = $proto{using}) ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $proto{"using"} and ref(my $using = $proto{"using"}) ne "HASH"
MC/DC50%1/2
defined $proto{"using"} and ref(my $using = $proto{"using"}) ne "HASH"
defined $proto{"using"}
ref(my $using = $proto{"using"}) ne "HASH"
Truth table66%2/3
A and B
A= defined $proto{"using"}B= ref(my $using = $proto{"using"}) ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | $proto{using} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | ▶ | map [ $self->expand_expr($_, -ident) ], | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | ref($using) eq 'ARRAY' ? @$using: $using | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | my %ret = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | type => delete $proto{type}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 16 | to => $self->expand_expr({ -from_list => delete $proto{to} }, -ident) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | %ret = (%ret, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 16 | map +($_ => $self->expand_expr($proto{$_}, -ident)), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | sort keys %proto | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 16 | return +{ -join => \%ret }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 8 | ▶ | sub _render_from_list { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_from_list: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 8 | my ($self, undef, $list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 8 | return $self->join_query_parts(', ', @$list); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 13 | ▶ | sub _render_join { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_join: called CC=8 SCAR=21.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 13 | my ($self, undef, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | my @parts = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | $args->{from}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | { -keyword => join '_', ($args->{type}||()), 'join' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | (map +($_->{-ident} || $_->{-as} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ? $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | : ('(', $self->render_aqt($_, 1), ')')), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 13 | ▶ | map +(@{$_->{-from_list}||[]} == 1 ? $_->{-from_list}[0] : $_), | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%2/2
$_->{'-from_list'} || []
MC/DC100%1/1
$_->{'-from_list'} || []
$_->{'-from_list'}
Truth table100%2/2
A
A= $_->{'-from_list'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | $args->{to} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | ($args->{on} ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | { -keyword => 'on' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | $args->{on}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | ) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | ($args->{using} ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | { -keyword => 'using' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 13 | ▶ | '(', $args->{using}, ')', | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
$args->{'type'} || ()
$_->{"-ident"} or $_->{"-as"}
MC/DC0%0/2
$args->{'type'} || ()
$args->{'type'}
()
MC/DC0%0/2
$_->{"-ident"} or $_->{"-as"}
$_->{"-ident"}
$_->{"-as"}
Truth table33%1/3
A || B
A= $args->{'type'}B= ()
Truth table66%2/3
A or B
A= $_->{"-ident"}B= $_->{"-as"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 13 | return $self->join_query_parts(' ', @parts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 46 | ▶ | sub _expand_op_as { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_op_as: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 46 | my ($self, undef, $vv, $k) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 46 | ▶ | my @vv = (ref($vv) eq 'ARRAY' ? @$vv : $vv); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 46 | my $ik = $self->expand_expr($k, -ident); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 46 | ▶ | return +{ -as => [ $ik, $self->expand_expr($vv[0], -ident) ] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@vv == 1 and ref $vv[0] eq "HASH"
MC/DC100%2/2
@vv == 1 and ref $vv[0] eq "HASH"
@vv == 1
ref $vv[0] eq "HASH"
Truth table100%3/3
A and B
A= @vv == 1B= ref $vv[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | if @vv == 1 and ref($vv[0]) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 30 | my @as = map $self->expand_expr($_, -ident), @vv; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 30 | return { -as => [ $ik, $self->expand_expr({ -alias => \@as }) ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 30 | ▶ | sub _render_as { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_as: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 30 | my ($self, undef, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 30 | my ($thing, $alias) = @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 30 | return $self->join_query_parts( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ' ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | $thing, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | { -keyword => 'as' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | $alias, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 3 | ▶ | sub _render_alias { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_alias: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 3 | my ($self, undef, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | my ($as, @cols) = @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | return (@cols | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | ▶ | ? $self->join_query_parts('', | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | $as, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | '(', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | $self->join_query_parts( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ', ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | @cols | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ')', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | : $self->render_aqt($as) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | ▶ | sub _expand_update_clause_target { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_update_clause_target: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | my ($self, undef, $target) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 5 | +(target => $self->_expand_from_list(undef, $target)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | ▶ | sub _expand_cast { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_cast: called CC=2 SCAR=10.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | my ($self, undef, $thing) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | return { -func => [ cast => $thing ] } if ref($thing) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my ($cast, $to) = @{$thing}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | +{ -func => [ cast => { -as => [ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | $self->expand_expr($cast), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | $self->expand_expr($to, -ident), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | ] } ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 37 | ▶ | sub _expand_alias { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_alias: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 37 | my ($self, undef, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 37 | ▶ | if (ref($args) eq 'HASH' and my $alias = $args->{-alias}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $args eq "HASH" and my $alias = $args->{"-alias"}
MC/DC50%1/2
ref $args eq "HASH" and my $alias = $args->{"-alias"}
ref $args eq "HASH"
my $alias = $args->{"-alias"}
Truth table66%2/3
A and B
A= ref $args eq "HASH"B= my $alias = $args->{"-alias"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | $args = $alias; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | my @parts = map $self->expand_expr($_, -ident), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 37 | ▶ | ref($args) eq 'ARRAY' ? @{$args} : $args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 37 | ▶ | return $parts[0] if @parts == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 4 | return { -alias => \@parts }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | ▶ | sub _expand_with { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_with: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 5 | my ($self, $name, $with) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 5 | my (undef, $type) = split '_', $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | ▶ | if (ref($with) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | return +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | %$with, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | queries => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | map +[ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | $self->expand_expr({ -alias => $_->[0] }, -ident), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | $self->expand_expr($_->[1]), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | ], @{$with->{queries}} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 4 | my @with = @$with; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 4 | my @exp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 4 | ▶ | while (my ($alias, $query) = splice @with, 0, 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 6 | push @exp, [ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | $self->expand_expr({ -alias => $alias }, -ident), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | $self->expand_expr($query) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 4 | ▶ | return +(with => { ($type ? (type => $type) : ()), queries => \@exp }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 4 | ▶ | sub _render_with { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_with: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 4 | my ($self, undef, $with) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | my $q_part = $self->join_query_parts(', ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 6 | my ($alias, $query) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 6 | $self->join_query_parts(' ', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | $alias, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | { -keyword => 'as' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 4 | } @{$with->{queries}} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | return $self->join_query_parts(' ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 4 | ▶ | { -keyword => join '_', 'with', ($with->{type}||'') }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$with->{'type'} || ''
MC/DC100%1/1
$with->{'type'} || ''
$with->{'type'}
Truth table100%2/2
A
A= $with->{'type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | $q_part, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 4 | ▶ | sub _expand_setop { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_setop: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 4 | my ($self, $setop, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | my $is_all = $setop =~ s/_all$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | +{ "-${setop}" => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ($is_all ? (type => 'all') : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | (ref($args) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ? (queries => [ map $self->expand_expr($_), @$args ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | %$args, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 4 | ▶ | queries => [ map $self->expand_expr($_), @{$args->{queries}} ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 3 | ▶ | sub _render_setop { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render_setop: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 3 | my ($self, $setop, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | $self->join_query_parts( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | { -keyword => ' '.join('_', $setop, ($args->{type}||())).' ' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 3 | ▶ | @{$args->{queries}} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args->{'type'} || ()
MC/DC0%0/2
$args->{'type'} || ()
$args->{'type'}
()
Truth table66%2/3
A || B
A= $args->{'type'}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 3 | ▶ | sub _expand_clause_setop { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_clause_setop: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 3 | my ($self, $setop, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 3 | my ($op, $type) = split '_', $setop; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 3 | ▶ | +(setop => $self->expand_expr({ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | "-${op}" => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | ($type ? (type => $type) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | queries => (ref($args) eq 'ARRAY' ? $args : [ $args ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | })); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||