Branch Coverage

blib/lib/DBI/SQL/Nano.pm
Criterion Covered Total %
branch 161 252 63.8


line true false branch
34 54 0 if ($ENV{'DBI_SQL_NANO'} or not eval { do { require SQL::Statement; $SQL::Statement::VERSION ge '1.400' } }) { }
84 86 664 if (/^\s*CREATE\s+TABLE\s+(.*?)\s*\((.+)\)\s*$/is)
88 86 0 if defined $2 and $2 ne ''
89 0 86 unless $self->{'column_names'}
93 128 622 if (/^\s*DROP\s+TABLE\s+(IF\s+EXISTS\s+)?(.*?)\s*$/is)
97 76 52 if defined $1 and $1 ne ''
101 160 590 if (/^\s*SELECT\s+(.*?)\s+FROM\s+(\S+)((.*))?/is)
104 160 0 if defined $1 and $1 ne ''
105 0 160 unless $self->{'column_names'}
107 58 102 if (my $clauses = $4)
109 48 10 if ($clauses =~ /^(.*)\s+ORDER\s+BY\s+(.*)$/is)
114 10 48 if $clauses
119 214 536 if (/^\s*INSERT\s+(?:INTO\s+)?(\S+)\s*(\((.*?)\))?\s*VALUES\s*\((.+)\)/is)
123 32 182 if defined $2 and $2 ne ''
125 214 0 if defined $4 and $4 ne ''
126 0 214 unless $self->{'values'}
130 68 682 if (/^\s*DELETE\s+FROM\s+(\S+)((.*))?/is)
134 34 34 if defined $3 and $3 ne ''
138 46 704 if (/^\s*UPDATE\s+(\S+)\s+SET\s+(.+)(\s+WHERE\s+.+)/is)
141 46 0 if defined $2 and $2 ne ''
144 46 0 if defined $3 and $3 ne ''
147 48 702 unless $self->{'command'} and $self->{'table_name'}
155 36 12 if @clause == 1
156 0 12 if @clause > 2
158 12 0 if $clause[1] =~ /^ASC$/i or $clause[1] =~ /^DESC$/i
170 164 0 if ($col =~ /^(\S+?)\s+.+/) { }
206 0 46 unless $self->{'column_names'} and $self->{'values'}
212 0 652 unless defined $str
215 164 488 if ($str =~ /^\?$/)
224 12 476 if $str =~ /^NULL$/i
228 176 300 if $str =~ /^'(.+)'$/s
232 190 110 if DBI::looks_like_number($str)
245 90 0 if ($str =~ /^\s*WHERE\s+(.*)/i) { }
256 0 90 unless defined $val1 and defined $op and defined $val2
273 0 502 unless $num_placeholders == $num_params
275 64 438 if (scalar @$params)
279 120 0 if ($self->{'values'}[$i]{'type'} eq 'placeholder')
284 0 64 if ($self->{'where_clause'})
286 0 0 if ($self->{'where_clause'}{'arg1'}{'type'} eq 'placeholder')
290 0 0 if ($self->{'where_clause'}{'arg2'}{'type'} eq 'placeholder')
315 40 32 if ($self->{'ignore_missing_table'} and $@ || @err and grep {$_ =~ /$enoentrx/;} @err, $@)
321 8 72 if $@ or @err
322 0 72 unless $table
342 134 0 unless $table->can('insert_one_row')
345 0 134 unless $self->{'column_names'}
346 134 0 if $self->{'column_names'}
349 0 134 unless $cNum
361 0 134 if $#$array < $maxCol
363 128 6 $table->can('insert_new_row') ? :
378 60 42 if ($self->eval_where($table, $array)) { }
381 8 52 if ($self->{'fetched_from_key'})
387 48 4 if $can_dor
391 2 40 unless $can_dor
394 16 4 if ($can_dor) { }
417 0 64 if (not defined $a && defined $b) { }
64 0 elsif (DBI::looks_like_number($a) and DBI::looks_like_number($b)) { }
427 0 0 $case_fold ? :
441 202 0 if ($self->eval_where($table, $array))
443 0 202 if $self->{'fetched_from_key'}
444 96 106 unless (keys %cols)
463 0 202 if $self->{'fetched_from_key'}
466 32 64 if ($self->{'order_clause'})
470 8 24 uc $desc eq 'DESC' ? :
480 40 24 if $desc
493 0 34 unless $table
502 58 2 if ($self->eval_where($table, $array)) { }
504 8 50 if $self->{'fetched_from_key'} and $can_rwu
505 56 2 if $can_usr
512 8 50 if ($self->{'fetched_value'})
514 8 0 if ($can_usr) { }
0 0 elsif ($can_uor) { }
524 48 2 $can_usr ? :
528 2 0 unless $can_rwu
531 24 2 if ($can_rwu) { }
535 48 0 if ($can_usr) { }
0 0 elsif ($can_uor) { }
562 54 238 if ($self->{'where_clause'})
564 54 0 if (my $col = $self->{'where_clause'}{'arg1'})
566 54 0 if $col->{'type'} eq 'column'
568 54 0 if (my $col = $self->{'where_clause'}{'arg2'})
570 0 54 if $col->{'type'} eq 'column'
585 916 128 if ($stmt_col_name and not $find_in_stmt)
589 916 457 if uc $k eq uc $stmt_col_name
593 32 96 if ($stmt_col_name and $find_in_stmt)
597 32 0 if uc $stmt_col_name eq uc $self->{'column_names'}[$i]
605 178 166 if uc $dbd_cols[$i] eq uc $stmt_col
629 130 0 if ($val1->{'type'} eq 'column') { }
638 0 130 if ($val2->{'type'} eq 'column') { }
648 120 10 if ($op eq '=' and not $neg and $table->can('fetch_one_row'))
651 16 104 if ($pred->{'arg1'}{'value'} =~ /^$key_col$/i)
659 0 0 $match ? :
0 114 if ($neg)
666 0 114 if ($op eq 'IS')
668 0 0 if not defined $val1 or $val1 eq ''
671 0 114 unless defined $val1
672 0 114 unless defined $val2
673 0 114 if ($op =~ /LIKE|CLIKE/i)
679 0 114 if ($op eq 'LIKE')
680 0 114 if ($op eq 'CLIKE')
681 2 112 if (DBI::looks_like_number($val1) and DBI::looks_like_number($val2)) { }
683 0 2 if ($op eq '<')
684 0 2 if ($op eq '>')
685 2 0 if ($op eq '=')
686 0 0 if ($op eq '<>')
687 0 0 if ($op eq '<=')
688 0 0 if ($op eq '>=')
692 0 112 if ($op eq '<')
693 0 112 if ($op eq '>')
694 112 0 if ($op eq '=')
695 0 0 if ($op eq '<>')
696 0 0 if ($op eq '<=')
697 0 0 if ($op eq '>=')
704 1490 216 unless ($self->{'params'})
705 0 216 if (defined $val_num)
710 0 216 wantarray ? :
719 72 430 if ($@)
724 0 430 unless $table
725 260 170 if (not $self->{'column_names'} or $self->{'column_names'}[0] eq '*')
735 0 326 unless ($self->{'values'})
736 326 0 if (defined $val_num)
740 0 0 if (wantarray) { }
754 470 952 if ($self->{'column_names'} and $self->{'column_names'}[0] ne '*')
773 0 430 unless defined $self->{'col_names'} and 'ARRAY' eq ref $self->{'col_names'}
774 430 0 unless exists $self->{'col_nums'}
776 0 430 unless defined $self->{'col_nums'} and 'HASH' eq ref $self->{'col_nums'}
788 0 668 unless $col_names->[$i]