| 1 | package DBI::Easy; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # use Hash::Merge; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use Class::Easy; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 61 | ▶ | sub statement { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
statement: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 61 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 61 | my $statement = shift; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 61 | ▶ | my $dbh_method = shift || 'dbh'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 'dbh'
MC/DC100%1/1
shift() || 'dbh'
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 61 | my $dbh = $self->$dbh_method; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 61 | my $sth; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 61 | ▶ | if (ref $statement eq 'DBI::st') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | $sth = $statement; | |||||||||||||||||||||||||||||||||||||||||
| 17 | } elsif (ref $statement) { | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | die "can't use '$statement' as sql statement"; | |||||||||||||||||||||||||||||||||||||||||
| 19 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 59 | my $prepare_method = $self->prepare_method; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 59 | $sth = $dbh->$prepare_method (($statement, {}, $self->prepare_param)); | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 61 | return $sth; | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 61 | ▶ | sub bind_values { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind_values: called CC=4 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 61 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 61 | my $sth = shift; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 61 | my $bind = shift; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 61 | foreach my $i (0 .. $#$bind) { | |||||||||||||||||||||||||||||||||||||||||
| 34 | 73 | my $v = $bind->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 73 | my @bind_v = ($v); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 73 | ▶ | if (ref $v eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | die "you must supply bind type within \%DBI::Easy::BIND_TYPES" | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | unless exists $DBI::Easy::BIND_TYPES{$v->[1]}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $opts = $DBI::Easy::BIND_TYPES{$v->[1]}; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | #if (exists $opts->{ora_type}) { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # warn Encode::is_utf8 ($v->[0]); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # $opts->{ora_csform} = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $opts->{ora_field} = $v->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | @bind_v = ($v->[0], $opts); | |||||||||||||||||||||||||||||||||||||||||
| 51 | #use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||
| 52 | #warn "bind for param ", $i + 1, ", for " . Dumper $opts; | ||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 73 | $sth->bind_param ($i + 1, @bind_v); | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # for every query except select we must use this routine | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 21 | ▶ | sub no_fetch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
no_fetch: called CC=11 SCAR=26.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 21 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 21 | my $statement = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 21 | my $params = shift; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 21 | my $seq = shift; | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 21 | ▶ | $params = [defined $params ? $params : ()] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | unless ref $params; | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 21 | my $dbh_method = 'dbh_modify'; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 21 | my $dbh = $self->dbh_modify; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 21 | my $rows_affected; | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 21 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 74 | 21 | my $sth = $self->statement ($statement, $dbh_method); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 21 | $self->bind_values ($sth, $params); | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 21 | $rows_affected = $sth->execute; | |||||||||||||||||||||||||||||||||||||||||
| 78 | # $sth->finish; | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 21 | ▶ | if (! ref $statement and $statement =~ /^\s*insert/io and defined $rows_affected) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not ref $statement and $statement =~ /^\s*insert/io and defined $rows_affected
not ref $statement and $statement =~ /^\s*insert/io
MC/DC33%1/3
not ref $statement and $statement =~ /^\s*insert/io and defined $rows_affected
not ref $statement
$statement =~ /^\s*insert/io
defined $rows_affected
Truth table50%2/4
not(A) and B and C
A= not ref $statementB= $statement =~ /^\s*insert/ioC= defined $rows_affected
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 16 | ▶ | if (defined $seq) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $rows_affected = $self->fetch_single ("select ${seq}.currval as maxid from dual"); | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | ▶ | } elsif ($self->dbh_vendor ne 'oracle' and defined $self->_pk_) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->dbh_vendor ne "oracle" and defined $self->_pk_
MC/DC0%0/2
$self->dbh_vendor ne "oracle" and defined $self->_pk_
$self->dbh_vendor ne "oracle"
defined $self->_pk_
Truth table33%1/3
A and B
A= $self->dbh_vendor ne "oracle"B= defined $self->_pk_
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 16 | $rows_affected = $dbh->last_insert_id ( | |||||||||||||||||||||||||||||||||||||||||
| 87 | undef, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | undef, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | $self->table_name, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | $self->_pk_column_ | ||||||||||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | # try to deal with return of pk id instead rows_affected | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $rows_affected = "0E$rows_affected"; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | return undef | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 21 | ▶ | if $self->_dbh_error ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 21 | ▶ | return $rows_affected || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$rows_affected || 0
MC/DC0%0/1
$rows_affected || 0
$rows_affected
Truth table50%1/2
A
A= $rows_affected
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 16 | ▶ | sub fetch_single { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_single: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 16 | my $statement = shift; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 16 | my $params = shift; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 16 | ▶ | $params = [defined $params ? $params : ()] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | unless ref $params; | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 16 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 16 | my $single; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 16 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 16 | my $sth = $self->statement ($statement); | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 16 | $self->bind_values ($sth, $params); | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 16 | ▶ | die unless $sth->execute; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 16 | $sth->bind_columns (\$single); | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 16 | $sth->fetch; | |||||||||||||||||||||||||||||||||||||||||
| 128 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 16 | ▶ | return if $self->_dbh_error ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 16 | return $single; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | sub fetch_column { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_column: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $statement = shift; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $params = shift; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $params = [defined $params ? $params : ()] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | unless ref $params; | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $single; | |||||||||||||||||||||||||||||||||||||||||
| 146 | my $column; | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $sth = $dbh->prepare_cached($statement, {}, 3); | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $self->bind_values ($sth, $params); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $rows_affected = $sth->execute; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $sth->bind_columns(\$single); | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | while ($sth->fetch) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | push @$column, $single; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | return if $self->_dbh_error ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | return $column; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub fetch_columns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_columns: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my $statement = shift; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $params = shift; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | $params = [defined $params ? $params : ()] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | unless ref $params; | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $columns = []; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $sth = $dbh->prepare_cached($statement, {}, 3); | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->bind_values ($sth, $params); | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $rows_affected = $sth->execute; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | while (my @arr = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | foreach (0 .. $#arr) { | |||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | push @{$columns->[$_]}, $arr[$_]; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | return if $self->_dbh_error ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return $columns; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 7 | ▶ | sub fetch_row { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_row: called CC=4 SCAR=14.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 7 | my $statement = shift; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | my $params = shift; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 7 | ▶ | $params = [defined $params ? $params : ()] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | unless ref $params; | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 7 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 7 | my $row; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 7 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 206 | 7 | my $sth = $dbh->prepare_cached($statement, {}, 3); | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 7 | $row = $dbh->selectrow_hashref ($sth, {}, @$params); | |||||||||||||||||||||||||||||||||||||||||
| 209 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 7 | ▶ | return if $self->_dbh_error ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 7 | return $row; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub fetch_row_in_place { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_row_in_place: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $row = $self->fetch_row (@_); | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | # Hash::Merge::set_clone_behavior (0); | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | # Hash::Merge::specify_behavior( | ||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 'SCALAR' => { | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | 'SCALAR' => sub { $_[1] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 'ARRAY' => \&strict_behavior_error, | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 'HASH' => \&strict_behavior_error, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 'ARRAY' => { | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 'SCALAR' => \&strict_behavior_error, | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | 'ARRAY' => sub { $_[1] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 'HASH' => \&strict_behavior_error, | ||||||||||||||||||||||||||||||||||||||||||
| 234 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 'HASH' => { | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 'SCALAR' => \&strict_behavior_error, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 'ARRAY' => \&strict_behavior_error, | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | 'HASH' => sub { Hash::Merge::_merge_hashes( $_[0], $_[1] ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 240 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | 'Strict Override', | |||||||||||||||||||||||||||||||||||||||||
| 242 | #); | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | # return unless "$structure" =~ /^(?:([^=]+)=)?([A-Z]+)\(0x([^\)]+)\)$/; | ||||||||||||||||||||||||||||||||||||||||||
| 245 | # | ||||||||||||||||||||||||||||||||||||||||||
| 246 | # my ($type, $address) = ($2, $3); | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | # warn Dumper $self, $row; | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | # Hash::Merge::merge ($self, $row); | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | # warn Dumper $self; | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub strict_behavior_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strict_behavior_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | die "'", ref $_[0], "' to '", ref $_[1], "' not supported"; | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | ▶ | sub fetch_hashref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_hashref: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | my $statement = shift; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | my $params = shift; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | ▶ | $params ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params ||= []
MC/DC0%0/1
$params ||= []
$params
Truth table50%1/2
A
A= $params
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 268 | my $rows_affected; | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | my $sth = $self->statement ($statement); | |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | $self->bind_values ($sth, $params); | |||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | $rows_affected = $sth->execute; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | $result = $sth->fetchall_hashref($key); | |||||||||||||||||||||||||||||||||||||||||
| 276 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | return if $self->_dbh_error ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 23 | ▶ | sub fetch_arrayref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_arrayref: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 23 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 23 | my $statement = shift; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 23 | my $params = shift; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 23 | ▶ | $params ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params ||= []
MC/DC100%1/1
$params ||= []
$params
Truth table100%2/2
A
A= $params
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 23 | my $sql_args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 23 | ▶ | $sql_args ||= {Slice => {}, MaxRows => undef}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$sql_args ||= {"Slice", {}, "MaxRows", undef}
MC/DC0%0/1
$sql_args ||= {"Slice", {}, "MaxRows", undef}
$sql_args
Truth table50%1/2
A
A= $sql_args
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 23 | my $fetch_handler = shift; | |||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 23 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 23 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 296 | my $rows_affected; | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 23 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 299 | 23 | my $sth = $self->statement ($statement); | |||||||||||||||||||||||||||||||||||||||||
| 300 | 23 | $self->bind_values ($sth, $params); | |||||||||||||||||||||||||||||||||||||||||
| 301 | 23 | $rows_affected = $sth->execute; | |||||||||||||||||||||||||||||||||||||||||
| 302 | 23 | $result = $sth->fetchall_arrayref ($sql_args->{Slice}, $sql_args->{MaxRows}); | |||||||||||||||||||||||||||||||||||||||||
| 303 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 23 | ▶ | return if $self->_dbh_error ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 23 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | sub fetch_handled { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_handled: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $statement = shift; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $params = shift; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $params ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params ||= []
MC/DC0%0/1
$params ||= []
$params
Truth table0%0/2
A
A= $params
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $fetch_handler = shift; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 320 | my $rows_affected; | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $failed = 0; | |||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $sth = $self->statement ($statement); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $self->bind_values ($sth, $params); | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $rows_affected = $sth->execute; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | while (my $row = $sth->fetchrow_hashref) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | unless (defined &$fetch_handler ($row)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $failed = 1; | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | return if $self->_dbh_error ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return $rows_affected; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||