| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | if ($data_type =~ /blob/i || $data_type =~ /bin/i || $data_type =~ /\Abigint\Z/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$data_type =~ /blob/i or $data_type =~ /bin/i or $data_type =~ /\Abigint\Z/i
$data_type =~ /blob/i or $data_type =~ /bin/i
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
exists $args->{"options"}{"auto_increment"} and $args->{"options"}{"auto_increment"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
exists $args->{"options"}{"binary"} and $args->{"options"}{"binary"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return $attributes->{SQLite}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||