Test/DBO.pm

filter: Statementstmt 64.2% 339 / 528 Branchbran 31.8% 84 / 264 Conditioncond 27.9% 19 / 68 MC/DCmcdc 7.6% 3 / 39 Subroutinesub 80.0% 32 / 40 Podpod 0.0% 0 / 17 totaltotal 49.9% 477 / 956 CC 164 SCAR 45.7
CC
164
Cov
51%
join_methods
306.0
_Find_Seen
306.0
Dump
240.0
CRAP 96.6
↑ Summary blib/lib/DBIx/DBO/Row.pm »
1 12 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package # Hide from PAUSE
4 Test::DBO;
5  
6 12 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use sigtrap qw(die normal-signals);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 12 ▶use Scalar::Util qw(blessed reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use DBIx::DBO;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 12 ▶BEGIN {
Subroutine BEGIN: called CC=5 SCAR=20.1
15 # Set up DebugSQL if requested
16 12 ▶ if ($ENV{DBO_TEST_SQL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"DBO_TEST_SQL"}) 0 12 12
17 0 diag "DBO_TEST_SQL=$ENV{DBO_TEST_SQL}";
18 }
19  
20 # Set up $Carp::Verbose if requested
21 12 ▶ if ($ENV{DBO_CARP_VERBOSE}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ENV{'DBO_CARP_VERBOSE'}) { } 0 12 12
elsif ($ENV{'AUTOMATED_TESTING'}) { } 12 0 12
22 0 diag "DBO_CARP_VERBOSE=$ENV{DBO_CARP_VERBOSE}";
23 0 $Carp::Verbose = $ENV{DBO_CARP_VERBOSE};
24 } elsif ($ENV{AUTOMATED_TESTING}) {
25 12 $Carp::Verbose = 1;
26 }
27  
28 # Store the last SQL executed, and show debug info
29 70 ▶ DBIx::DBO->config(HookSQL => sub {
Subroutine __ANON__: called CC=4 SCAR=22.5
30 70 my $me = shift;
31 70 my $loc = Carp::short_error_loc();
32 70 my %i = Carp::caller_info($loc);
33 70 $me->config(LastSQL => [$i{'sub'}, @_]);
34 70 ▶ my $dbg = $ENV{DBO_TEST_SQL} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dbg = $ENV{"DBO_TEST_SQL"} or return 0 70 70
35 0 my $trace;
36 0 ▶ if ($dbg > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbg > 1) { } 0 0 0
37 0 $trace = "\t$i{sub_name} called at $i{file} line $i{line}\n";
38 # Add an extra stack level
39 0 %i = Carp::caller_info($loc - 1);
40 0 $trace = "\t$i{sub_name} called at $i{file} line $i{line}\n$trace";
41 0 ▶ $trace .= "\t$i{sub_name} called at $i{file} line $i{line}\n" while %i = Carp::caller_info(++$loc);
Branch: 1 branch
BranchTrueFalseTotal
%i = Carp::caller_info(++$loc) and do { $trace .= qq[\t$i{"sub_name"} called at $i{"file"} line $i{"line"}\n] } 0 0 0
42 } else {
43 0 $trace = "\t$i{sub} called at $i{file} line $i{line}\n";
44 }
45 0 my $sql = shift;
46 0 Test::More::diag "RUN_SQL: $sql\nRUN_SQL: (".join(', ', map $me->rdbh->quote($_), @_).")\n".$trace;
47 12 });
48  
49 {
50 12 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
51 # Remove CARP_NOT during tests
52 package # Hide from PAUSE
53 DBIx::DBO;
54 *DBIx::DBO::croak =
55 *DBIx::DBO::Query::croak =
56 *DBIx::DBO::Table::croak =
57 43 ▶ *DBIx::DBO::Row::croak = sub {
Subroutine __ANON__: called CC=3 SCAR=11.7
58 43 ▶ local @DBIx::DBO::DBD::CARP_NOT = () if $Carp::Verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $Carp::Verbose 43 0 43
59 43 ▶ local $Carp::CarpLevel = $Carp::CarpLevel + 1 if $Carp::Verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $Carp::Verbose 43 0 43
60 43 &Carp::croak;
61 12 };
62 # Fix SvREFCNT with Devel::Cover
63 package # Hide from PAUSE
64 DBIx::DBO::Query;
65 43 ▶ *DBIx::DBO::Query::SvREFCNT = sub (\[$@%&*]) {
Subroutine __ANON__: called CC=1 SCAR=0.0
66 43 return Devel::Peek::SvREFCNT(${$_[0]}) - 3;
67 12 ▶ } if exists $INC{'Devel/Cover.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $INC{"Devel/Cover.pm"} 12 0 12
68 }
69 }
70  
71 12 our $dbd;
72 12 our $dbd_name;
73 12 our $test_db = "DBO_${DBIx::DBO::VERSION}_test_db" =~ s/\W/_/gr;
74 12 our $test_sch = "DBO_${DBIx::DBO::VERSION}_test_sch" =~ s/\W/_/gr;
75 12 our $test_tbl = "DBO_${DBIx::DBO::VERSION}_test_tbl" =~ s/\W/_/gr;
76 12 our @_cleanup_sql;
77 12 our $case_sensitivity_sql = 'SELECT ? LIKE ?';
78 12 our %can;
79 12 our $test_count = 117;
80  
81 13 ▶sub import {
Subroutine import: called CC=19 SCAR=32.1
82 13 (my $class, $dbd, $dbd_name, my %opt) = @_;
83 13 ▶ defined $dbd or return;
Branch: 1 branch
BranchTrueFalseTotal
defined $Test::DBO::dbd or return 13 0 13
84  
85 13 ▶ grep $_ eq $dbd, DBI->available_drivers
Branch: 1 branch
BranchTrueFalseTotal
grep(($_ eq $Test::DBO::dbd), "DBI"->available_drivers) or plan("skip_all", "No $Test::DBO::dbd driver available!") 9 4 13
86 or plan skip_all => "No $dbd driver available!";
87  
88 # Catch install_driver errors
89 9 eval { DBI->install_driver($dbd) };
90 9 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 9 9
91 0 ▶ die $@ if $@ !~ /\binstall_driver\b/;
Branch: 1 branch
BranchTrueFalseTotal
unless $@ =~ /\binstall_driver\b/u 0 0 0
92 0 plan skip_all => $@;
93 }
94  
95 # Skip tests with missing module requirements
96 9 ▶ unless (eval { DBIx::DBO::DBD->_require_dbd_class($dbd) }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { "DBIx::DBO::DBD"->_require_dbd_class($Test::DBO::dbd) } }) 1 8 9
97 1 ▶ if ($@ =~ /^Can't locate ([\w\/]+)\.pm in \@INC /m) {
Branch: 3 branches
BranchTrueFalseTotal
if ($@ =~ m[^Can't locate ([\w/]+)\.pm in \@INC ]mu) { } 0 1 1
elsif ($@ =~ /^([\w:]+ version [\d\.]+ required.*?) at /mu) { } 0 1 1
elsif ($@ =~ /^(\Q$Test::DBO::dbd_name\E is not yet supported)/mu) { } 1 0 1
98 # Module is not installed
99 0 $_ = "$1 is required" =~ s'/'::'gr;
100 } elsif ($@ =~ /^([\w:]+ version [\d\.]+ required.*?) at /m) {
101 # Module is not correct version
102 0 ($_ = $1);
103 } elsif ($@ =~ /^(\Q$dbd_name\E is not yet supported)/m) {
104 # DBM is not yet supported
105 1 ($_ = $1);
106 } else {
107 0 die $@;
108 }
109 1 plan skip_all => "Can't load $dbd driver: $_";
110 }
111  
112 {
113 12 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
114 8 *{caller().'::sql_err'} = \&sql_err;
115 }
116  
117 8 ▶ if (exists $opt{tempdir}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt{"tempdir"}) 1 7 8
118 1 require File::Temp;
119 1 my $dir = File::Temp::tempdir('tmp_XXXX', CLEANUP => 1);
120 1 ▶ if (ref $opt{tempdir}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opt{'tempdir'}) { } 0 1 1
121 0 ${$opt{tempdir}} = $dir;
122 } else {
123 1 ▶ chdir $dir or die "Can't cd to $dir: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
chdir $dir or die "Can't cd to ${dir}: $!\n" 1 0 1
124 1 ▶ eval "END { chdir '..' }";
Subroutine END: called CC=1 SCAR=0.0
125 }
126 }
127  
128 # Query tests must produce the same result regardless of caching
129 8 ▶ DBIx::DBO->config(CacheQuery => $ENV{DBO_CACHE_QUERY} // int rand 2);
Condition50%1/2
$ENV{"DBO_CACHE_QUERY"} // int rand 2
l!l
08
MC/DC0%0/1
$ENV{"DBO_CACHE_QUERY"} // int rand 2
$ENV{"DBO_CACHE_QUERY"}
Truth table50%1/2
A
A= $ENV{"DBO_CACHE_QUERY"}
Aresult
11
00
130  
131 8 ▶ if (exists $opt{try_connect}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt{"try_connect"}) 0 8 8
132 0 try_to_connect($opt{try_connect});
133 }
134  
135 8 ▶ note "DBD::$dbd ".${ $::DBD::{$dbd.'::'}{VERSION} } if exists $opt{try_connect} or exists $opt{connect_ok};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opt{"try_connect"} or exists $opt{"connect_ok"} 2 6 8
Condition66%2/3
exists $opt{"try_connect"} or exists $opt{"connect_ok"}
l!l&&r!l&&!r
026
MC/DC50%1/2
exists $opt{"try_connect"} or exists $opt{"connect_ok"}
exists $opt{"try_connect"} exists $opt{"connect_ok"}
Truth table66%2/3
A or B
A= exists $opt{"try_connect"}B= exists $opt{"connect_ok"}
ABresult
1X1
011
000
136  
137 8 ▶ return unless exists $opt{tests};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opt{"tests"} 1 7 8
138 7 $opt{tests} =~ s/^\+(\d+)$/$test_count + $1/e;
139  
140 7 ▶ if (exists $opt{connect_ok}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opt{'connect_ok'}) { } 2 5 7
141 2 ▶ my $dbo = connect_ok(@{$opt{connect_ok}}) or plan skip_all => "Can't connect: $DBI::errstr";
Branch: 1 branch
BranchTrueFalseTotal
my $dbo = connect_ok(@{$opt{"connect_ok"};}) or plan("skip_all", "Can't connect: $DBI::errstr") 2 0 2
142  
143 2 plan tests => $opt{tests} + 2;
144 2 pass "Connect to $dbd_name";
145 2 isa_ok $dbo, 'DBIx::DBO', '$dbo';
146 } else {
147 5 plan tests => $opt{tests};
148 }
149 }
150  
151 1 ▶sub sql_err {
Subroutine sql_err: called CC=4 SCAR=14.5
Pod undocumented
152 1 my $me = shift;
153 1 my($cmd, $sql, @bind) = @{$me->config('LastSQL')};
154 1 $sql =~ s/^/ /mg;
155 1 ▶ my @err = ($DBI::errstr || $me->rdbh->errstr || '???');
Condition40%2/5
$DBI::errstr || $me->rdbh->errstr || '???'
l!l
01
$DBI::errstr or $me->rdbh->errstr
l!l&&r!l&&!r
001
MC/DC0%0/2
$DBI::errstr || $me->rdbh->errstr || '???'
$DBI::errstr $me->rdbh->errstr
Truth table33%1/3
A or B
A= $DBI::errstrB= $me->rdbh->errstr
ABresult
1X1
011
000
156 1 ▶ unshift @err, 'Bind Values: ('.join(', ', map $me->rdbh->quote($_), @bind).')' if @bind;
Branch: 1 branch
BranchTrueFalseTotal
if @bind 0 1 1
157 1 unshift @err, "SQL command failed: $cmd", $sql.';';
158 1 $err[-1] =~ s/ at line \d+$//;
159 1 join "\n", @err;
160 }
161  
162 2 ▶sub connect_dbo {
Subroutine connect_dbo: called CC=2 SCAR=8.4
Pod undocumented
163 2 my($dsn, $user, $pass) = @_;
164 2 ▶ $dsn //= '';
Condition50%1/2
$dsn //= ""
l!l
02
MC/DC0%0/1
$dsn //= ""
$dsn
Truth table50%1/2
A
A= $dsn
Aresult
11
00
165 0 ▶ DBIx::DBO->connect("DBI:$dbd:$dsn", $user, $pass, {HandleError => sub { note $_[0]; 1 }});
Subroutine __ANON__: not called CC=1 SCAR=2.6
166 }
167  
168 2 ▶sub try_to_connect {
Subroutine try_to_connect: called CC=3 SCAR=14.2
Pod undocumented
169 2 my $dbo_ref = shift;
170 2 my @env = map $ENV{"DBO_TEST_\U$dbd\E_$_"}, qw(DSN USER PASS);
171 2 ▶ if (grep defined, @env) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep defined($_), @env) 0 2 2
172 0 ▶ return $$dbo_ref if $$dbo_ref = connect_dbo(@env);
Branch: 1 branch
BranchTrueFalseTotal
if $$dbo_ref = connect_dbo(@env) 0 0 0
173 0 plan skip_all => "Can't connect: $DBI::errstr";
174 }
175 2 return undef;
176 }
177  
178 2 ▶sub connect_ok {
Subroutine connect_ok: called CC=2 SCAR=8.1
Pod undocumented
179 2 my $dbo_ref = shift;
180 2 ▶ return try_to_connect($dbo_ref) || ($$dbo_ref = connect_dbo(@_));
Condition33%1/3
try_to_connect($dbo_ref) || ($$dbo_ref = connect_dbo(@_))
l!l&&r!l&&!r
020
MC/DC0%0/2
try_to_connect($dbo_ref) || ($$dbo_ref = connect_dbo(@_))
try_to_connect($dbo_ref) ($$dbo_ref = connect_dbo(@_))
Truth table33%1/3
A || B
A= try_to_connect($dbo_ref)B= ($$dbo_ref = connect_dbo(@_))
ABresult
1X1
011
000
181 }
182  
183 12 my $table_data;
184 my $quoted_table;
185 6 ▶sub is_table_data($$) {
Subroutine is_table_data: called CC=2 SCAR=7.0
Pod undocumented
186 6 my($dbo, $message) = @_;
187 6 ▶ my $rv = $dbo->selectall_arrayref("SELECT * FROM $quoted_table") or diag sql_err($dbo);
Branch: 1 branch
BranchTrueFalseTotal
my $rv = $dbo->selectall_arrayref("SELECT * FROM $quoted_table") or diag(sql_err($dbo)) 6 0 6
188 6 @$rv = sort { $a->[0] <=> $b->[0] } @$rv; # Sort by id
189 6 is_deeply $rv, $table_data, $message;
190 }
191  
192 1 ▶sub basic_methods {
Subroutine basic_methods: called CC=34 SCAR=43.6
Pod undocumented
193 1 my $dbo = shift;
194 1 $quoted_table = $dbo->{dbd_class}->_qi($dbo, $test_sch, $test_tbl);
195  
196 1 note 'Testing with: CacheQuery => '.DBIx::DBO->config('CacheQuery');
197  
198 # Create a DBO from DBI handles
199 1 isa_ok(DBIx::DBO->new($dbo->{dbh}, $dbo->{rdbh}), 'DBIx::DBO', 'Method DBIx::DBO->new, $dbo');
200  
201 1 my @quoted_cols = map $dbo->{dbd_class}->_qi($dbo, $_), qw(type id name);
202 1 my $t;
203 my $create_table = "CREATE TABLE $quoted_table ($quoted_cols[1] ".
204 ($can{auto_increment_id} || 'INT NOT NULL').", $quoted_cols[2] VARCHAR(20)".
205 1 ▶ ($can{auto_increment_id} ? '' : ", PRIMARY KEY ($quoted_cols[1])").')';
Branch: 1 branch
BranchTrueFalseTotal
$Test::DBO::can{'auto_increment_id'} ? : 1 0 1
Condition50%1/2
$Test::DBO::can{'auto_increment_id'} || 'INT NOT NULL'
l!l
10
MC/DC0%0/1
$Test::DBO::can{'auto_increment_id'} || 'INT NOT NULL'
$Test::DBO::can{'auto_increment_id'}
Truth table50%1/2
A
A= $Test::DBO::can{'auto_increment_id'}
Aresult
11
00
206  
207 # Create a test table with a multi-column primary key
208 1 ▶ if ($dbo->do("CREATE TABLE $quoted_table ($quoted_cols[2] VARCHAR(20), $quoted_cols[1] INT, $quoted_cols[0] VARCHAR(8), PRIMARY KEY ($quoted_cols[0], $quoted_cols[1]))")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbo->do("CREATE TABLE $quoted_table ($quoted_cols[2] VARCHAR(20), $quoted_cols[1] INT, $quoted_cols[0] VARCHAR(8), PRIMARY KEY ($quoted_cols[0], $quoted_cols[1]))")) { } 1 0 1
209 1 pass 'Create the test table: '.$quoted_table;
210  
211 # Create a table object
212 1 $t = $dbo->table([undef, $test_tbl]);
213 1 isa_ok $t, 'DBIx::DBO::Table', '$t';
214  
215 # Check the Primary Keys
216 1 ▶ is_deeply $t->{PrimaryKeys}, ['type', 'id'], 'Check PrimaryKeys'
Branch: 1 branch
BranchTrueFalseTotal
is_deeply($t->{"PrimaryKeys"}, ["type", "id"], "Check PrimaryKeys") or diag(Dump($t)) 1 0 1
217 or diag Test::DBO::Dump($t);
218  
219 # Recreate our test table
220 1 ▶ $dbo->do("DROP TABLE $quoted_table") && $dbo->do($create_table)
Branch: 1 branch
BranchTrueFalseTotal
$dbo->do("DROP TABLE $quoted_table") and $dbo->do($create_table) or diag(sql_err($dbo)) or die "Can't recreate the test table!\n" 1 0 1
Condition33%2/6
$dbo->do("DROP TABLE $quoted_table") and $dbo->do($create_table) or diag(sql_err($dbo))
l!l&&r!l&&!r
100
$dbo->do("DROP TABLE $quoted_table") and $dbo->do($create_table)
!ll&&!rl&&r
001
MC/DC0%0/3
$dbo->do("DROP TABLE $quoted_table") and $dbo->do($create_table) or diag(sql_err($dbo))
$dbo->do("DROP TABLE $quoted_table") $dbo->do($create_table) diag(sql_err($dbo))
Truth table20%1/5
A and B or C
A= $dbo->do("DROP TABLE $quoted_table")B= $dbo->do($create_table)C= diag(sql_err($dbo))
ABCresult
11X1
0X11
1011
0X00
1000
221 or diag sql_err($dbo) or die "Can't recreate the test table!\n";
222  
223 # Remove the created table during cleanup
224 1 todo_cleanup("DROP TABLE $quoted_table");
225  
226 1 $dbo->{dbd_class}->_get_table_info($dbo, $t->{Schema}, $t->{Name});
227 1 $t = $t->new($dbo, [$test_sch, $test_tbl]);
228 }
229 else {
230 0 diag sql_err($dbo);
231 SKIP: {
232 0 skip "Can't create a multi-column primary key", 1;
233 }
234  
235 # Create the test table
236 0 ▶ ok $dbo->do($create_table), 'Create the test table'
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $dbo->do($create_table), "Create the test table") or diag(sql_err($dbo)) or die "Can't create the test table!\n" 0 0 0
Condition0%0/3
&ok(scalar $dbo->do($create_table), "Create the test table") or diag(sql_err($dbo))
l!l&&r!l&&!r
000
MC/DC0%0/2
&ok(scalar $dbo->do($create_table), "Create the test table") or diag(sql_err($dbo))
&ok(scalar $dbo->do($create_table), "Create the test table") diag(sql_err($dbo))
Truth table0%0/3
A or B
A= &ok(scalar $dbo->do($create_table), "Create the test table")B= diag(sql_err($dbo))
ABresult
1X1
011
000
237 or diag sql_err($dbo) or die "Can't create the test table!\n";
238  
239 # Remove the created table during cleanup
240 0 todo_cleanup("DROP TABLE $quoted_table");
241  
242 # Create a table object
243 0 $t = $dbo->table([$test_sch, $test_tbl]);
244 0 isa_ok $t, 'DBIx::DBO::Table', '$t';
245 }
246 1 ▶ die "Couldn't create the DBIx::DBO::Table object!" unless $t;
Branch: 1 branch
BranchTrueFalseTotal
unless $t 0 1 1
247  
248 1 is $t->dbo, $dbo, 'Method DBIx::DBO::Table->dbo';
249  
250 1 pass 'Method DBIx::DBO->do';
251  
252 1 ok my $table_info = $dbo->table_info([$test_sch, $test_tbl]), 'Method DBIx::DBO->table_info';
253 1 is $table_info, $dbo->table_info($quoted_table), 'Method DBIx::DBO->table_info (quoted)';
254 1 ▶ is $table_info, $dbo->table_info(defined $test_sch ? "$test_sch.$test_tbl" : $test_tbl),
Branch: 1 branch
BranchTrueFalseTotal
defined $Test::DBO::test_sch ? : 0 1 1
255 'Method DBIx::DBO->table_info (unquoted)';
256  
257 # Insert data
258 1 ▶ $dbo->do("INSERT INTO $quoted_table VALUES (1, 'John Doe')") or diag sql_err($dbo);
Branch: 1 branch
BranchTrueFalseTotal
$dbo->do("INSERT INTO $quoted_table VALUES (1, 'John Doe')") or diag(sql_err($dbo)) 1 0 1
259 1 ▶ $dbo->do("INSERT INTO $quoted_table VALUES (?, ?)", undef, 2, 'Jane Smith') or diag sql_err($dbo);
Branch: 1 branch
BranchTrueFalseTotal
$dbo->do("INSERT INTO $quoted_table VALUES (?, ?)", undef, 2, "Jane Smith") or diag(sql_err($dbo)) 1 0 1
260  
261 # Check the DBO select* methods
262 1 my $rv = [];
263 1 ▶ @$rv = $dbo->selectrow_array("SELECT * FROM $quoted_table") or diag sql_err($dbo);
Branch: 1 branch
BranchTrueFalseTotal
@$rv = $dbo->selectrow_array("SELECT * FROM $quoted_table") or diag(sql_err($dbo)) 1 0 1
264 1 is_deeply $rv, [1,'John Doe'], 'Method DBIx::DBO->selectrow_array';
265  
266 1 ▶ $rv = $dbo->selectrow_arrayref("SELECT * FROM $quoted_table") or diag sql_err($dbo);
Branch: 1 branch
BranchTrueFalseTotal
$rv = $dbo->selectrow_arrayref("SELECT * FROM $quoted_table") or diag(sql_err($dbo)) 1 0 1
267 1 is_deeply $rv, [1,'John Doe'], 'Method DBIx::DBO->selectrow_arrayref';
268  
269 1 $table_data = [[1,'John Doe'],[2,'Jane Smith']];
270 1 is_table_data $dbo, 'Method DBIx::DBO->selectall_arrayref';
271  
272 # Insert via table object
273 1 ▶ $rv = $t->insert(id => 3, name => 'Uncle Arnie') or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$rv = $t->insert("id", 3, "name", "Uncle Arnie") or diag(sql_err($t)) 1 0 1
274 1 ok $rv, 'Method DBIx::DBO::Table->insert';
275 1 push @$table_data, [3,'Uncle Arnie'];
276  
277 1 is_deeply [$t->columns], [qw(id name)], 'Method DBIx::DBO::Table->columns';
278  
279 # Create a column object
280 1 my $c = $t->column('id');
281 1 isa_ok $c, 'DBIx::DBO::Column', '$c';
282  
283 # Advanced insert using a column object
284 1 ▶ $rv = $t->insert($c => {FUNC => '4'}, name => 'NotUsed', name => \"'James Bond'") or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$rv = $t->insert($c, {"FUNC", 4}, "name", "NotUsed", "name", \"'James Bond'") or diag(sql_err($t)) 1 0 1
285 1 ok $rv, 'Method DBIx::DBO::Table->insert (complex values)';
286 1 push @$table_data, [4,'James Bond'];
287  
288 1 is_table_data $dbo, 'Method DBIx::DBO::Table->insert (remove duplicate cols)';
289  
290 # Delete via table object
291 1 ▶ $rv = $t->delete(id => 3) or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$rv = $t->delete("id", 3) or diag(sql_err($t)) 1 0 1
292 1 is $rv, 1, 'Method DBIx::DBO::Table->delete';
293  
294 1 ▶ if ($can{auto_increment_id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Test::DBO::can{'auto_increment_id'}) { } 1 0 1
295 1 ▶ $t->insert(name => 'Vernon Lyon') or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->insert("name", "Vernon Lyon") or diag(sql_err($t)) 1 0 1
296 } else {
297 0 ▶ $t->insert(id => 5, name => 'Vernon Lyon') or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->insert("id", 5, "name", "Vernon Lyon") or diag(sql_err($t)) 0 0 0
298 }
299  
300 SKIP: {
301 1 ▶ skip "No auto-increment $quoted_cols[1] column", 1 unless $can{auto_increment_id};
Branch: 1 branch
BranchTrueFalseTotal
unless $Test::DBO::can{"auto_increment_id"} 0 1 1
302 1 ▶ is $t->last_insert_id, 5, 'Method DBIx::DBO::Table->last_insert_id'
Branch: 1 branch
BranchTrueFalseTotal
&is(scalar $t->last_insert_id, 5, "Method DBIx::DBO::Table->last_insert_id") or $t->delete("name", "Vernon Lyon"), $t->insert("id", 5, "name", "Vernon Lyon") 1 0 1
303 or $t->delete(name => 'Vernon Lyon'), $t->insert(id => 5, name => 'Vernon Lyon');
304 }
305  
306 1 my $bulk_data = $dbo->query($t)->arrayref({ Slice => {} });
307 SKIP: {
308 1 ▶ unless ($can{truncate}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Test::DBO::can{"truncate"}) 1 0 1
309 1 ▶ $t->delete or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->delete or diag(sql_err($t)) 1 0 1
310 1 skip 'TRUNCATE TABLE is not supported', 1;
311 }
312 0 ▶ $t->truncate or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->truncate or diag(sql_err($t)) 0 0 0
313 0 undef @$table_data;
314 0 is_table_data $dbo, 'Method DBIx::DBO::Table->truncate';
315 }
316 1 @$table_data = sort { $a->[0] <=> $b->[0] } map [@$_{qw(id name)}], @$bulk_data;
317  
318 # Bulk insert
319 1 ▶ $rv = $t->bulk_insert(rows => [map [@$_{qw(id name)}], @$bulk_data]) or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$rv = $t->bulk_insert("rows", [map([@$_{"id", "name"}], @$bulk_data)]) or diag(sql_err($t)) 1 0 1
320 1 is $rv, 4, 'Method DBIx::DBO::Table->bulk_insert (ARRAY)';
321 1 is_table_data $dbo, 'Table contents are correct';
322 1 ▶ $t->delete or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->delete or diag(sql_err($t)) 1 0 1
323  
324 1 ▶ $rv = $t->bulk_insert(rows => \@$bulk_data) or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$rv = $t->bulk_insert("rows", \@$bulk_data) or diag(sql_err($t)) 1 0 1
325 1 is $rv, 4, 'Method DBIx::DBO::Table->bulk_insert (HASH)';
326 1 is_table_data $dbo, 'Table contents are correct';
327 1 ▶ $t->delete or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->delete or diag(sql_err($t)) 1 0 1
328  
329 1 ▶ $rv = $t->bulk_insert(columns => [qw(name id)], rows => [map [@$_{qw(name id)}], @$bulk_data]) or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$rv = $t->bulk_insert("columns", ["name", "id"], "rows", [map([@$_{"name", "id"}], @$bulk_data)]) or diag(sql_err($t)) 1 0 1
330 1 is $rv, 4, 'Method DBIx::DBO::Table->bulk_insert (ARRAY)';
331 1 is_table_data $dbo, 'Table contents are correct';
332 1 ▶ $t->delete or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->delete or diag(sql_err($t)) 1 0 1
333  
334 1 ▶ $rv = $t->bulk_insert(columns => [qw(name id)], rows => \@$bulk_data) or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$rv = $t->bulk_insert("columns", ["name", "id"], "rows", \@$bulk_data) or diag(sql_err($t)) 1 0 1
335 1 is $rv, 4, 'Method DBIx::DBO::Table->bulk_insert (HASH)';
336 1 is_table_data $dbo, 'Table contents are correct';
337  
338 1 return $t;
339 }
340  
341 1 ▶sub advanced_table_methods {
Subroutine advanced_table_methods: called CC=6 SCAR=18.8
Pod undocumented
342 1 my $dbo = shift;
343 1 my $t = shift;
344  
345 SKIP: {
346 1 ▶ skip "No test table for advanced table tests", 2 unless $t;
Branch: 1 branch
BranchTrueFalseTotal
unless $t 0 1 1
347  
348 # Advanced insert
349 1 ▶ my $rv = $t->insert(id => { FUNC => '? + 3', VAL => 3 }, name => \"'Harry Harrelson'") or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
my $rv = $t->insert("id", {"FUNC", "? + 3", "VAL", 3}, "name", \"'Harry Harrelson'") or diag(sql_err($t)) 1 0 1
350 1 ok $rv, 'Method DBIx::DBO::Table->insert (advanced)';
351  
352 1 ▶ $t->insert(id => 7, name => 'Amanda Huggenkiss') or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->insert("id", 7, "name", "Amanda Huggenkiss") or diag(sql_err($t)) 1 0 1
353 1 ▶ $t->insert(id => 8, name => undef) or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->insert("id", 8, "name", undef) or diag(sql_err($t)) 1 0 1
354  
355 # Advanced delete
356 1 ▶ $rv = $t->delete(id => \'NOT NULL', name => undef) or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$rv = $t->delete("id", \"NOT NULL", "name", undef) or diag(sql_err($t)) 1 0 1
357 1 ok $rv, 'Method DBIx::DBO::Table->delete (advanced)';
358 }
359 }
360  
361 0 ▶sub skip_advanced_table_methods {
Subroutine skip_advanced_table_methods: not called CC=3 SCAR=24.8
Pod undocumented
362 0 my $dbo = shift;
363 0 my $t = shift;
364  
365 0 skip "No advanced table tests for $dbd_name", 2;
366 0 ▶ $t->insert(id => 6, name => 'Harry Harrelson') or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->insert("id", 6, "name", "Harry Harrelson") or diag(sql_err($t)) 0 0 0
367 0 ▶ $t->insert(id => 7, name => 'Amanda Huggenkiss') or diag sql_err($t);
Branch: 1 branch
BranchTrueFalseTotal
$t->insert("id", 7, "name", "Amanda Huggenkiss") or diag(sql_err($t)) 0 0 0
368 }
369  
370 1 ▶sub row_methods {
Subroutine row_methods: called CC=12 SCAR=26.1
Pod undocumented
371 1 my $dbo = shift;
372 1 my $t = shift;
373  
374 1 my $r = DBIx::DBO::Row->new($dbo, $t->_as_table);
375 1 isa_ok $r, 'DBIx::DBO::Row', '$r (using quoted table name)';
376  
377 1 $r = $dbo->row([ @$t{qw(Schema Name)} ]);
378 1 isa_ok $r, 'DBIx::DBO::Row', '$r (using table name array)';
379  
380 1 $r = $dbo->row($t);
381 1 isa_ok $r, 'DBIx::DBO::Row', '$r (using Table object)';
382  
383 1 is $r->dbo, $dbo, 'Method DBIx::DBO::Row->dbo';
384  
385 1 ok $r->is_empty, 'Method DBIx::DBO::Row->is_empty';
386 1 is_deeply [$r->columns], [qw(id name)], 'Method DBIx::DBO::Row->columns';
387  
388 1 ▶ ok $r->load(id => [2, 3], name => 'Jane Smith'), 'Method DBIx::DBO::Row->load' or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $r->load("id", [2, 3], "name", "Jane Smith"), "Method DBIx::DBO::Row->load") or diag(sql_err($r)) 1 0 1
389 1 is_deeply $$r->{array}, [ 2, 'Jane Smith' ], 'Row loaded correctly';
390  
391 # Access methods
392 1 is $r->[1], 'Jane Smith', 'Access row as an arrayref';
393 1 is $r->{name}, 'Jane Smith', 'Access row as a hashref';
394 1 is $r->value('name'), 'Jane Smith', 'Method DBIx::DBO::Row->value';
395 1 is $r->value($t->column('name')), 'Jane Smith', 'Method DBIx::DBO::Row->value (using Table->column)';
396  
397 1 ▶ is $r->update(name => 'Someone Else'), 1, 'Method DBIx::DBO::Row->update' or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
&is(scalar $r->update("name", "Someone Else"), 1, "Method DBIx::DBO::Row->update") or diag(sql_err($r)) 1 0 1
398 1 ▶ is_deeply \@$r, [ 2, 'Someone Else' ], 'Row updated correctly (internal)' or diag Test::DBO::Dump($r);
Branch: 1 branch
BranchTrueFalseTotal
is_deeply(\@$r, [2, "Someone Else"], "Row updated correctly (internal)") or diag(Dump($r)) 1 0 1
399 1 ▶ $r->load(id => 2) or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
$r->load("id", 2) or diag(sql_err($r)) 1 0 1
400 1 ▶ is_deeply \@$r, [ 2, 'Someone Else' ], 'Row updated correctly (external)' or diag Test::DBO::Dump($r);
Branch: 1 branch
BranchTrueFalseTotal
is_deeply(\@$r, [2, "Someone Else"], "Row updated correctly (external)") or diag(Dump($r)) 1 0 1
401  
402 1 ▶ $r->update(name => 'Nobody', $t ** 'name' => 'Anybody') or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
$r->update("name", "Nobody", $t ** "name", "Anybody") or diag(sql_err($r)) 1 0 1
403 1 ▶ is_deeply \@{$r->load(id => 2)}, [ 2, 'Anybody' ], 'Row update removes duplicates' or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
is_deeply(\@{$r->load("id", 2);}, [2, "Anybody"], "Row update removes duplicates") or diag(sql_err($r)) 1 0 1
404  
405 # UPDATE the primary key and a complex expression, requiring a reload
406 1 $r->config(OnRowUpdate => 'reload');
407 1 ▶ $r->update(id => 3, name => \"'Uncle Arnie'") or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
$r->update("id", 3, "name", \"'Uncle Arnie'") or diag(sql_err($r)) 1 0 1
408 1 ▶ ok !$r->is_empty, 'Row reloaded on update' or $r->load(id => [2, 3]) or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
&ok(!$r->is_empty, "Row reloaded on update") or $r->load("id", [2, 3]) or diag(sql_err($r)) 1 0 1
Condition33%1/3
&ok(!$r->is_empty, "Row reloaded on update") or $r->load("id", [2, 3])
l!l&&r!l&&!r
100
MC/DC0%0/2
&ok(!$r->is_empty, "Row reloaded on update") or $r->load("id", [2, 3])
&ok(!$r->is_empty, "Row reloaded on update") $r->load("id", [2, 3])
Truth table33%1/3
A or B
A= &ok(!$r->is_empty, "Row reloaded on update")B= $r->load("id", [2, 3])
ABresult
1X1
011
000
409  
410 1 ▶ ok $r->delete, 'Method DBIx::DBO::Row->delete' or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $r->delete, "Method DBIx::DBO::Row->delete") or diag(sql_err($r)) 1 0 1
411 1 $t->insert(id => 2, name => 'Jane Smith');
412  
413 1 is $r->load(name => 'non-existent'), undef, 'Load non-existent row';
414 1 is_deeply $$r->{array}, undef, 'Row is empty again';
415 }
416  
417 1 ▶sub query_methods {
Subroutine query_methods: called CC=12 SCAR=26.1
Pod undocumented
418 1 my $dbo = shift;
419 1 my $t = shift;
420 1 $quoted_table = $t->_as_table;
421  
422 # Create a query object
423 1 my $q = $dbo->query($t);
424 1 isa_ok $q, 'DBIx::DBO::Query', '$q';
425  
426 1 is $q->dbo, $dbo, 'Method DBIx::DBO::Query->dbo';
427  
428 # Default sql = select everything
429 1 is_deeply [$q->columns], [qw(id name)], 'Method DBIx::DBO::Query->columns';
430 1 my $sql = $q->sql;
431 1 is $sql, "SELECT * FROM $quoted_table", 'Method DBIx::DBO::Query->sql';
432  
433 # Sort the result
434 1 $q->order_by('id');
435 1 like $q->sql, qr/ ORDER BY .*id/, 'Method DBIx::DBO::Query->order_by';
436  
437 # Get a valid sth
438 1 ▶ ok $q->run, 'Method DBIx::DBO::Query->run' or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $q->run, "Method DBIx::DBO::Query->run") or diag(sql_err($q)) 1 0 1
439 1 isa_ok $q->{sth}, 'DBI::st', '$q->{sth}';
440  
441 # Get a Row object
442 1 my $r = $q->row;
443 1 isa_ok $r, 'DBIx::DBO::Row', '$q->row';
444 1 undef $q;
445 1 ok !exists $$r->{Parent}, 'Row detaches when the parent query is destroyed';
446  
447 # Get another attached Row
448 1 $q = $dbo->query($t);
449 1 $r = $q->row;
450  
451 1 $q->config(Testing => 123);
452 1 is $r->config('Testing'), 123, 'Row gets config from parent Query';
453  
454 # Alter the SQL to ensure the row is detached and rebuilt
455 1 my $r_str = "$r";
456 1 $q->order_by('id');
457 1 $r = $q->row;
458 1 isnt $r_str, "$r", 'Row rebuilds SQL and detaches when a ref still exists';
459 1 $r_str = "$r";
460  
461 # Remove the reference so that the row wont detach
462 1 undef $r;
463  
464 # Fetch the first row
465 1 $r = $q->fetch;
466 1 ok $r->isa('DBIx::DBO::Row'), 'Method DBIx::DBO::Query->fetch';
467 1 is "$r", $r_str, 'Re-use the same row object';
468 1 is_deeply [$q->columns], [qw(id name)], 'Method DBIx::DBO::Query->columns (after fetch)';
469  
470 # Fetch another row
471 1 $r_str = "$r";
472 1 $r = $q->fetch;
473 1 isnt $r_str, "$r", 'Row detaches during fetch when a ref still exists';
474  
475 # Re-run the query
476 1 ▶ $q->run or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
$q->run or diag(sql_err($q)) 1 0 1
477 1 is $q->fetch->{name}, 'John Doe', 'Method DBIx::DBO::Query->run (rerun)';
478 1 $q->finish;
479 1 ok $q->{Row}->is_empty, 'Method DBIx::DBO::Query->finish (Row is now empty)';
480 1 is $q->fetch->{name}, 'John Doe', 'Method DBIx::DBO::Query->finish (fetch returns the first Row)';
481  
482 # Count the number of rows
483 1 is_deeply [map ref $q->fetch, 1..5], [('DBIx::DBO::Row') x 5], 'Fetched 5 more Rows';
484 1 is $q->fetch, undef, 'Fetch exhausted (no more rows)';
485 1 is $q->rows, 6, 'Row count is 6';
486  
487 # WHERE clause
488 1 ▶ ok $q->where('name', 'LIKE', \"'%o%'"), 'Method DBIx::DBO::Query->where' or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $q->where("name", "LIKE", \"'%o%'"), "Method DBIx::DBO::Query->where") or diag(sql_err($q)) 1 0 1
489  
490 # Parentheses
491 1 $q->open_bracket('OR');
492 1 $q->where('name', 'LIKE', \"'%a%'");
493 1 $q->where('id', '!=', \1);
494 1 $q->where('id', '=', undef);
495 1 $q->open_bracket('AND');
496 1 $q->where('id', '<>', 12345);
497 1 $q->where('id', '!=', undef);
498 1 $q->where('id', 'NOT IN', [1,22,333]);
499 1 $q->where('id', 'NOT BETWEEN', [123,456]);
500 1 my $got = $q->col_arrayref({ Columns => [1] });
501 1 ▶ is_deeply $got, [4,5,6], 'Method DBIx::DBO::Query->open_bracket' or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
is_deeply($got, [4, 5, 6], "Method DBIx::DBO::Query->open_bracket") or diag(sql_err($q)) 1 0 1
502  
503 1 $q->where('id', 'NOT IN', 4444);
504 1 ok scalar(() = $q->sql =~ / NOT IN /g) == 1, 'Group multiple IN & NOT IN clauses together';
505  
506 1 $q->order_by;
507 1 ▶ is $q->update(id => { FUNC => '? + 10', COL => 'id' }), 3, 'Method DBIx::DBO::Query->update' or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
&is(scalar $q->update("id", {"FUNC", "? + 10", "COL", "id"}), 3, "Method DBIx::DBO::Query->update") or diag(sql_err($q)) 1 0 1
508 1 $q->order_by('id');
509  
510 1 my $old_sql = $q->sql;
511 1 $q->unwhere('name');
512 1 is $q->sql, $old_sql, 'Method DBIx::DBO::Query->unwhere (before close_bracket)';
513  
514 1 $q->close_bracket;
515 1 $q->close_bracket;
516 1 $q->unwhere('name');
517 1 isnt $q->sql, $old_sql, 'Method DBIx::DBO::Query->close_bracket';
518  
519 1 $got = $q->col_arrayref({ Columns => [1] });
520 1 is_deeply $got, [2,7,14,15,16], 'Method DBIx::DBO::Query->unwhere';
521  
522 # Reset the Query
523 1 $q->reset;
524 1 is $q->sql, $dbo->query($t)->sql, 'Method DBIx::DBO::Query->reset';
525  
526 # Group by the first initial
527 1 $q->show(\'COUNT(*)');
528 1 ▶ ok(($q->group_by({FUNC => 'SUBSTR(?, 1, 1)', COL => 'name'}), $q->run),
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar($q->group_by({"FUNC", "SUBSTR(?, 1, 1)", "COL", "name"}), $q->run), "Method DBIx::DBO::Query->group_by") or diag(sql_err($q)) 1 0 1
529 'Method DBIx::DBO::Query->group_by') or diag sql_err($q);
530  
531 # Update & Load a Row with aliased columns
532 1 $q->show($t, {COL => 'id', AS => 'key'});
533 1 $q->order_by({COL => 'id', ORDER => 'DESC' });
534 1 $q->group_by;
535 1 is_deeply [$q->columns], [qw(id name key)], 'Method DBIx::DBO::Query->columns (with aliases)';
536 1 $r = $q->fetch;
537 1 is_deeply [$q->columns], [qw(id name key)], 'Method DBIx::DBO::Query->columns (after fetch)';
538 1 isa_ok $q ** 'key', 'DBIx::DBO::Column', '$q ** $alias';
539  
540 # After changing the Query, test that the Row still works as before
541 1 $q->show('id');
542 1 $q->order_by('id');
543 1 is join(' ', $r->columns), 'id name key', 'Method DBIx::DBO::Row->columns (unchanged by parent)';
544 1 ▶ is $r->{key}, 16, 'Alias returns correct value' or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
&is($r->{"key"}, 16, "Alias returns correct value") or diag(sql_err($r)) 0 1 1
545 1 ▶ ok $r->update(id => $r->{key}), 'Can update a Row despite using aliases' or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $r->update("id", $r->{"key"}), "Can update a Row despite using aliases") or diag(sql_err($r)) 0 0 0
546 0 ▶ ok $r->load(id => 15), 'Can load a Row despite using aliases' or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $r->load("id", 15), "Can load a Row despite using aliases") or diag(sql_err($r)) 0 0 0
547  
548 # Limit & limit with Offset
549 0 $q->limit(3);
550 0 $got = [];
551 0 ▶ for (my $row; $row = $q->fetch; push @$got, $row->[0]) {}
Branch: 1 branch
BranchTrueFalseTotal
if ($row = $q->fetch) 0 0 0
552 0 is_deeply $got, [1,2,7], 'Method DBIx::DBO::Query->limit';
553  
554 0 $q->limit(3, 2);
555 0 $got = [];
556 0 ▶ for (my $row; $row = $q->fetch; push @$got, $row->[0]) {}
Branch: 1 branch
BranchTrueFalseTotal
if ($row = $q->fetch) 0 0 0
557 0 is_deeply $got, [7,14,15], 'Method DBIx::DBO::Query->limit (with offset)';
558  
559 0 $q->finish;
560 0 return $q;
561 }
562  
563 0 ▶sub advanced_query_methods {
Subroutine advanced_query_methods: not called CC=12 SCAR=50.5
Pod undocumented
564 0 my $dbo = shift;
565 0 my $t = shift;
566 0 my $q = shift;
567 0 $q->reset;
568  
569 # Show specific columns only
570 SKIP: {
571 0 ▶ skip 'COLLATE is not supported', 1 unless $can{collate};
Branch: 1 branch
BranchTrueFalseTotal
unless $Test::DBO::can{"collate"} 0 0 0
572 0 $q->order_by({ COL => 'name', COLLATE => $can{collate} });
573 0 ▶ ok $q->run, 'Method DBIx::DBO::Query->order_by COLLATE' or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $q->run, "Method DBIx::DBO::Query->order_by COLLATE") or diag(sql_err($q)) 0 0 0
574 }
575 0 $q->order_by('id');
576 0 $q->show({ FUNC => 'UPPER(?)', COL => 'name', AS => 'name' }, 'id', 'name');
577 0 ▶ ok $q->run && $q->fetch->{name} eq 'JOHN DOE', 'Method DBIx::DBO::Query->show' or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar($q->run && $q->fetch->{"name"} eq "JOHN DOE"), "Method DBIx::DBO::Query->show") or diag(sql_err($q)) 0 0 0
Condition0%0/3
$q->run && $q->fetch->{'name'} eq 'JOHN DOE'
!ll&&!rl&&r
000
MC/DC0%0/2
$q->run && $q->fetch->{'name'} eq 'JOHN DOE'
$q->run $q->fetch->{'name'} eq 'JOHN DOE'
Truth table0%0/3
A && B
A= $q->runB= $q->fetch->{'name'} eq 'JOHN DOE'
ABresult
0X0
100
111
578  
579 0 is $q->row->value($t ** 'name'), 'John Doe', 'Access specific column';
580 0 is_deeply [$q->row->columns], [qw(name id name)], 'Method DBIx::DBO::Row->columns (aliased)';
581 0 is_deeply [$q->columns], [qw(name id name)], 'Method DBIx::DBO::Query->columns (aliased)';
582  
583 # Show whole tables
584 0 $q->show({ FUNC => "'who?'", AS => 'name' }, $t);
585 0 is $q->fetch->value($t ** 'name'), 'John Doe', 'Access specific column from a shown table';
586  
587 # Check case sensitivity of LIKE
588 0 ▶ my $case_sensitive = $dbo->selectrow_arrayref($case_sensitivity_sql, undef, 'a', 'A') or diag sql_err($dbo);
Branch: 1 branch
BranchTrueFalseTotal
my $case_sensitive = $dbo->selectrow_arrayref($Test::DBO::case_sensitivity_sql, undef, "a", "A") or diag(sql_err($dbo)) 0 0 0
589 0 $case_sensitive = not $case_sensitive->[0];
590 0 ▶ note "$dbd_name 'LIKE' is".($case_sensitive ? '' : ' NOT').' case sensitive';
Branch: 1 branch
BranchTrueFalseTotal
$case_sensitive ? : 0 0 0
591  
592 # WHERE clause
593 0 $q->show('id');
594 0 ok $q->where('name', 'LIKE', '%a%'), 'Method DBIx::DBO::Query->where LIKE';
595 0 ▶ my $a = $q->col_arrayref or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
my $a = $q->col_arrayref or diag(sql_err($q)) 0 0 0
596 0 is_deeply $a, [2,7,14,16], 'Method DBIx::DBO::Query->col_arrayref';
597 0 ok $q->where('id', 'BETWEEN', [6, \16]), 'Method DBIx::DBO::Query->where BETWEEN';
598 0 ▶ $a = $q->arrayref or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
$a = $q->arrayref or diag(sql_err($q)) 0 0 0
599 0 is_deeply $a, [[7],[14],[16]], 'Method DBIx::DBO::Query->arrayref';
600 0 ok $q->where('name', 'IN', ['Harry Harrelson', 'James Bond']), 'Method DBIx::DBO::Query->where IN';
601 0 ▶ $a = $q->hashref('id') or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
$a = $q->hashref("id") or diag(sql_err($q)) 0 0 0
602 0 is_deeply $a, {14 => {id => 14},16 => {id => 16}}, 'Method DBIx::DBO::Query->hashref';
603  
604 # HAVING clause
605 0 ▶ my $concat = $dbd eq 'SQLite' ? '? || ?' : 'CONCAT(?, ?)';
Branch: 1 branch
BranchTrueFalseTotal
$Test::DBO::dbd eq 'SQLite' ? : 0 0 0
606 0 my %concat_col = (FUNC => $concat, COL => [qw(id name)]);
607 0 ▶ my $having_col = $dbo->{dbd_class}->_alias_preference($q, 'having') ? 'combo' : \%concat_col;
Branch: 1 branch
BranchTrueFalseTotal
$dbo->{'dbd_class'}->_alias_preference($q, 'having') ? : 0 0 0
608 0 $q->show('id', 'name', { %concat_col, AS => 'combo'});
609 0 $q->group_by('id', 'name');
610 0 $q->having($having_col, '=', '14James Bond');
611 0 $q->having($having_col, '=', 'ABC-XYZ');
612 0 $q->having($having_col, '=', 'XYZ-ABC');
613 0 is_deeply [@{$q->fetch}], [14, 'James Bond', '14James Bond'], 'Method DBIx::DBO::Query->having';
614  
615 0 $q->unhaving($having_col, '=', '14James Bond');
616 0 is $q->fetch, undef, 'Method DBIx::DBO::Query->unhaving';
617 0 $q->unhaving($having_col);
618 0 is_deeply [@{$q->fetch}], [14, 'James Bond', '14James Bond'], 'Method DBIx::DBO::Query->unhaving (whole column)';
619  
620 0 $q->finish;
621 }
622  
623 0 ▶sub skip_advanced_query_methods {
Subroutine skip_advanced_query_methods: not called CC=1 SCAR=6.9
Pod undocumented
624 0 skip "No advanced query tests for $dbd_name", 15;
625 }
626  
627 0 ▶sub join_methods {
Subroutine join_methods: not called CC=17 SCAR=57.2
Pod undocumented
628 0 my $dbo = shift;
629 0 my $table = shift;
630  
631 0 my($q, $t1, $t2) = $dbo->query($table, $table);
632  
633 # DISTINCT clause
634 0 $q->order_by('id');
635 0 $q->show('id');
636 0 $q->distinct(1);
637 0 is_deeply $q->arrayref, [[1],[2],[7],[14],[15],[16]], 'Method DBIx::DBO::Query->distinct';
638 0 $q->distinct(0);
639 0 $q->show($t1, $t2);
640  
641 # Counting rows
642 0 $q->limit(3);
643 0 $q->config(CalcFoundRows => 1);
644 0 ok $q, 'Comma JOIN';
645 0 ▶ is $q->count_rows, 3, 'Method DBIx::DBO::Query->count_rows' or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
&is(scalar $q->count_rows, 3, "Method DBIx::DBO::Query->count_rows") or diag(sql_err($q)) 0 0 0
646 0 ▶ is $q->found_rows, 36, 'Method DBIx::DBO::Query->found_rows' or diag sql_err($q);
Branch: 1 branch
BranchTrueFalseTotal
&is(scalar $q->found_rows, 36, "Method DBIx::DBO::Query->found_rows") or diag(sql_err($q)) 0 0 0
647  
648 # JOIN
649 0 $q->join_on($t2, $t1 ** 'id', '=', { FUNC => '?/7.0', VAL => $t2 ** 'id' });
650 0 $q->order_by({ COL => $t1 ** 'name', ORDER => 'DESC' });
651 0 $q->where($t1 ** 'name', '<', $t2 ** 'name', FORCE => 'OR');
652 0 $q->where($t1 ** 'name', '>', $t2 ** 'name', FORCE => 'OR');
653 0 $q->where($t1 ** 'name', 'LIKE', '%');
654 0 my $r;
655 # Oracle Can't do a SELECT * from a subquery that has "ambiguous" columns (two columns with the same name)
656 0 ▶ $q->show() if $dbd eq 'Oracle';
Branch: 1 branch
BranchTrueFalseTotal
if $Test::DBO::dbd eq "Oracle" 0 0 0
657 SKIP: {
658 0 ▶ $q->run or fail 'JOIN ON' or diag sql_err($q) or skip 'No Left Join', 1;
Branch: 1 branch
BranchTrueFalseTotal
$q->run or &fail("JOIN ON") or diag(sql_err($q)) or skip("No Left Join", 1) 0 0 0
Condition0%0/6
$q->run or &fail("JOIN ON") or diag(sql_err($q))
l!l&&r!l&&!r
000
$q->run or &fail("JOIN ON")
l!l&&r!l&&!r
000
MC/DC0%0/3
$q->run or &fail("JOIN ON") or diag(sql_err($q))
$q->run &fail("JOIN ON") diag(sql_err($q))
Truth table0%0/4
A or B or C
A= $q->runB= &fail("JOIN ON")C= diag(sql_err($q))
ABCresult
1XX1
01X1
0011
0000
659 0 ▶ $r = $q->fetch or fail 'JOIN ON' or skip 'No Left Join', 1;
Branch: 1 branch
BranchTrueFalseTotal
$r = $q->fetch or &fail("JOIN ON") or skip("No Left Join", 1) 0 0 0
Condition0%0/3
$r = $q->fetch or &fail("JOIN ON")
l!l&&r!l&&!r
000
MC/DC0%0/2
$r = $q->fetch or &fail("JOIN ON")
$r = $q->fetch &fail("JOIN ON")
Truth table0%0/3
A or B
A= $r = $q->fetchB= &fail("JOIN ON")
ABresult
1X1
011
000
660  
661 0 is_deeply \@$r, [ 1, 'John Doe', 7, 'Amanda Huggenkiss' ], 'JOIN ON';
662 0 ▶ $r->load($t1 ** id => 2) or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
$r->load($t1 ** "id", 2) or diag(sql_err($r)) 0 0 0
663 0 is_deeply \@$r, [ 2, 'Jane Smith', 14, 'James Bond' ], 'Method DBIx::DBO::Row->load';
664 }
665  
666 # LEFT JOIN
667 0 ($q, $t1) = $dbo->query($table);
668 # ... "t1" LEFT JOIN ... "t2"
669 0 $t2 = $q->join_table($table, 'left');
670 # ... "t1" LEFT JOIN ... "t2" ON "t1"."id" = "t2"."id"/2.0
671 0 $q->join_on($t2, $t1 ** 'id', '=', { FUNC => '?/2.0', COL => $t2 ** 'id' });
672 0 ok $q->open_join_on_bracket($t2, 'OR'), 'Method DBIx::DBO::Query->open_join_on_bracket';
673 # ... "t1" LEFT JOIN ... "t2" ON "t1"."id" = "t2"."id"/2.0 AND 1 = 2
674 0 $q->join_on($t2, \1, '=', \2);
675 # ... "t1" LEFT JOIN ... "t2" ON "t1"."id" = "t2"."id"/2.0 AND (1 = 2 OR 3 = 3)
676 0 $q->join_on($t2, \3, '=', \3);
677 0 ok $q->close_join_on_bracket($t2), 'Method DBIx::DBO::Query->close_join_on_bracket';
678  
679 0 $q->order_by({ COL => $t1 ** 'name', ORDER => 'DESC' });
680 0 $q->limit(1, 3);
681  
682 SKIP: {
683 0 ▶ $q->run or diag sql_err($q) or fail 'LEFT JOIN' or skip 'No Left Join', 3;
Branch: 1 branch
BranchTrueFalseTotal
$q->run or diag(sql_err($q)) or &fail("LEFT JOIN") or skip("No Left Join", 3) 0 0 0
Condition0%0/6
$q->run or diag(sql_err($q)) or &fail("LEFT JOIN")
l!l&&r!l&&!r
000
$q->run or diag(sql_err($q))
l!l&&r!l&&!r
000
MC/DC0%0/3
$q->run or diag(sql_err($q)) or &fail("LEFT JOIN")
$q->run diag(sql_err($q)) &fail("LEFT JOIN")
Truth table0%0/4
A or B or C
A= $q->runB= diag(sql_err($q))C= &fail("LEFT JOIN")
ABCresult
1XX1
01X1
0011
0000
684 0 ▶ $r = $q->fetch or fail 'LEFT JOIN' or skip 'No Left Join', 3;
Branch: 1 branch
BranchTrueFalseTotal
$r = $q->fetch or &fail("LEFT JOIN") or skip("No Left Join", 3) 0 0 0
Condition0%0/3
$r = $q->fetch or &fail("LEFT JOIN")
l!l&&r!l&&!r
000
MC/DC0%0/2
$r = $q->fetch or &fail("LEFT JOIN")
$r = $q->fetch &fail("LEFT JOIN")
Truth table0%0/3
A or B
A= $r = $q->fetchB= &fail("LEFT JOIN")
ABresult
1X1
011
000
685  
686 0 is_deeply [@$r[0..3]], [14, 'James Bond', undef, undef], 'LEFT JOIN';
687 0 is $r->_column_idx($t2 ** 'id'), 2, 'Method DBIx::DBO::Row->_column_idx';
688 0 is $r->value($t2 ** 'id'), undef, 'Method DBIx::DBO::Row->value';
689  
690 # Update the LEFT JOINed row
691 SKIP: {
692 0 ▶ skip "Multi-table UPDATE is not supported by $dbd_name", 1 unless $can{multi_table_update};
Branch: 1 branch
BranchTrueFalseTotal
unless $Test::DBO::can{"multi_table_update"} 0 0 0
693 0 ▶ ok $r->update($t1 ** 'name' => 'Vernon Wayne Lyon'), 'Method DBIx::DBO::Row->update' or diag sql_err($r);
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $r->update($t1 ** "name", "Vernon Wayne Lyon"), "Method DBIx::DBO::Row->update") or diag(sql_err($r)) 0 0 0
694 }
695 }
696  
697 0 $q->finish;
698 }
699  
700 0 ▶sub skip_join_methods {
Subroutine skip_join_methods: not called CC=1 SCAR=6.9
Pod undocumented
701 0 skip "No query join tests for $dbd_name", 12;
702 }
703  
704 1 ▶sub todo_cleanup {
Subroutine todo_cleanup: called CC=1 SCAR=0.0
Pod undocumented
705 1 my $sql = shift;
706 1 unshift @_cleanup_sql, $sql;
707 }
708  
709 1 ▶sub cleanup {
Subroutine cleanup: called CC=4 SCAR=14.6
Pod undocumented
710 1 my $dbo = shift;
711  
712 1 note 'Doing cleanup';
713 1 for my $sql (@_cleanup_sql) {
714 1 ▶ $dbo->do($sql) or diag sql_err($dbo);
Branch: 1 branch
BranchTrueFalseTotal
$dbo->do($sql) or diag(sql_err($dbo)) 1 0 1
715 }
716  
717 1 $dbo->disconnect;
718 1 ▶ ok !defined $dbo->{dbh} && !defined $dbo->{rdbh}, 'Method DBIx::DBO->disconnect';
Condition33%1/3
defined $dbo->{'dbh'} || defined $dbo->{'rdbh'}
l!l&&r!l&&!r
001
MC/DC0%0/2
defined $dbo->{'dbh'} || defined $dbo->{'rdbh'}
defined $dbo->{'dbh'} defined $dbo->{'rdbh'}
Truth table33%1/3
A || B
A= defined $dbo->{'dbh'}B= defined $dbo->{'rdbh'}
ABresult
1X1
011
000
719 }
720  
721 0 ▶sub Dump {
Subroutine Dump: not called CC=15 SCAR=54.8
Pod undocumented
722 0 my($val, $var) = @_;
723 0 ▶ if (blessed $val and !defined $var) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($val) and not defined $var) 0 0 0
Condition0%0/3
builtin::blessed($val) and not defined $var
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($val) and not defined $var
builtin::blessed($val) not defined $var
Truth table0%0/3
A and not(B)
A= builtin::blessed($val)B= not defined $var
ABresult
0X0
100
111
724 0 ▶ if ($val->isa('DBIx::DBO')) {
Branch: 4 branches
BranchTrueFalseTotal
if ($val->isa('DBIx::DBO')) { } 0 0 0
elsif ($val->isa('DBIx::DBO::Table')) { } 0 0 0
elsif ($val->isa('DBIx::DBO::Query')) { } 0 0 0
elsif ($val->isa('DBIx::DBO::Row')) { } 0 0 0
725 0 $var = 'dbo';
726 } elsif ($val->isa('DBIx::DBO::Table')) {
727 0 $var = 't';
728 } elsif ($val->isa('DBIx::DBO::Query')) {
729 0 $var = 'q';
730 } elsif ($val->isa('DBIx::DBO::Row')) {
731 0 $var = 'r';
732 }
733 }
734 0 ▶ $var //= 'dump';
Condition0%0/2
$var //= "dump"
l!l
00
MC/DC0%0/1
$var //= "dump"
$var
Truth table0%0/2
A
A= $var
Aresult
11
00
735 0 require Data::Dumper;
736 0 local $Data::Dumper::Sortkeys = 1;
737 0 local $Data::Dumper::Quotekeys = 0;
738 0 my $d = Data::Dumper->new([$val], [$var]);
739 0 ▶ if (ref $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val) 0 0 0
740 0 my %seen;
741 0 my @_no_recursion = ($val);
742 0 ▶ if (reftype $val eq 'ARRAY') { _Find_Seen(\%seen, \@_no_recursion, $_) for @$val }
Branch: 3 branches
BranchTrueFalseTotal
if (builtin::reftype($val) eq 'ARRAY') { } 0 0 0
elsif (builtin::reftype($val) eq 'HASH') { } 0 0 0
elsif (builtin::reftype($val) eq 'REF') { } 0 0 0
743 0 elsif (reftype $val eq 'HASH') { _Find_Seen(\%seen, \@_no_recursion, $_) for values %$val }
744 0 elsif (reftype $val eq 'REF') { _Find_Seen(\%seen, \@_no_recursion, $$val) }
745 0 $d->Seen(\%seen);
746 }
747 0 ▶ defined wantarray ? return $d->Dump : print $d->Dump;
Branch: 1 branch
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
748 }
749  
750 0 ▶sub _Find_Seen {
Subroutine _Find_Seen: not called CC=17 SCAR=57.2
751 0 my($seen, $_no_recursion, $val) = @_;
752 0 ▶ return unless ref $val;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $val 0 0 0
753 0 for (@$_no_recursion) {
754 0 ▶ return if $val == $_;
Branch: 1 branch
BranchTrueFalseTotal
if $val == $_ 0 0 0
755 }
756 0 push @$_no_recursion, $val;
757  
758 0 ▶ if (blessed $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($val)) 0 0 0
759 0 ▶ if ($val->isa('DBIx::DBO')) {
Branch: 4 branches
BranchTrueFalseTotal
if ($val->isa('DBIx::DBO')) { } 0 0 0
elsif ($val->isa('DBIx::DBO::Table')) { } 0 0 0
elsif ($val->isa('DBIx::DBO::Query')) { } 0 0 0
elsif ($val->isa('DBIx::DBO::Row')) { } 0 0 0
760 0 $seen->{dbo} = $val;
761 0 return;
762 } elsif ($val->isa('DBIx::DBO::Table')) {
763 0 my $t = 1;
764 0 ▶ while (my($k, $v) = each %$seen) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$seen) 0 0 0
765 0 ▶ next if $k !~ /^t\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $k =~ /^t\d+$/u 0 0 0
766 0 ▶ return if $val == $v;
Branch: 1 branch
BranchTrueFalseTotal
if $val == $v 0 0 0
767 0 $t++;
768 }
769 0 $seen->{"t$t"} = $val;
770 0 return;
771 } elsif ($val->isa('DBIx::DBO::Query')) {
772 0 $seen->{q} = $val;
773 0 return;
774 } elsif ($val->isa('DBIx::DBO::Row')) {
775 0 $seen->{r} = $val;
776 0 return;
777 }
778 }
779 0 ▶ if (reftype $val eq 'ARRAY') { _Find_Seen($seen, $_no_recursion, $_) for @$val }
Branch: 3 branches
BranchTrueFalseTotal
if (builtin::reftype($val) eq 'ARRAY') { } 0 0 0
elsif (builtin::reftype($val) eq 'HASH') { } 0 0 0
elsif (builtin::reftype($val) eq 'REF') { } 0 0 0
780 0 elsif (reftype $val eq 'HASH') { _Find_Seen($seen, $_no_recursion, $_) for values %$val }
781 0 elsif (reftype $val eq 'REF') { _Find_Seen($seen, $_no_recursion, $$val) }
782 }
783  
784 # When testing via Sponge, use fake tables
785 package # Hide from PAUSE
786 DBIx::DBO::DBD::Sponge;
787 18 ▶sub _get_table_schema {
Subroutine _get_table_schema: called CC=1 SCAR=0.0
788 18 return;
789 }
790 12 my $fake_table_info = {
791 PrimaryKeys => [],
792 Columns => [ 'id', 'name', 'age' ],
793 Column_Idx => { id => 1, name => 2, age => 3 },
794 };
795 12 ▶sub _get_table_info {
Subroutine _get_table_info: called CC=3 SCAR=11.4
796 12 my($class, $me, $schema, $table) = @_;
797 12 ▶ return $class->SUPER::_get_table_info($me, $schema, $table) if $table ne $Test::DBO::test_tbl;
Branch: 1 branch
BranchTrueFalseTotal
if $table ne $Test::DBO::test_tbl 2 10 12
798 # Fake table info
799 10 ▶ return $me->{TableInfo}{''}{$table} ||= $fake_table_info;
Condition33%1/3
$me->{"TableInfo"}{""}{$table} ||= $fake_table_info
l!l&&r!l&&!r
0100
MC/DC0%0/2
$me->{"TableInfo"}{""}{$table} ||= $fake_table_info
$me->{"TableInfo"}{""}{$table} $fake_table_info
Truth table33%1/3
A ||= B
A= $me->{"TableInfo"}{""}{$table}B= $fake_table_info
ABresult
1X1
011
000
800 }
801  
802 # Replace DBI::connect for testing via MySpongeDBI
803 {
804 12 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
805 12 my $old_dbi_connect = \&DBI::connect;
806 44 ▶ *DBI::connect = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
807 44 ▶ return $old_dbi_connect->('MySpongeDBI', @_[1 .. $#_]) if $_[1] eq 'DBI:Sponge:';
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "DBI:Sponge:" 42 2 44
808 2 goto &$old_dbi_connect;
809 12 };
810 }
811  
812 # When testing via MySpongeDBI, fake table contents
813 package # Hide from PAUSE
814 MySpongeDBI::db;
815 12 @MySpongeDBI::ISA = ('DBI');
816 12 @MySpongeDBI::db::ISA = ('DBI::db');
817 12 @MySpongeDBI::st::ISA = ('DBI::st');
818 12 my $cols;
819 my @rows;
820 4 ▶sub setup {
Subroutine setup: called CC=1 SCAR=0.0
821 4 ($cols, @rows) = @_;
822 }
823 10 ▶sub prepare {
Subroutine prepare: called CC=4 SCAR=13.9
824 10 my($dbh, $sql, $attr) = @_;
825 10 ▶ $attr ||= {};
Condition100%2/2
$attr ||= {}
l!l
46
MC/DC100%1/1
$attr ||= {}
$attr
Truth table100%2/2
A
A= $attr
Aresult
11
00
826 10 ▶ $attr->{NAME} ||= $cols;
Condition66%2/3
$attr->{"NAME"} ||= $cols
l!l&&r!l&&!r
460
MC/DC0%0/2
$attr->{"NAME"} ||= $cols
$attr->{"NAME"} $cols
Truth table66%2/3
A ||= B
A= $attr->{"NAME"}B= $cols
ABresult
1X1
011
000
827 10 ▶ $attr->{rows} ||= [ @rows ];
Condition100%2/2
$attr->{"rows"} ||= [@rows]
l!l
46
MC/DC100%1/1
$attr->{"rows"} ||= [@rows]
$attr->{"rows"}
Truth table100%2/2
A
A= $attr->{"rows"}
Aresult
11
00
828 10 $dbh->SUPER::prepare($sql, $attr);
829 }
830  
831 12 1;
↑ Summary blib/lib/DBIx/DBO/Row.pm »