DBD/PO/Statement.pm

filter: Statementstmt 90.4% 19 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 92.8% 26 / 28 CC 1 SCAR 0.4
CC
1
Cov
90%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« DBD/PO/Text/PO.pm ↑ Summary DBD/PO/db.pm »
1 package DBD::PO::Statement;
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 our $VERSION = '2.09';
7
8 1 ▶use DBD::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use parent qw(-norequire DBD::File::Statement);
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use English qw(-no_match_vars $OS_ERROR);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 0 ▶use DBD::PO::Text::PO qw($EOL_DEFAULT $SEPARATOR_DEFAULT @COL_NAMES);
Subroutine BEGIN: called CC=1 SCAR=2.6
14
15 sub open_table { ## no critic (ExcessComplexity)
16 my ($self, $data, $table, $create_mode, $lock_mode) = @_;
17
18 my $dbh = $data->{Database};
19 my $tables = $dbh->{po_tables};
20 if (! exists $tables->{$table}) {
21 $tables->{$table} = {};
22 }
23 my $meta = $tables->{$table} || {};
24 my $po = $meta->{po} || $dbh->{po_po};
25 if (! $po) {
26 @{ $dbh->FETCH('f_valid_attrs') }{qw(po_eol po_separator po_charset)}
27 = (1) x 3; ## no critic (MagicNumbers)
28 my $class = $meta->{class}
29 || $dbh->{po_class}
30 || 'DBD::PO::Text::PO';
31 my %opts = (
32 eol => exists $meta->{eol}
33 ? $meta->{eol}
34 : exists $dbh->{po_eol}
35 ? $dbh->{po_eol}
36 : $EOL_DEFAULT,
37 separator => exists $meta->{separator}
38 ? $meta->{separator}
39 : exists $dbh->{po_separator}
40 ? $dbh->{po_separator}
41 : $SEPARATOR_DEFAULT,
42 charset => exists $meta->{charset}
43 ? $meta->{charset}
44 : $dbh->{po_charset}
45 ? $dbh->{po_charset}
46 : undef,
47 );
48 $po = $meta->{po}
49 = $class->new(\%opts);
50 }
51 my $file = $meta->{file}
52 || $table;
53 my $tbl = $self->SUPER::open_table($data, $file, $create_mode, $lock_mode);
54 if ($tbl) {
55 {
56 my $po_charset = exists $meta->{charset}
57 ? $meta->{charset}
58 : $dbh->{po_charset}
59 ? $dbh->{po_charset}
60 : undef;
61 if ($po_charset && $tbl->{fh}) {
62 $tbl->{fh}->binmode("encoding($po_charset)")
63 or croak "binmode $OS_ERROR";
64 }
65 }
66 $tbl->{po_po} = $po;
67 my $types = $meta->{types};
68 if ($types) {
69 # The 'types' array contains DBI types, but we need types
70 # suitable for DBD::Text::PO.
71 my $t = [];
72 for (@{$types}) {
73 if ($_) {
74 $_ = $DBD::PO::PO_TYPES[$_ + 6] ## no critic (MagicNumbers)
75 || $DBD::PO::PV;
76 }
77 else {
78 $_ = $DBD::PO::PV;
79 }
80 push @{$t}, $_;
81 }
82 $tbl->{types} = $t;
83 }
84 if (
85 ! $create_mode
86 && ! $self->{ignore_missing_table}
87 && $self->command() ne 'DROP'
88 ) {
89 $tbl->{col_names} = \@COL_NAMES;
90 }
91 }
92
93 return $tbl;
94 }
95
96 sub command {
97 return shift->{command};
98 }
99
100 1;
101
102 __END__
« DBD/PO/Text/PO.pm ↑ Summary DBD/PO/db.pm »