blib/lib/DBIO/SQLite/Introspect.pm

filter: Statementstmt 100% 45 / 45 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 95.1% 59 / 62 CC 4 SCAR 6.3
CC
4
Cov
96%
table_columns_info
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« blib/lib/DBIO/SQLite/Introspect/Triggers.pm ↑ Summary blib/lib/DBIO/SQLite/Introspect/ForeignKeys.pm »
1 package DBIO::SQLite::Introspect;
2 # ABSTRACT: Introspect a SQLite database via sqlite_master and PRAGMAs
3  
4 193 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 193 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 193 our $VERSION = '0.900007';
8  
9 193 ▶use base 'DBIO::Introspect::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 193 ▶use DBIO::SQLite::Introspect::Tables;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 193 ▶use DBIO::SQLite::Introspect::Columns;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 193 ▶use DBIO::SQLite::Introspect::Indexes;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 193 ▶use DBIO::SQLite::Introspect::ForeignKeys;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 193 ▶use DBIO::SQLite::Introspect::Triggers;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 193 ▶use DBIO::SQLite::Util qw(column_is_nullable pk_is_rowid_alias);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 761 ▶sub _build_model {
Subroutine _build_model: called CC=1 SCAR=0.0
20 761 my ($self) = @_;
21  
22 761 my $tables = DBIO::SQLite::Introspect::Tables->fetch($self->dbh);
23 757 my $columns = DBIO::SQLite::Introspect::Columns->fetch($self->dbh, $tables);
24 755 my $indexes = DBIO::SQLite::Introspect::Indexes->fetch($self->dbh, $tables);
25 755 my $fks = DBIO::SQLite::Introspect::ForeignKeys->fetch($self->dbh, $tables);
26 755 my $triggers = DBIO::SQLite::Introspect::Triggers->fetch($self->dbh, $tables);
27  
28 return {
29 755 tables => $tables,
30 columns => $columns,
31 indexes => $indexes,
32 foreign_keys => $fks,
33 triggers => $triggers,
34 };
35 }
36  
37  
38 26 ▶sub table_columns_info {
Subroutine table_columns_info: called CC=4 SCAR=14.0
Pod documented
39 26 my ($self, $key) = @_;
40 26 my $info = $self->SUPER::table_columns_info($key);
41 26 ▶ my $cols = $self->model->{columns}{$key} || [];
Condition50%1/2
$self->model->{'columns'}{$key} || []
l!l
260
MC/DC0%0/1
$self->model->{'columns'}{$key} || []
$self->model->{'columns'}{$key}
Truth table50%1/2
A
A= $self->model->{'columns'}{$key}
Aresult
11
00
42  
43 # Only a key column can disagree with the base, and only then is the extra
44 # PRAGMA worth running. Views and keyless tables keep SUPER's answer.
45 26 ▶ return $info unless grep { $_->{is_pk} } @$cols;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_->{"is_pk"};} @$cols 0 26 26
46  
47 26 my $alias = pk_is_rowid_alias($self->dbh, $key);
48 26 for my $col (@$cols) {
49 $info->{ $col->{column_name} }{is_nullable} =
50 65 column_is_nullable($col->{not_null}, $col->{is_pk}, $alias);
51 }
52 26 return $info;
53 }
54  
55 193 1;
56  
57 __END__
« blib/lib/DBIO/SQLite/Introspect/Triggers.pm ↑ Summary blib/lib/DBIO/SQLite/Introspect/ForeignKeys.pm »