| 1 | package DBIx::EAV::Cursor; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use Carp qw/ croak confess /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use SQL::Abstract; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Scalar::Util qw/ blessed /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | my $sql = SQL::Abstract->new(); | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | has 'eav', is => 'ro', required => 1; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | has 'type', is => 'ro', required => 1; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | has 'query', is => 'ro', default => sub { {} }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | has 'options', is => 'ro', default => sub { {} }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 10 | has '_sth', is => 'ro', lazy => 1, builder => 1, predicate => '_has_sth', clearer => '_reset_sth'; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | sub _check_query_already_executed { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_query_already_executed: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | croak "Query already executed!" if defined $self->_sth; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | sub _build__sth { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 94 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__sth: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 94 | my ($sql_query, $bind) = $self->_build_sql_query(); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 94 | my ($rv, $sth) = $self->eav->table('entities')->_do($sql_query, $bind); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 94 | $sth; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | sub _build_sql_query { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 100 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_sql_query: called CC=39 SCAR=36.7
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 100 | my $opts = $self->options; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 100 | my $eav = $self->eav; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 100 | my $type = $self->type; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 100 | my $entities_table = $eav->table('entities'); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 100 | my ($order_by, $group_by, $having, %parser_data, %replacements); | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | # selected field | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 20 | my @select_fields = $opts->{select} ? @{$opts->{select}} | |||||||||||||||||||||||||||||||||||||||||
| 45 | 100 | ▶ | : @{$entities_table->columns}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | # distinct (before normalizing @select_fields) | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 100 | ▶ | if ($opts->{distinct}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | # if has group_by, warn and ignore distinct | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | ▶ | if ($opts->{group_by}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # exclude id from group by to make the distinct effect | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | ▶ | $opts->{group_by} = [grep { !ref && $_ !~ /^(me\.|)id$/ } @select_fields]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $_ || $_ =~ /^(me\.|)id$/
MC/DC50%1/2
ref $_ || $_ =~ /^(me\.|)id$/
ref $_
$_ =~ /^(me\.|)id$/
Truth table66%2/3
A || B
A= ref $_B= $_ =~ /^(me\.|)id$/
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | # normalize select fields | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 100 | ▶ | for (my $i = 0; $i < @select_fields; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | # literal, dont touch | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 230 | ▶ | next if ref $select_fields[$i] eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 216 | my $ident = $select_fields[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 216 | my ($fn, $as); | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | # sql function | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 216 | ▶ | if (ref $ident) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | $as = delete $ident->{'-as'}; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ($fn, $ident) = each %$ident; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | unless ($as) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | $as = lc($fn.'_'.$ident); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | $as =~ s/\./_/g; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | $parser_data{aliases}{$as} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 216 | my $info = $self->_parse_clause_identifier($ident, \%parser_data); | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | $select_fields[$i] = $fn ? \(sprintf "%s( %s ) AS %s", uc $fn, $info->{replacement}, $as) | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 216 | ▶ | : $info->{replacement}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | # add type criteria unless we have a subselect ('from' option) | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 100 | ▶ | my $type_criteria = $opts->{from} ? [] : [ entity_type_id => $type->id ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 100 | ▶ | if ($opts->{subtype_depth}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | push @$type_criteria, [ '_parent_type_'.$_, $type->id ] | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | for 1 .. $opts->{subtype_depth}; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | # parse WHERE | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 100 | my ($where, @bind) = $sql->where({ -and => [ $type_criteria, $self->query] }); | |||||||||||||||||||||||||||||||||||||||||
| 99 | 100 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 100 | my $where_re = qr/ ([\w._]+) (?:=|!=|<>|>|<|>=|<=|IN|IS NULL|LIKE|NOT LIKE) \?/; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 100 | ▶ | while ($where =~ /$where_re/g) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 176 | my $ident = $1; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 176 | my $info = $self->_parse_clause_identifier($ident, \%parser_data, $bind[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | $bind[$i] = $info->{bind} | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 176 | ▶ | if exists $info->{bind}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 176 | $replacements{$ident} = $info->{replacement}; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 176 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | # replace identifiers in WHERE | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 100 | ▶ | while (my ($string, $replacement) = each %replacements) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 173 | $where =~ s/\b$string\b/$replacement/g; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | # parse ORDER BY | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 100 | ▶ | if (defined $opts->{order_by}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 10 | %replacements = (); | |||||||||||||||||||||||||||||||||||||||||
| 124 | 10 | $order_by = $sql->where(undef, $opts->{order_by}); | |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 10 | ▶ | while ($order_by =~ / ([\w._]+)(?: ASC| DESC|,|$)/g) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 11 | my $ident = $1; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 11 | my $info = $self->_parse_clause_identifier($ident, \%parser_data); | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | die "Cursor: query error: can't order by relationship! ($ident)'" | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 11 | ▶ | if $info->{is_relationship}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 11 | $replacements{$ident} = $info->{replacement}; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | # replace identifiers | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 10 | ▶ | while (my ($string, $replacement) = each %replacements) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 11 | $order_by =~ s/\b$string\b/$replacement/g; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # prepare prefetch attributes | ||||||||||||||||||||||||||||||||||||||||||
| 144 | # if ($opts->{prefetch}) { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | # foreach my $attr (ref $opts->{prefetch} eq 'ARRAY' ? @{$opts->{prefetch}} : ($opts->{prefetch})) { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | # die "unknown attribute given to prefetch: '$attr'" | ||||||||||||||||||||||||||||||||||||||||||
| 147 | # unless $attr =~ /^(?:$possible_attrs)$/; | ||||||||||||||||||||||||||||||||||||||||||
| 148 | # | ||||||||||||||||||||||||||||||||||||||||||
| 149 | # $join_attr{$attr} = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 150 | # push @select_fields, "$attr.value AS $attr"; | ||||||||||||||||||||||||||||||||||||||||||
| 151 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | # parse ORDER BY | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 100 | ▶ | if (defined $opts->{group_by}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 7 | my @fields; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 7 | ▶ | foreach my $ident (ref $opts->{group_by} eq 'ARRAY' ? @{$opts->{group_by}} : $opts->{group_by}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 9 | my $info = $self->_parse_clause_identifier($ident, \%parser_data); | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | die "Cursor: query error: can't group by a relationship! ($ident)'" | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 9 | ▶ | if $info->{is_relationship}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 9 | push @fields, $info->{replacement}; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 7 | $group_by .= 'GROUP BY '. join(', ', @fields); | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | # parse HAVING | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 100 | ▶ | if (defined $opts->{having}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | my @having_bind; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ($having, @having_bind) = $sql->where($opts->{having}); | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | push @bind, @having_bind; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | $having =~ s/^\s*WHERE/HAVING/; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | %replacements = (); | |||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | ▶ | while ($having =~ /$where_re/g) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | my $ident = $1; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | my $info = $self->_parse_clause_identifier($ident, \%parser_data); | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | $replacements{$ident} = $info->{replacement}; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | # replace identifiers | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | while (my ($string, $replacement) = each %replacements) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | $having =~ s/\b$string\b/$replacement/g; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | # build sql statement | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | # SELECT ... FROM | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | # from subselect | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 100 | my $from = $entities_table->name; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 100 | ▶ | if (my $subquery = $opts->{from}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | my ($sub_select, $sub_bind) = @$$subquery; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | $from = "($sub_select)"; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 3 | push @bind, @$sub_bind; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 100 | my $sql_query = $sql->select("$from AS me", \@select_fields); | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | # JOINs | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 100 | ▶ | if (my $depth = $opts->{subtype_depth}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 3 | my $hierarchy_table = $eav->table("type_hierarchy")->name; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | $sql_query .= " LEFT JOIN $hierarchy_table AS _parent_type_1 ON (_parent_type_1.child_type_id = me.entity_type_id)"; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 3 | my $i = 2; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | ▶ | while ($depth > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | $sql_query .= sprintf(" LEFT JOIN $hierarchy_table AS _parent_type_%d ON (_parent_type_%d.child_type_id = _parent_type_%d.parent_type_id)", | |||||||||||||||||||||||||||||||||||||||||
| 219 | $i, $i, $i - 1); | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | $depth--; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 100 | ▶ | $sql_query .= " $_" for @{$parser_data{joins} || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | # WHERE, GROUP BY, HAVING, ORDER BY | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 100 | $sql_query .= " $where"; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 100 | ▶ | $sql_query .= " $group_by" if defined $group_by; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 100 | ▶ | $sql_query .= " $having" if defined $having; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 100 | ▶ | $sql_query .= " $order_by" if defined $order_by; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | # LIMIT / OFFSET | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 100 | ▶ | if ($opts->{limit}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | ▶ | die "invalid limit" unless $opts->{limit} =~ /^\d+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | $sql_query .= " LIMIT $opts->{limit}"; | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | if (defined $opts->{offset}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | ▶ | die "invalid offset" unless $opts->{offset} =~ /^\d+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | $sql_query .= " OFFSET $opts->{offset}"; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | # return query and bind values | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 100 | ($sql_query, \@bind); | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | sub _parse_clause_identifier { | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 414 | ▶ | my ($self, $identifier, $parser_data, $bind_value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_clause_identifier: called CC=23 SCAR=31.9
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | # cached | ||||||||||||||||||||||||||||||||||||||||||
| 252 | return $parser_data->{cache}->{$identifier} | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 414 | ▶ | if exists $parser_data->{cache}->{$identifier}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 328 | my $type = $self->type; | |||||||||||||||||||||||||||||||||||||||||
| 256 | 328 | my $eav = $self->eav; | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | # special case: parent_type | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 328 | ▶ | return $parser_data->{cache}->{$identifier} = { replacement => $identifier.'.parent_type_id' } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | if $identifier =~ /^_parent_type_\d+$/; | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | # special case: alias | ||||||||||||||||||||||||||||||||||||||||||
| 263 | return { replacement => $identifier } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 322 | ▶ | if exists $parser_data->{aliases}{$identifier}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | # remove me. | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 319 | $identifier =~ s/^me\.//; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | # parse possibly deep related identifier | ||||||||||||||||||||||||||||||||||||||||||
| 270 | # valid formats: | ||||||||||||||||||||||||||||||||||||||||||
| 271 | # - <attr> | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # - <rel> | ||||||||||||||||||||||||||||||||||||||||||
| 273 | # - <rel>+.<attr> | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 319 | my @parts = split /\./, $identifier; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 319 | my @joins; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 319 | my $current_type = $type; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 319 | my $current_entity_alias = 'me'; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 319 | my @rels; | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 319 | ▶ | for (my $i = 0; $i < @parts; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 323 | my $id_part = $parts[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 323 | ▶ | if ($current_type->has_relationship($id_part)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 50 | my $rel = $current_type->relationship($id_part); | |||||||||||||||||||||||||||||||||||||||||
| 288 | 50 | ▶ | my ($our_side, $their_side) = $rel->{is_right_entity} ? qw/ right left / : qw/ left right /; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 50 | push @rels, $rel->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 50 | my $current_rel_alias = join '_', @rels, 'link'; | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | # join relationship table | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 50 | ▶ | unless ($parser_data->{joined}{$current_rel_alias}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 49 | push @{$parser_data->{joins}}, sprintf "INNER JOIN %sentity_relationships AS %s ON %s.id = %s.%s_entity_id AND %s.relationship_id = %d", | |||||||||||||||||||||||||||||||||||||||||
| 296 | $eav->schema->table_prefix, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | $current_rel_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 298 | $current_entity_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 299 | $current_rel_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 300 | $our_side, | ||||||||||||||||||||||||||||||||||||||||||
| 301 | $current_rel_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 49 | $rel->{id}; | |||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 49 | $parser_data->{joined}{$current_rel_alias} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | # endpart is the relationship itself | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 50 | ▶ | if ($i == $#parts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 46 | ▶ | if (defined $bind_value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | die "Cursor: query error: the entity given to '$identifier' is not an entity of type '$rel->{entity}'." | ||||||||||||||||||||||||||||||||||||||||||
| 313 | unless blessed $bind_value | ||||||||||||||||||||||||||||||||||||||||||
| 314 | && $bind_value->isa('DBIx::EAV::Entity') | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 44 | ▶ | && $bind_value->is_type($rel->{entity}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
builtin::blessed($bind_value) and $bind_value->isa("DBIx::EAV::Entity") and $bind_value->is_type($rel->{"entity"})
builtin::blessed($bind_value) and $bind_value->isa("DBIx::EAV::Entity")
MC/DC0%0/3
builtin::blessed($bind_value) and $bind_value->isa("DBIx::EAV::Entity") and $bind_value->is_type($rel->{"entity"})
builtin::blessed($bind_value)
$bind_value->isa("DBIx::EAV::Entity")
$bind_value->is_type($rel->{"entity"})
Truth table25%1/4
A and B and C
A= builtin::blessed($bind_value)B= $bind_value->isa("DBIx::EAV::Entity")C= $bind_value->is_type($rel->{"entity"})
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 44 | ▶ | die "Cursor: query error: the '$rel->{entity}' instance given to '$identifier' is not in storage." | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | unless $bind_value->in_storage; | ||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | # set replacement for WHERE, and change bind value to the entity id | ||||||||||||||||||||||||||||||||||||||||||
| 322 | # note: dont cache this result because bindvalue can change | ||||||||||||||||||||||||||||||||||||||||||
| 323 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 46 | ▶ | replacement => $current_rel_alias .'.'. $their_side.'_entity_id', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | bind => $bind_value ? $bind_value->id : '', | ||||||||||||||||||||||||||||||||||||||||||
| 326 | is_relationship => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | # step into the related type | ||||||||||||||||||||||||||||||||||||||||||
| 330 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 4 | $current_type = $eav->type($rel->{entity}); | |||||||||||||||||||||||||||||||||||||||||
| 333 | $current_entity_alias = $current_entity_alias eq 'me' ? $rel->{name} | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 4 | ▶ | : $current_entity_alias.'_'.$rel->{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 4 | ▶ | unless ($parser_data->{joined}{$current_entity_alias}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 4 | push @{$parser_data->{joins}}, sprintf "INNER JOIN %sentities AS %s ON %s.id = %s.%s_entity_id", | |||||||||||||||||||||||||||||||||||||||||
| 339 | $eav->schema->table_prefix, | ||||||||||||||||||||||||||||||||||||||||||
| 340 | $current_entity_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 341 | $current_entity_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 342 | $current_rel_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 343 | $their_side; | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 4 | $parser_data->{joined}{$current_entity_alias} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | elsif ($current_type->has_static_attribute($id_part)) { | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | # attribute allowed only at the and | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 227 | ▶ | confess "Cursor: query error: invalid identifier '$identifier': attribute only allowed at the and of identifier." | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | if $i < $#parts; | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 227 | return $parser_data->{cache}->{$identifier} = { | |||||||||||||||||||||||||||||||||||||||||
| 357 | replacement => $current_entity_alias.'.'.$id_part, | ||||||||||||||||||||||||||||||||||||||||||
| 358 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | elsif ($current_type->has_attribute($id_part)) { | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | # attribute allowed only at the and | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 46 | ▶ | confess "Cursor: query error: invalid identifier '$identifier': attribute only allowed at the and of identifier." | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | if $i < $#parts; | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 46 | my $attr = $current_type->attribute($id_part); | |||||||||||||||||||||||||||||||||||||||||
| 368 | my $join_alias = $current_entity_alias eq 'me' ? $attr->{name} | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 46 | ▶ | : $current_entity_alias.'_'.$attr->{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 46 | ▶ | unless ($parser_data->{joined}{$join_alias}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 34 | push @{$parser_data->{joins}}, sprintf "LEFT JOIN %svalue_%s AS %s ON (%s.entity_id = %s.id AND %s.attribute_id = %s)", | |||||||||||||||||||||||||||||||||||||||||
| 373 | $eav->schema->table_prefix, | ||||||||||||||||||||||||||||||||||||||||||
| 374 | $attr->{data_type}, | ||||||||||||||||||||||||||||||||||||||||||
| 375 | $join_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 376 | $join_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 377 | $current_entity_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 378 | $join_alias, | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 34 | $attr->{id}; | |||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 34 | $parser_data->{joined}{$join_alias} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 46 | return { replacement => $join_alias.'.value' } | |||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | die sprintf "Cursor: query error: invalid identifier '%s': '%s' is not a valid attribute/relationship for '%s'\n", | |||||||||||||||||||||||||||||||||||||||||
| 388 | $identifier, | ||||||||||||||||||||||||||||||||||||||||||
| 389 | $id_part, | ||||||||||||||||||||||||||||||||||||||||||
| 390 | $current_type->name; | ||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | sub as_query { | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 6 | ▶ | \[shift->_build_sql_query]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_query: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | sub reset { | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | $self->_reset_sth; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 3 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | sub first { | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 2 | ▶ | $_[0]->reset->next; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | sub next { | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 195 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 195 | $self->_sth->fetchrow_hashref; | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | sub all { | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my @rows; | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $self->reset; | |||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | while (my $row = $self->next) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | push @rows, $row; | |||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $self->reset; | |||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | return wantarray ? @rows : \@rows; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | __END__ | ||||||||||||||||||||||||||||||||||||||||||