Branch Coverage

blib/lib/ClearPress/model.pm
Criterion Covered Total %
branch 79 148 53.3


line true false branch
29 0 31 $EXPERIMENTAL_PL ? :
43 1 45 unless ($tbl)
58 1 76 unless (ref $ref)
59 1 0 if ($pk) { }
71 0 0 if ($sk and $ref->{$sk} and not $ref->{$pk})
82 0 0 unless (eval { do { my $id = $dbh->selectall_arrayref("/* model::new */ SELECT $pk FROM $table WHERE $sk=?", {}, $ref->{$sk})->[0][0]; $ref->{$pk} = $id; 1 } })
96 1 58 unless (ref $self)
107 1 57 if ($util)
112 54 3 if ($self->{'util'})
125 1 2 unless (eval { do { my $ns = "${ref}::util"; $nsutil = $ns->new } })
129 2 1 if ($nsutil)
151 18 80 unless (exists $self->{$field})
162 0 9 unless (ref $self)
180 0 9 unless (eval { do { my $dbh = $util->dbh; $sth = $dbh->prepare($query); $sth->execute(@args); 1 } })
183 0 0 defined $_ ? :
200 6 0 unless ($cachekey)
205 6 0 unless ($self->{$cachekey})
207 6 0 unless ($sortk)
226 0 1 unless ($cachekey)
231 1 0 unless ($self->{$cachekey})
250 0 4 unless ($cachekey)
255 1 3 unless ($self->{$cachekey})
292 2 0 unless ($cachekey)
296 1 1 unless ($self->{$cachekey})
330 5 4 if (ref $attr ne 'ARRAY')
337 0 9 if (ref $single eq 'HASH')
344 0 9 unless ($yield =~ /model/msx)
350 0 9 if (defined &{$namespace;})
373 5 0 if (ref $attr ne 'ARRAY')
380 4 1 if (ref $single eq 'HASH')
390 0 5 unless ($yield =~ /model/msx)
394 0 5 if (defined &{$namespace;})
416 4 0 if (ref $attr ne 'ARRAY')
423 0 4 if (ref $single eq 'HASH')
432 0 4 unless ($through)
440 0 4 unless ($yield =~ /model/msx)
444 0 4 if (defined &{$namespace;})
461 4 0 if (ref $attr ne 'ARRAY')
468 0 4 if (ref $single eq 'HASH')
477 0 4 unless ($through)
486 0 4 unless ($yield =~ /model/msx)
490 0 4 if (defined &{$namespace;})
512 0 16 if (defined &{$namespace;})
533 0 16 unless ($table)
540 16 0 unless ($self->$pk)
555 0 16 unless (eval { do { my $drv = $util->driver; my $id = $drv->create($query, @args); $self->$pk($id) } })
556 0 0 if $tr_state
557 0 0 defined $_ ? :
562 16 0 if $tr_state
565 0 16 unless (eval { do { $dbh->commit if $tr_state; 1 } })
566 0 0 if $tr_state
578 16 9 unless ($query or $self->{$pk})
584 0 9 unless ($table)
588 9 0 unless ($self->{'_loaded'})
589 9 0 unless ($query)
605 1 8 unless ($sth->rows)
616 8 0 if (not $warnings) { }
629 1 8 unless (eval { do { my $sth = $util->dbh->prepare($query); $sth->execute(@args); my $ref = $sth->fetchrow_hashref; unless ($sth->rows) { $sth->finish; croak('missing entity'); } ; $sth->finish; my $warnings = $util->driver->sth_has_warnings($sth); if (not $warnings) { foreach my $f ($self->fields) { $self->{$f} = $ref->{$f}; } ; } else { foreach my $w (@{$warnings;}) { carp("ClearPress::model::read: mysql warning: $w->[2]"); } ; } ; 1 } })
630 1 0 if ($ClearPress::model::EVAL_ERROR =~ /missing\sentity/msx)
633 0 0 defined $_ ? :
644 0 4 unless ($pk and $self->$pk)
649 0 4 unless ($table)
670 0 4 unless (eval { do { $dbh->do($query, {}, map({$self->$_;} @fields), $self->$pk) } })
671 0 0 if $tr_state
676 4 0 if $tr_state
679 0 4 unless (eval { do { $dbh->commit if $tr_state; 1 } })
693 0 1 unless ($pk and $self->$pk)
705 0 1 unless (eval { do { $dbh->do($query, {}, $self->$pk) } })
706 0 0 if $tr_state
711 1 0 if $tr_state
714 0 1 unless (eval { do { $dbh->commit if $tr_state; 1 } })
725 0 0 if ($pk and defined $self->{$pk})
736 0 1 if (scalar grep({$_ eq 'date';} $self->fields))
742 1 0 unless ($date)