Model/Driver/DBI/DBD/SQLite.pm

filter: Statementstmt 52.0% 26 / 50 Branchbran 38.8% 7 / 18 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 72.7% 8 / 11 Podpod 0.0% 0 / 2 totaltotal 45.0% 45 / 100 CC 15 SCAR 18.0
CC
15
Cov
46%
_as_sql_column_type
12.0
_as_sql_column
8.7
bind_param_attributes
7.5
CRAP 6.0
« Model/Driver.pm ↑ Summary Model/Driver/Logic.pm »
1 package Data::Model::Driver::DBI::DBD::SQLite;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use base 'Data::Model::Driver::DBI::DBD';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 0 ▶sub fetch_last_id { $_[3]->func('last_insert_rowid') }
Subroutine fetch_last_id: not called CC=1 SCAR=6.9
Pod undocumented
7  
8 5 ▶sub bind_param_attributes {
Subroutine bind_param_attributes: called CC=5 SCAR=20.2
Pod undocumented
9 5 my($self, $data_type) = @_;
10 5 ▶ if ($data_type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data_type) 5 0 5
11 5 ▶ if ($data_type =~ /blob/i || $data_type =~ /bin/i || $data_type =~ /\Abigint\Z/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data_type =~ /blob/i or $data_type =~ /bin/i or $data_type =~ /\Abigint\Z/i) 0 5 5
Condition33%2/6
$data_type =~ /blob/i or $data_type =~ /bin/i or $data_type =~ /\Abigint\Z/i
l!l&&r!l&&!r
005
$data_type =~ /blob/i or $data_type =~ /bin/i
l!l&&r!l&&!r
005
MC/DC0%0/3
$data_type =~ /blob/i or $data_type =~ /bin/i or $data_type =~ /\Abigint\Z/i
$data_type =~ /blob/i $data_type =~ /bin/i $data_type =~ /\Abigint\Z/i
Truth table25%1/4
A or B or C
A= $data_type =~ /blob/iB= $data_type =~ /bin/iC= $data_type =~ /\Abigint\Z/i
ABCresult
1XX1
01X1
0011
0000
12 0 return DBI::SQL_BLOB;
13 }
14 }
15 5 return;
16 }
17  
18  
19  
20 1 ▶sub _as_sql_column {
Subroutine _as_sql_column: called CC=5 SCAR=21.6
21 1 my($self, $c, $column, $args) = @_;
22  
23 # for primary key
24 1 ▶ if (exists $args->{options}->{auto_increment} && $args->{options}->{auto_increment}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"options"}{"auto_increment"} and $args->{"options"}{"auto_increment"}) 0 1 1
Condition33%1/3
exists $args->{"options"}{"auto_increment"} and $args->{"options"}{"auto_increment"}
!ll&&!rl&&r
100
MC/DC0%0/2
exists $args->{"options"}{"auto_increment"} and $args->{"options"}{"auto_increment"}
exists $args->{"options"}{"auto_increment"} $args->{"options"}{"auto_increment"}
Truth table33%1/3
A and B
A= exists $args->{"options"}{"auto_increment"}B= $args->{"options"}{"auto_increment"}
ABresult
0X0
100
111
25 0 $c->{_sqlite_output_primary_key} = 1;
26 0 return sprintf('%-15s %-15s', $column, 'INTEGER') . ' NOT NULL PRIMARY KEY';
27 }
28  
29 # binary flagged is COLLATE BINARY
30 1 ▶ if (exists $args->{options}->{binary} && $args->{options}->{binary}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"options"}{"binary"} and $args->{"options"}{"binary"}) 1 0 1
Condition33%1/3
exists $args->{"options"}{"binary"} and $args->{"options"}{"binary"}
!ll&&!rl&&r
001
MC/DC0%0/2
exists $args->{"options"}{"binary"} and $args->{"options"}{"binary"}
exists $args->{"options"}{"binary"} $args->{"options"}{"binary"}
Truth table33%1/3
A and B
A= exists $args->{"options"}{"binary"}B= $args->{"options"}{"binary"}
ABresult
0X0
100
111
31 1 return sprintf('%-15s %-15s', $column, 'COLLATE BINARY');
32 }
33  
34 # TODO: you need COLLATE NOCASE suppor?
35  
36 0 return;
37 }
38  
39 0 ▶sub _as_sql_column_type {
Subroutine _as_sql_column_type: not called CC=3 SCAR=24.8
40 0 my($self, $c, $column, $args) = @_;
41 0 my $type = uc($args->{type});
42 0 ▶ if ($type =~ /BIN/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /BIN/) 0 0 0
43 0 $args->{options}->{binary} = 0;
44 0 return "BLOB";
45 }
46  
47 # for pseudo bigint emulation
48 0 ▶ if ($type eq 'BIGINT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "BIGINT") 0 0 0
49 0 $args->{options}->{binary} = 0;
50 0 return "BLOB";
51 }
52  
53 0 return;
54 }
55  
56 0 ▶sub _as_sql_unsigned { '' }
Subroutine _as_sql_unsigned: not called CC=1 SCAR=6.9
57  
58 1 ▶sub _as_sql_primary_key {
Subroutine _as_sql_primary_key: called CC=2 SCAR=7.1
59 1 my($self, $c) = @_;
60 1 ▶ return '' if $c->{_sqlite_output_primary_key};
Branch: 1 branch
BranchTrueFalseTotal
if $c->{"_sqlite_output_primary_key"} 0 1 1
61 1 return;
62 }
63  
64 1 ▶sub _as_sql_unique {
Subroutine _as_sql_unique: called CC=3 SCAR=17.9
65 1 my($self, $c, $unique) = @_;
66 1 ▶ return () unless @{ $unique };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$unique;} 1 0 1
67  
68 0 my @sql = ();
69 0 for my $data (@{ $unique }) {
70 0 my($name, $columns) = @{ $data };
71 0 push(@sql, 'UNIQUE (' . join(', ', @{ $columns }) . ')');
72 }
73 0 return @sql;
74 }
75  
76 1 ▶sub _as_sql_get_table_attributes {
Subroutine _as_sql_get_table_attributes: called CC=2 SCAR=8.1
77 1 my($self, $c, $attributes) = @_;
78 1 ▶ return '' unless $attributes->{SQLite};
Branch: 1 branch
BranchTrueFalseTotal
unless $attributes->{"SQLite"} 1 0 1
79 0 return $attributes->{SQLite};
80 }
81  
82 2 1;
« Model/Driver.pm ↑ Summary Model/Driver/Logic.pm »