Branch Coverage

Test/DBO.pm
Criterion Covered Total %
branch 103 264 39.0


line true false branch
15 0 10 if eval "$Carp::VERSION < 1.12"
18 0 10 unless (exists $Test::More::{'note'})
28 0 0 if $@
32 0 10 if ($ENV{'DBO_DEBUG_SQL'})
38 0 10 if ($ENV{'DBO_CARP_VERBOSE'}) { }
10 0 elsif ($ENV{'AUTOMATED_TESTING'}) { }
51 86 0 unless my $dbg = $ENV{'DBO_DEBUG_SQL'}
53 0 0 if ($dbg > 1) { }
72 38 0 if $Carp::Verbose
73 38 0 if $Carp::Verbose
81 10 0 if exists $INC{'Devel/Cover.pm'}
96 0 11 unless $dbd = shift()
100 3 8 unless grep(($_ eq $dbd), 'DBI'->available_drivers)
105 0 8 if ($@)
106 0 0 unless $@ =~ /\binstall_driver\b/
111 1 7 unless (eval { do { 'DBIx::DBO::DBD'->_require_dbd_class($dbd) } })
112 0 1 if ($@ =~ m[^Can't locate ([\w/]+)\.pm in \@INC ]m) { }
0 1 elsif ($@ =~ /^([\w:]+ version [\d\.]+ required.*?) at /m) { }
1 0 elsif ($@ =~ /^(\Q$dbd_name\E is not yet supported)/m) { }
132 1 6 if (exists $opt{'tempdir'})
135 0 1 if (ref $opt{'tempdir'}) { }
138 0 1 unless chdir $dir
144 0 7 defined $ENV{'DBO_CACHE_QUERY'} ? :
146 0 7 if (exists $opt{'try_connect'})
150 2 5 if exists $opt{'try_connect'} or exists $opt{'connect_ok'}
152 1 6 unless exists $opt{'tests'}
154 2 4 if (exists $opt{'connect_ok'}) { }
155 0 2 unless my $dbo = connect_ok(@{$opt{'connect_ok'};})
170 0 0 if @bind
178 2 0 unless defined $dsn
185 0 2 if (grep defined($_), @env)
186 0 0 if $$dbo_ref = connect_dbo(@env)
208 1 0 $can{'auto_increment_id'} ? :
213 1 0 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]))")) { }
221 0 1 unless is_deeply($$t{'PrimaryKeys'}, ['type', 'id'], 'Check PrimaryKeys')
225 0 1 unless $dbo->do("DROP TABLE $quoted_table") and $dbo->do($create_table) or diag(sql_err($dbo))
241 0 0 unless ok $dbo->do($create_table), 'Create the test table' or diag(sql_err($dbo))
251 0 1 unless $t
259 0 1 defined $test_sch ? :
263 0 1 unless $dbo->do("INSERT INTO $quoted_table VALUES (1, 'John Doe')")
264 0 1 unless $dbo->do("INSERT INTO $quoted_table VALUES (?, ?)", undef, 2, 'Jane Smith')
268 0 1 unless @$rv = $dbo->selectrow_array("SELECT * FROM $quoted_table")
271 0 1 unless $rv = $dbo->selectrow_arrayref("SELECT * FROM $quoted_table")
274 0 1 unless $rv = $dbo->selectall_arrayref("SELECT * FROM $quoted_table")
278 0 1 unless $rv = $t->insert('id', 3, 'name', 'Uncle Arnie')
301 0 1 unless $rv = $t->insert($c, {'FUNC', '4'}, 'name', 'NotUsed', 'name', \q['James Bond'])
306 0 1 unless $rv = $t->delete('id', 3)
309 1 0 if ($can{'auto_increment_id'}) { }
310 0 1 unless $t->insert('name', 'Vernon Lyon')
312 0 0 unless $t->insert('id', 5, 'name', 'Vernon Lyon')
315 0 1 unless $can{'auto_increment_id'}
317 0 1 unless is $t->last_insert_id, 5, 'Method DBIx::DBO::Table->last_insert_id'
323 1 0 unless ($can{'truncate'})
324 0 1 unless $t->delete
327 0 0 unless $t->truncate
332 0 1 unless $rv = $t->bulk_insert('rows', [map([@$_{'id', 'name'}], @$bulk_data)])
334 0 1 unless $t->delete
336 0 1 unless $rv = $t->bulk_insert('rows', \@$bulk_data)
338 0 1 unless $t->delete
340 0 1 unless $rv = $t->bulk_insert('columns', ['name', 'id'], 'rows', [map([@$_{'name', 'id'}], @$bulk_data)])
342 0 1 unless $t->delete
344 0 1 unless $rv = $t->bulk_insert('columns', ['name', 'id'], 'rows', \@$bulk_data)
354 0 1 unless $t
358 0 1 unless my $rv = $t->insert('id', {'FUNC', '? + 3', 'VAL', 3}, 'name', \q['Harry Harrelson'])
361 0 1 unless $t->insert('id', 7, 'name', 'Amanda Huggenkiss')
362 0 1 unless $t->insert('id', 8, 'name', undef)
365 0 1 unless $rv = $t->delete('id', \'NOT NULL', 'name', undef)
375 0 0 unless $t->insert('id', 6, 'name', 'Harry Harrelson')
376 0 0 unless $t->insert('id', 7, 'name', 'Amanda Huggenkiss')
397 0 1 unless ok $r->load('id', [2, 3], 'name', 'Jane Smith'), 'Method DBIx::DBO::Row->load'
406 0 1 unless is $r->update('name', 'Someone Else'), 1, 'Method DBIx::DBO::Row->update'
407 0 1 unless is_deeply(\@$r, [2, 'Someone Else'], 'Row updated correctly (internal)')
408 0 1 unless $r->load('id', 2)
409 0 1 unless is_deeply(\@$r, [2, 'Someone Else'], 'Row updated correctly (external)')
411 0 1 unless $r->update('name', 'Nobody', $t ** 'name', 'Anybody')
412 0 1 unless is_deeply(\@{$r->load('id', 2);}, [2, 'Anybody'], 'Row update removes duplicates')
416 0 1 unless $r->update('id', 3, 'name', \q['Uncle Arnie'])
417 0 1 unless ok !$r->is_empty, 'Row reloaded on update' or $r->load('id', [2, 3])
419 0 1 unless ok $r->delete, 'Method DBIx::DBO::Row->delete'
447 0 1 unless isa_ok $q->_sth, 'DBI::st', '$q->_sth'
478 0 1 unless $q->run
488 0 1 unless ok $q->where('name', 'LIKE', \q['%o%']), 'Method DBIx::DBO::Query->where'
501 0 1 unless is_deeply($got, [4, 5, 6], 'Method DBIx::DBO::Query->open_bracket')
507 0 1 unless is $q->update('id', {'FUNC', '? + 10', 'COL', 'id'}), 3, 'Method DBIx::DBO::Query->update'
528 0 1 unless ok(($q->group_by({'FUNC', 'SUBSTR(?, 1, 1)', 'COL', 'name'}), $q->run), 'Method DBIx::DBO::Query->group_by')
537 0 1 unless ok $r->update('id', $$r{'key'}), 'Can update a Row despite using aliases'
538 0 1 unless ok $r->load('id', 15), 'Can load a Row despite using aliases'
567 0 1 unless $can{'collate'}
570 0 1 unless ok $q->run, 'Method DBIx::DBO::Query->order_by COLLATE'
574 0 1 unless ok $q->run && $q->fetch->{'name'} eq 'JOHN DOE', 'Method DBIx::DBO::Query->show'
585 0 1 unless my $case_sensitive = $dbo->selectrow_arrayref($case_sensitivity_sql, undef, 'a', 'A')
587 0 1 $case_sensitive ? :
592 0 1 unless my $a = $q->col_arrayref
595 0 1 unless $a = $q->arrayref
598 0 1 unless $a = $q->hashref('id')
602 1 0 $dbd eq 'SQLite' ? :
604 1 0 $$dbo{'dbd_class'}->_alias_preference($q, 'having') ? :
642 0 1 unless is $q->count_rows, 3, 'Method DBIx::DBO::Query->count_rows'
643 0 1 unless is $q->found_rows, 36, 'Method DBIx::DBO::Query->found_rows'
653 0 1 if $dbd eq 'Oracle'
654 0 0 unless $q->run or fail 'JOIN ON' or diag(sql_err($q))
656 0 1 unless $r = $q->fetch or fail 'JOIN ON'
659 0 1 unless $r->load($t1 ** 'id', 2)
679 0 0 unless $q->_sth or diag(sql_err($q)) or fail 'LEFT JOIN'
681 0 1 unless $r = $q->fetch or fail 'LEFT JOIN'
688 1 0 unless $can{'multi_table_update'}
690 0 0 unless ok $r->update($t1 ** 'name', 'Vernon Wayne Lyon'), 'Method DBIx::DBO::Row->update'
707 0 1 unless $dbo->do($sql)
716 0 0 if (blessed $val and not defined $var)
717 0 0 if ($val->isa('DBIx::DBO')) { }
0 0 elsif ($val->isa('DBIx::DBO::Table')) { }
0 0 elsif ($val->isa('DBIx::DBO::Query')) { }
0 0 elsif ($val->isa('DBIx::DBO::Row')) { }
727 0 0 unless defined $var
732 0 0 if (ref $val)
735 0 0 if (reftype $val eq 'ARRAY') { }
0 0 elsif (reftype $val eq 'HASH') { }
0 0 elsif (reftype $val eq 'REF') { }
740 0 0 defined wantarray ? :
745 0 0 unless ref $val
747 0 0 if $val == $_
751 0 0 if (blessed $val)
752 0 0 if ($val->isa('DBIx::DBO')) { }
0 0 elsif ($val->isa('DBIx::DBO::Table')) { }
0 0 elsif ($val->isa('DBIx::DBO::Query')) { }
0 0 elsif ($val->isa('DBIx::DBO::Row')) { }
758 0 0 unless $k =~ /^t\d+$/
759 0 0 if $val == $v
772 0 0 if (reftype $val eq 'ARRAY') { }
0 0 elsif (reftype $val eq 'HASH') { }
0 0 elsif (reftype $val eq 'REF') { }
790 1 4 if $table ne $Test::DBO::test_tbl