Geoffrey/Converter/SQLite/Index.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 59 / 59 CC 6 SCAR 9.9
CC
6
Cov
100%
add
5.0
drop
2.0
BEGIN
1.0
CRAP 2.7
« Geoffrey/Role/Action.pm ↑ Summary Geoffrey/Template.pm »
1 package Geoffrey::Converter::SQLite::Index;
2  
3 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 $Geoffrey::Converter::SQLite::Index::VERSION = '0.000206';
9  
10 5 ▶use parent 'Geoffrey::Role::ConverterType';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 8 ▶sub add {
Subroutine add: called CC=5 SCAR=16.1
Pod documented
13 8 my ( $self, $params ) = @_;
14 8 ▶ if ( !$params ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($params) 1 7 8
15 1 require Geoffrey::Exception::General;
16 1 Geoffrey::Exception::General::throw_no_params();
17 }
18 7 ▶ if ( !$params->{table} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($params->{"table"}) 1 6 7
19 1 require Geoffrey::Exception::RequiredValue;
20 1 Geoffrey::Exception::RequiredValue::throw_table_name();
21 }
22 6 ▶ if ( !$params->{column} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($params->{"column"}) 1 5 6
23 1 require Geoffrey::Exception::RequiredValue;
24 1 Geoffrey::Exception::RequiredValue::throw_refcolumn_missing();
25 }
26 5 require Ref::Util;
27 5 require Geoffrey::Utils;
28 return Geoffrey::Utils::replace_spare(
29 q~CREATE INDEX {0} ON {1} ({2})~,
30 [ Geoffrey::Utils::add_name(
31 { prefix => 'ix',
32 name => $params->{name},
33 context => $params->{table}
34 }
35 ),
36 $params->{table},
37 ( join ', ',
38 Ref::Util::is_arrayref( $params->{column} )
39 2 ? @{ $params->{column} }
40 : ( $params->{column} )
41 5 ▶ )
Branch: 1 branch
BranchTrueFalseTotal
Ref::Util::XS::is_arrayref($params->{'column'}) ? : 2 3 5
42 ]
43 );
44 }
45  
46 5 ▶sub drop {
Subroutine drop: called CC=2 SCAR=6.9
Pod documented
47 5 my ( $self, $name ) = @_;
48 5 ▶ if ( !$name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name) 1 4 5
49 1 require Geoffrey::Exception::RequiredValue;
50 1 Geoffrey::Exception::RequiredValue::throw_index_name();
51 }
52 4 return qq~DROP INDEX $name~;
53 }
54  
55 4 ▶sub list {
Subroutine list: called CC=1 SCAR=0.0
Pod documented
56 4 my ( $self, $schema ) = @_;
57 4 require Geoffrey::Utils;
58 return
59 4 q~SELECT * FROM ~
60 . Geoffrey::Utils::add_schema($schema)
61 . q~sqlite_master WHERE type='index'~;
62 }
63  
64 5 1; # End of Geoffrey::Converter::SQLite::Index
65  
66 __END__
« Geoffrey/Role/Action.pm ↑ Summary Geoffrey/Template.pm »