blib/lib/DBIO/MySQL/Introspect.pm

filter: Statementstmt 75.0% 30 / 40 Branchbran 75.0% 6 / 8 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 80.0% 8 / 10 Podpod 100% 2 / 2 totaltotal 68.1% 47 / 69 CC 8 SCAR 19.0
CC
8
Cov
69%
view_definition
20.0
result_class_extra_statements
5.0
_build_model
2.0
CRAP 6.7
« blib/lib/DBIO/MySQL/Storage/Async.pm ↑ Summary blib/lib/DBIO/MySQL/DefaultValue.pm »
1 package DBIO::MySQL::Introspect;
2 # ABSTRACT: Introspect a MySQL/MariaDB database via information_schema
3  
4 42 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 42 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 42 our $VERSION = '0.900007';
8  
9 42 ▶use base 'DBIO::Introspect::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 42 ▶use DBIO::MySQL::Introspect::Tables;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 42 ▶use DBIO::MySQL::Introspect::Columns;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 42 ▶use DBIO::MySQL::Introspect::Indexes;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 42 ▶use DBIO::MySQL::Introspect::ForeignKeys;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 0 ▶sub _build_model {
Subroutine _build_model: not called CC=1 SCAR=6.9
18 0 my ($self) = @_;
19 0 my $dbh = $self->dbh;
20  
21 0 my $tables = DBIO::MySQL::Introspect::Tables->fetch($dbh);
22 return {
23 0 tables => $tables,
24 columns => DBIO::MySQL::Introspect::Columns->fetch($dbh, $tables),
25 indexes => DBIO::MySQL::Introspect::Indexes->fetch($dbh, $tables),
26 foreign_keys => DBIO::MySQL::Introspect::ForeignKeys->fetch($dbh, $tables),
27 };
28 }
29  
30 0 ▶sub view_definition {
Subroutine view_definition: not called CC=4 SCAR=30.0
Pod documented
31 0 my ($self, $key) = @_;
32 0 my $model = $self->model;
33 0 ▶ my $tbl = $model->{tables}{$key} // {};
Condition0%0/2
$model->{"tables"}{$key} // {}
l!l
00
MC/DC0%0/1
$model->{"tables"}{$key} // {}
$model->{"tables"}{$key}
Truth table0%0/2
A
A= $model->{"tables"}{$key}
Aresult
11
00
34 0 ▶ return undef unless ($tbl->{kind} // '') eq 'view';
Branch: 1 branch
BranchTrueFalseTotal
unless ($tbl->{"kind"} // "") eq "view" 0 0 0
Condition0%0/2
$tbl->{"kind"} // ""
l!l
00
MC/DC0%0/1
$tbl->{"kind"} // ""
$tbl->{"kind"}
Truth table0%0/2
A
A= $tbl->{"kind"}
Aresult
11
00
35  
36 0 my ($def) = $self->dbh->selectrow_array(
37 q{SELECT view_definition FROM information_schema.views
38 WHERE table_schema = DATABASE() AND table_name = ?},
39 undef, $key,
40 );
41 0 return $def;
42 }
43  
44 4 ▶sub result_class_extra_statements {
Subroutine result_class_extra_statements: called CC=5 SCAR=16.1
Pod documented
45 4 my ($self, $key) = @_;
46 4 my $model = $self->model;
47 4 ▶ my $tbl = $model->{tables}{$key} // {};
Condition50%1/2
$model->{"tables"}{$key} // {}
l!l
40
MC/DC0%0/1
$model->{"tables"}{$key} // {}
$model->{"tables"}{$key}
Truth table50%1/2
A
A= $model->{"tables"}{$key}
Aresult
11
00
48  
49 # source_info is a plain setter -- emit ONE statement, a second call
50 # would replace the first
51 4 my %info;
52 4 ▶ $info{mysql_engine} = $tbl->{engine} if $tbl->{engine};
Branch: 1 branch
BranchTrueFalseTotal
if $tbl->{"engine"} 3 1 4
53 4 ▶ $info{mysql_collation} = $tbl->{table_collation} if $tbl->{table_collation};
Branch: 1 branch
BranchTrueFalseTotal
if $tbl->{"table_collation"} 3 1 4
54  
55 4 ▶ return %info ? ([ source_info => \%info ]) : ();
Branch: 1 branch
BranchTrueFalseTotal
%info ? : 3 1 4
56 }
57  
58 42 1;
59  
60 __END__
« blib/lib/DBIO/MySQL/Storage/Async.pm ↑ Summary blib/lib/DBIO/MySQL/DefaultValue.pm »