blib/lib/DBIx/TableLoader.pm

filter: Statementstmt 100% 140 / 140 Branchbran 93.7% 45 / 48 Conditioncond 78.3% 29 / 37 MC/DCmcdc 31.8% 7 / 22 Subroutinesub 100% 40 / 40 Podpod 100% 28 / 28 totaltotal 91.7% 289 / 315 CC 40 SCAR 10.8
CC
40
Cov
95%
determine_column_types
6.0
get_row
6.0
__ANON__
5.1
CRAP 2.9
↑ Summary
1 # vim: set ts=2 sts=2 sw=2 expandtab smarttab:
2 #
3 # This file is part of DBIx-TableLoader
4 #
5 # This software is copyright (c) 2011 by Randy Stauner.
6 #
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 #
10 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package DBIx::TableLoader;
14 # git description: v1.100-1-g8e5d9b8
15  
16 7 our $AUTHORITY = 'cpan:RWSTAUNER';
17 # ABSTRACT: Easily load a database table from a data set
18 7 $DBIx::TableLoader::VERSION = '1.101';
19 7 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 #use DBI 1.13 (); # oldest DBI on CPAN as of 2011-02-15; Has SQL_LONGVARCHAR
21 7 ▶use Try::Tiny 0.09;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23  
24 44 ▶sub new {
Subroutine new: called CC=5 SCAR=16.1
Pod documented
25 44 my $class = shift;
26 44 my $self = bless {}, $class;
27  
28 44 ▶ my %opts = @_ == 1 ? %{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 16 28 44
29  
30 44 my %defaults = (%{ $self->base_defaults }, %{ $self->defaults });
31 44 ▶ while( my ($key, $value) = each %defaults ){
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %defaults) 1102 44 1146
32 $self->{$key} = exists($opts{$key})
33 1102 ▶ ? delete $opts{$key}
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{$key} ? : 137 965 1102
34 : $value;
35 }
36  
37 # be loud about typos
38 44 ▶ croak("Unknown options: ${\join(', ', keys %opts)}")
Branch: 1 branch
BranchTrueFalseTotal
if %opts 1 43 44
39 if %opts;
40  
41 # custom routine to handle type of input data (hook for subclasses)
42 43 $self->prepare_data();
43  
44 # normalize 'columns' attribute
45 43 $self->determine_column_types();
46  
47 41 return $self;
48 }
49  
50  
51 44 ▶sub base_defaults {
Subroutine base_defaults: called CC=1 SCAR=0.0
Pod documented
52 return {
53 44 catalog => undef,
54 columns => undef,
55 create => 1,
56 create_prefix => '',
57 create_sql => '',
58 create_suffix => '',
59 # 'data' attribute may not be useful in subclasses
60 data => undef,
61 dbh => undef,
62 default_column_type => '',
63 default_sql_data_type => '',
64 drop => 0,
65 drop_prefix => '',
66 drop_sql => '',
67 drop_suffix => '',
68 get_row => undef,
69 grep_rows => undef,
70 handle_invalid_row => undef,
71 map_rows => undef,
72 # default_name() method will default to 'data' if 'name' is blank
73 # this way subclasses don't have to override this value in defaults()
74 name => '',
75 name_prefix => '',
76 name_suffix => '',
77 quoted_name => undef,
78 schema => undef,
79 table_type => '', # TEMP, TEMPORARY, VIRTUAL?
80 transaction => 1,
81 };
82 }
83  
84  
85 42 ▶sub defaults {
Subroutine defaults: called CC=1 SCAR=0.0
Pod documented
86 42 return {};
87 }
88  
89  
90 146 ▶sub columns {
Subroutine columns: called CC=2 SCAR=6.9
Pod documented
91 146 my ($self) = @_;
92 # by default the column names are found in the first row of the data
93 # (but circumvent get_row() to avoid any grep or map subs)
94 146 ▶ return $self->{columns} ||= $self->_get_custom_or_raw_row();
Condition100%3/3
$self->{"columns"} ||= $self->_get_custom_or_raw_row
l!l&&r!l&&!r
130151
MC/DC100%2/2
$self->{"columns"} ||= $self->_get_custom_or_raw_row
$self->{"columns"} $self->_get_custom_or_raw_row
Truth table100%3/3
A ||= B
A= $self->{"columns"}B= $self->_get_custom_or_raw_row
ABresult
1X1
011
000
95 }
96  
97  
98 29 ▶sub column_names {
Subroutine column_names: called CC=1 SCAR=0.0
Pod documented
99 29 my ($self) = @_;
100 # return the first element of each arrayref
101 29 return [ map { $$_[0] } @{ $self->columns } ];
102 }
103  
104  
105 10 ▶sub create {
Subroutine create: called CC=1 SCAR=0.0
Pod documented
106 10 my ($self) = @_;
107 10 $self->{dbh}->do($self->create_sql);
108 }
109  
110  
111 16 ▶sub create_prefix {
Subroutine create_prefix: called CC=2 SCAR=6.9
Pod documented
112 16 my ($self) = @_;
113 return $self->{create_prefix} ||=
114 16 ▶ "CREATE $self->{table_type} TABLE " .
Condition100%2/2
$self->{"create_prefix"} ||= qq[CREATE $self->{"table_type"} TABLE ] . $self->quoted_name . ' ('
l!l
79
MC/DC100%1/1
$self->{"create_prefix"} ||= qq[CREATE $self->{"table_type"} TABLE ] . $self->quoted_name . ' ('
$self->{"create_prefix"}
Truth table100%2/2
A
A= $self->{"create_prefix"}
Aresult
11
00
115 $self->quoted_name . " (";
116 }
117  
118  
119 16 ▶sub create_sql {
Subroutine create_sql: called CC=2 SCAR=7.0
Pod documented
120 16 my ($self) = @_;
121 $self->{create_sql} ||=
122 join(' ',
123 $self->create_prefix,
124  
125 # column definitions (each element is: [name, data_type])
126 join(', ', map {
127 20 $self->{dbh}->quote_identifier($_->[0]) . ' ' . $_->[1]
128 16 ▶ } @{ $self->columns }),
Condition66%2/3
$self->{"create_sql"} ||= join(" ", $self->create_prefix, join(", ", map({$self->{"dbh"}->quote_identifier($_->[0]) . ' ' . $_->[1];} @{$self->columns;})), $self->create_suffix)
l!l&&r!l&&!r
6100
MC/DC0%0/2
$self->{"create_sql"} ||= join(" ", $self->create_prefix, join(", ", map({$self->{"dbh"}->quote_identifier($_->[0]) . ' ' . $_->[1];} @{$self->columns;})), $self->create_suffix)
$self->{"create_sql"} join(" ", $self->create_prefix, join(", ", map({$self->{"dbh"}->quote_identifier($_->[0]) . ' ' . $_->[1];} @{$self->columns;})), $self->create_suffix)
Truth table66%2/3
A ||= B
A= $self->{"create_sql"}B= join(" ", $self->create_prefix, join(", ", map({$self->{"dbh"}->quote_identifier($_->[0]) . ' ' . $_->[1];} @{$self->columns;})), $self->create_suffix)
ABresult
1X1
011
000
129  
130 $self->create_suffix
131 );
132 }
133  
134  
135 16 ▶sub create_suffix {
Subroutine create_suffix: called CC=2 SCAR=6.9
Pod documented
136 16 my ($self) = @_;
137 return $self->{create_suffix} ||=
138 16 ▶ ')';
Condition100%2/2
$self->{"create_suffix"} ||= ")"
l!l
88
MC/DC100%1/1
$self->{"create_suffix"} ||= ")"
$self->{"create_suffix"}
Truth table100%2/2
A
A= $self->{"create_suffix"}
Aresult
11
00
139 }
140  
141 # ask the driver what data type it uses for the desired SQL standard type
142  
143 27 ▶sub _data_type_from_driver {
Subroutine _data_type_from_driver: called CC=2 SCAR=6.9
144 27 my ($self, $data_type) = @_;
145 27 ▶ if( my $type = $self->{dbh}->type_info($data_type) ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = $self->{"dbh"}->type_info($data_type)) 17 3 20
146 17 return $type->{TYPE_NAME};
147 }
148 3 return;
149 }
150  
151  
152 16 ▶sub default_name {
Subroutine default_name: called CC=1 SCAR=0.0
Pod documented
153 16 return 'data';
154 }
155  
156  
157 46 ▶sub default_column_type {
Subroutine default_column_type: called CC=3 SCAR=11.0
Pod documented
158 46 my ($self) = @_;
159 27 ▶ return $self->{default_column_type} ||= try {
Subroutine __ANON__: called CC=1 SCAR=0.0
160 27 $self->_data_type_from_driver($self->default_sql_data_type);
161 }
162 # outside the eval in case there was an error
163 46 ▶ || 'text';
Condition80%4/5
$self->{"default_column_type"} ||= &try(sub { $self->_data_type_from_driver($self->default_sql_data_type); } ) || "text"
l!l&&r!l&&!r
19270
&try(sub { $self->_data_type_from_driver($self->default_sql_data_type); } ) || 'text'
l!l
1710
MC/DC0%0/2
$self->{"default_column_type"} ||= &try(sub { $self->_data_type_from_driver($self->default_sql_data_type); } ) || "text"
$self->{"default_column_type"} &try(sub { $self->_data_type_from_driver($self->default_sql_data_type); } )
Truth table66%2/3
A ||= B
A= $self->{"default_column_type"}B= &try(sub { $self->_data_type_from_driver($self->default_sql_data_type); } )
ABresult
1X1
011
000
164 }
165  
166  
167 28 ▶sub default_sql_data_type {
Subroutine default_sql_data_type: called CC=2 SCAR=7.0
Pod documented
168 28 my ($self) = @_;
169 27 ▶ $self->{default_sql_data_type} ||= try {
Subroutine __ANON__: called CC=1 SCAR=0.0
170 # if this doesn't work default_column_type will just use 'text'
171 27 require DBI;
172 27 DBI::SQL_LONGVARCHAR();
173 28 ▶ };
Condition66%2/3
$self->{"default_sql_data_type"} ||= &try(sub { require DBI; DBI::SQL_LONGVARCHAR(); } )
l!l&&r!l&&!r
1270
MC/DC0%0/2
$self->{"default_sql_data_type"} ||= &try(sub { require DBI; DBI::SQL_LONGVARCHAR(); } )
$self->{"default_sql_data_type"} &try(sub { require DBI; DBI::SQL_LONGVARCHAR(); } )
Truth table66%2/3
A ||= B
A= $self->{"default_sql_data_type"}B= &try(sub { require DBI; DBI::SQL_LONGVARCHAR(); } )
ABresult
1X1
011
000
174 }
175  
176  
177 43 ▶sub determine_column_types {
Subroutine determine_column_types: called CC=6 SCAR=17.9
Pod documented
178 43 my ($self) = @_;
179 43 my ($columns, $type) = ($self->columns, $self->default_column_type);
180  
181 43 ▶ croak("Unable to determine columns!")
Branch: 1 branch
BranchTrueFalseTotal
unless $columns and @$columns 2 41 43
Condition100%3/3
$columns and @$columns
!ll&&!rl&&r
1141
MC/DC100%2/2
$columns and @$columns
$columns @$columns
Truth table100%3/3
A and B
A= $columnsB= @$columns
ABresult
0X0
100
111
182 unless $columns && @$columns;
183  
184 # break reference
185 41 $columns = [@$columns];
186  
187 # reset each element to an arrayref if it isn't already
188 41 foreach my $column ( @$columns ){
189 # upgrade lone string to arrayref otherwise break reference
190 84 ▶ $column = ref $column ? [@$column] : [$column];
Branch: 1 branch
BranchTrueFalseTotal
ref $column ? : 9 75 84
191 # append column type if missing
192 84 ▶ push(@$column, $type)
Branch: 1 branch
BranchTrueFalseTotal
unless @$column > 1 77 7 84
193 unless @$column > 1;
194 }
195  
196 # restore changes
197 41 $self->{columns} = $columns;
198 41 return;
199 }
200  
201  
202 8 ▶sub drop {
Subroutine drop: called CC=1 SCAR=0.0
Pod documented
203 8 my ($self) = @_;
204 8 $self->{dbh}->do($self->drop_sql);
205 }
206  
207  
208 16 ▶sub drop_prefix {
Subroutine drop_prefix: called CC=2 SCAR=6.9
Pod documented
209 16 my ($self) = @_;
210 # default to "DROP TABLE" since SQLite, PostgreSQL, and MySQL
211 # all accept it (rather than "DROP $table_type TABLE")
212 16 ▶ $self->{drop_prefix} ||= 'DROP TABLE';
Condition100%2/2
$self->{"drop_prefix"} ||= "DROP TABLE"
l!l
97
MC/DC100%1/1
$self->{"drop_prefix"} ||= "DROP TABLE"
$self->{"drop_prefix"}
Truth table100%2/2
A
A= $self->{"drop_prefix"}
Aresult
11
00
213 }
214  
215  
216 16 ▶sub drop_sql {
Subroutine drop_sql: called CC=2 SCAR=7.1
Pod documented
217 16 my ($self) = @_;
218 16 ▶ return $self->{drop_sql} ||= join(' ',
Condition66%2/3
$self->{"drop_sql"} ||= join(" ", $self->drop_prefix, $self->quoted_name, $self->drop_suffix)
l!l&&r!l&&!r
880
MC/DC0%0/2
$self->{"drop_sql"} ||= join(" ", $self->drop_prefix, $self->quoted_name, $self->drop_suffix)
$self->{"drop_sql"} join(" ", $self->drop_prefix, $self->quoted_name, $self->drop_suffix)
Truth table66%2/3
A ||= B
A= $self->{"drop_sql"}B= join(" ", $self->drop_prefix, $self->quoted_name, $self->drop_suffix)
ABresult
1X1
011
000
219 $self->drop_prefix,
220 $self->quoted_name,
221 $self->drop_suffix,
222 );
223 }
224  
225  
226 16 ▶sub drop_suffix {
Subroutine drop_suffix: called CC=1 SCAR=0.0
Pod documented
227 16 my ($self) = @_;
228 # default is blank
229 16 return $self->{drop_suffix};
230 }
231  
232 # call get_raw_row unless a custom 'get_row' is defined
233 # (this is the essence of get_row() but without the grep/map subs)
234  
235 88 ▶sub _get_custom_or_raw_row {
Subroutine _get_custom_or_raw_row: called CC=2 SCAR=6.9
236 88 my ($self) = @_;
237 # considered { $self->{get_row} ||= $self->can('get_raw_row'); } in new()
238 # but it just seemed a little strange... this is more normal/clear
239 return $self->{get_row}
240 88 ▶ ? $self->{get_row}->($self)
Branch: 1 branch
BranchTrueFalseTotal
$self->{'get_row'} ? : 14 74 88
241 : $self->get_raw_row();
242 }
243  
244  
245 67 ▶sub get_raw_row {
Subroutine get_raw_row: called CC=1 SCAR=0.0
Pod documented
246 67 my ($self) = @_;
247 # It would be simpler to shift the data but I don't think it actually
248 # gains us anything. This way we're not modifying anything unexpectedly.
249 # Besides subclasses will likely be more useful than this one.
250 67 return $self->{data}->[ $self->{row_index}++ ];
251 }
252  
253  
254 69 ▶sub get_row {
Subroutine get_row: called CC=6 SCAR=17.9
Pod documented
255 69 my ($self) = @_;
256 69 my $row;
257  
258 GETROW: {
259 69 ▶ $row = $self->_get_custom_or_raw_row()
Branch: 1 branch
BranchTrueFalseTotal
$row = $self->_get_custom_or_raw_row or last GETROW 55 17 72
260 or last GETROW;
261  
262 # call grep_rows with the same semantics as map_rows (below)
263 55 ▶ if( $self->{grep_rows} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"grep_rows"}) 6 49 55
264 6 local $_ = $row;
265 # if grep returns false try the block again
266 redo GETROW
267 6 ▶ unless $self->{grep_rows}->($row, $self);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"grep_rows"}->($row, $self) 2 4 6
268 }
269  
270 # Send the row first since it's the important part.
271 # This isn't a method call, and $self will likely be seldom used.
272 53 ▶ if( $self->{map_rows} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"map_rows"}) 11 42 53
273 # localize $_ to the $row for consistency with the built in map()
274 11 local $_ = $row;
275 # also pass row as the first argument to simulate a normal function call
276 11 $row = $self->{map_rows}->($row, $self);
277 }
278  
279 # validate the row before passing a bad value to the DBI
280 53 ▶ $row = try {
Subroutine __ANON__: called CC=1 SCAR=0.0
281 53 $self->validate_row($row);
282 }
283 12 ▶ catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
284 # file/line position is unhelpful, but so is the newline
285 12 chomp(my $e = $_[0]);
286 # if there was an error, pass it through the handler
287 # the handler should die, return a row, or return false to skip
288 12 $self->handle_invalid_row($e, $row);
289 }
290 53 ▶ or redo GETROW;
Branch: 1 branch
BranchTrueFalseTotal
$row = &try(sub { $self->validate_row($row); } , &catch(sub { chomp(my $e = $_[0]); $self->handle_invalid_row($e, $row); } )) or redo GETROW 48 1 49
291 }
292  
293 65 return $row;
294 }
295  
296  
297 15 ▶sub handle_invalid_row {
Subroutine handle_invalid_row: called CC=4 SCAR=13.9
Pod documented
298 15 my ($self, $error, $row) = @_;
299  
300 15 ▶ if( my $handler = $self->{handle_invalid_row} ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $handler = $self->{"handle_invalid_row"}) 14 1 15
301 # should this be croak/carp?
302 14 ▶ if( $handler eq 'die' ){
Branch: 2 branches
BranchTrueFalseTotal
if ($handler eq 'die') { } 3 11 14
elsif ($handler eq 'warn') { } 1 10 11
303 3 die $error . "\n";
304 }
305 elsif( $handler eq 'warn' ){
306 1 warn $error . "\n";
307 1 return $row;
308 }
309 # otherwise it should be a coderef (or a method name (for a subclass maybe))
310 else {
311 10 return $self->$handler($error, $row);
312 }
313 }
314  
315 # pass through if no handler was defined
316 1 return $row;
317 }
318  
319  
320 12 ▶sub insert_sql {
Subroutine insert_sql: called CC=1 SCAR=0.0
Pod documented
321 12 my ($self) = @_;
322 join(' ',
323 'INSERT INTO',
324 $self->quoted_name,
325 '(',
326 12 join(', ', @{ $self->quoted_column_names } ),
327 ')',
328 'VALUES(',
329 12 join(', ', ('?') x @{ $self->columns }),
330 ')'
331 );
332 }
333  
334  
335 7 ▶sub insert_all {
Subroutine insert_all: called CC=2 SCAR=6.9
Pod documented
336 7 my ($self) = @_;
337  
338 7 my $rows = 0;
339 7 my $sth = $self->{dbh}->prepare($self->insert_sql);
340 7 ▶ while( my $row = $self->get_row() ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $self->get_row) 8 6 14
341 8 $sth->execute(@$row);
342 8 ++$rows;
343 }
344  
345 6 return $rows;
346 }
347  
348  
349 4 ▶sub load {
Subroutine load: called CC=1 SCAR=0.0
Pod documented
350 4 my ($self) = @_;
351 4 my $rows;
352  
353 # is it appropriate/sufficient to call prepare_data() from new()?
354  
355 4 ▶ try {
Subroutine __ANON__: called CC=5 SCAR=16.3
356  
357 $self->{dbh}->begin_work()
358 4 ▶ if $self->{transaction};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transaction"} 3 1 4
359  
360 $self->drop()
361 4 ▶ if $self->{drop};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"drop"} 0 4 4
362  
363 $self->create()
364 4 ▶ if $self->{create};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"create"} 4 0 4
365  
366 4 $rows = $self->insert_all();
367  
368 $self->{dbh}->commit()
369 3 ▶ if $self->{transaction};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transaction"} 2 1 3
370  
371 }
372 1 ▶ catch {
Subroutine __ANON__: called CC=2 SCAR=7.2
373 # explicitly end the transaction that we started
374 # in case this isn't the last thing being done with the dbh
375 $self->{dbh}->rollback()
376 1 ▶ if $self->{transaction};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transaction"} 1 0 1
377  
378 # propagate the exception
379 1 die $_[0];
380 4 };
381  
382 3 return $rows;
383 }
384  
385  
386 24 ▶sub name {
Subroutine name: called CC=3 SCAR=11.4
Pod documented
387 24 my ($self) = @_;
388 return $self->{_name} ||=
389 $self->{name_prefix} .
390 ($self->{name} || $self->default_name) .
391 24 ▶ $self->{name_suffix};
Condition66%4/6
$self->{"_name"} ||= $self->{"name_prefix"} . ($self->{"name"} || $self->default_name) . $self->{"name_suffix"}
l!l&&r!l&&!r
4200
$self->{'name'} || $self->default_name
l!l&&r!l&&!r
3170
MC/DC0%0/2
$self->{"_name"} ||= $self->{"name_prefix"} . ($self->{"name"} || $self->default_name) . $self->{"name_suffix"}
$self->{"_name"} $self->{"name_prefix"} . ($self->{"name"} || $self->default_name) . $self->{"name_suffix"}
MC/DC0%0/2
$self->{'name'} || $self->default_name
$self->{'name'} $self->default_name
Truth table66%2/3
A ||= B
A= $self->{"_name"}B= $self->{"name_prefix"} . ($self->{"name"} || $self->default_name) . $self->{"name_suffix"}
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $self->{'name'}B= $self->default_name
ABresult
1X1
011
000
392 }
393  
394  
395 42 ▶sub prepare_data {
Subroutine prepare_data: called CC=1 SCAR=0.0
Pod documented
396 42 my ($self) = @_;
397 42 $self->{row_index} = 0;
398 }
399  
400  
401 33 ▶sub quoted_name {
Subroutine quoted_name: called CC=2 SCAR=7.1
Pod documented
402 33 my ($self) = @_;
403 # allow quoted name to be passed in to handle edge cases
404 return $self->{quoted_name} ||=
405 $self->{dbh}->quote_identifier(
406 33 ▶ $self->{catalog}, $self->{schema}, $self->name);
Condition66%2/3
$self->{"quoted_name"} ||= $self->{"dbh"}->quote_identifier($self->{"catalog"}, $self->{"schema"}, $self->name)
l!l&&r!l&&!r
14190
MC/DC0%0/2
$self->{"quoted_name"} ||= $self->{"dbh"}->quote_identifier($self->{"catalog"}, $self->{"schema"}, $self->name)
$self->{"quoted_name"} $self->{"dbh"}->quote_identifier($self->{"catalog"}, $self->{"schema"}, $self->name)
Truth table66%2/3
A ||= B
A= $self->{"quoted_name"}B= $self->{"dbh"}->quote_identifier($self->{"catalog"}, $self->{"schema"}, $self->name)
ABresult
1X1
011
000
407 }
408  
409  
410 16 ▶sub quoted_column_names {
Subroutine quoted_column_names: called CC=2 SCAR=7.0
Pod documented
411 16 my ($self) = @_;
412 return $self->{quoted_column_names} ||= [
413 36 map { $self->{dbh}->quote_identifier($_) }
414 16 ▶ @{ $self->column_names }
Condition50%1/2
$self->{"quoted_column_names"} ||= [map({$self->{"dbh"}->quote_identifier($_);} @{$self->column_names;})]
l!l
016
MC/DC0%0/1
$self->{"quoted_column_names"} ||= [map({$self->{"dbh"}->quote_identifier($_);} @{$self->column_names;})]
$self->{"quoted_column_names"}
Truth table50%1/2
A
A= $self->{"quoted_column_names"}
Aresult
11
00
415 ];
416 }
417  
418  
419 48 ▶sub validate_row {
Subroutine validate_row: called CC=2 SCAR=6.9
Pod documented
420 48 my ($self, $row) = @_;
421  
422 # DBI will croak if exec'd with different numbers
423 48 my $num_columns = @{ $self->columns };
424  
425 48 ▶ die 'Row has ' . @$row . ' fields when ' . $num_columns . " are expected\n"
Branch: 1 branch
BranchTrueFalseTotal
if @$row != $num_columns 12 36 48
426 if @$row != $num_columns;
427  
428 # are there other validation checks we can do?
429  
430 36 return $row;
431 }
432  
433 7 1;
434  
435 __END__
↑ Summary