Branch Coverage

blib/lib/ActiveRecord/Simple.pm
Criterion Covered Total %
branch 129 218 59.1


line true false branch
26 0 141 scalar @_ > 1 ? :
28 140 1 $class->can('_get_columns') ? :
30 84 57 if ($class->can('_get_mixins'))
36 126 15 if ($class->can('_get_relations'))
45 125 15 if $class->can($pkg_method_name)
54 5 10 if (@objects)
55 4 1 if ($relation->{'type'} eq 'many') { }
1 0 elsif ($relation->{'type'} eq 'one') { }
56 1 3 if ($objects[0] and &blessed($objects[0])) { }
78 0 1 unless ref $object and grep {$relation->{'type'} eq $_;} 'one', 'many'
81 0 1 unless my $pk = $relation->{'params'}{'pk'}
82 0 1 unless my $fk = $relation->{'params'}{'fk'}
91 8 2 unless ($$self{"relation_instance_$relname"})
98 4 4 ref $rel->{'class'} eq 'HASH' ? :
106 6 6 ref $rel_opts->{'class'} eq 'HASH' ? :
107 8 4 if $rel_opts_class eq $class
110 2 6 if ($type eq 'one_to_many' or $type eq 'one_to_one' or $type eq 'one_to_only') { }
0 6 elsif ($type eq 'only_to_one') { }
2 4 elsif ($type eq 'many_to_one') { }
4 0 elsif ($type eq 'many_to_many') { }
0 0 elsif ($type eq 'generic_to_generic') { }
125 0 2 unless $self->can('_get_primary_key')
175 0 8 unless $table_info_sth->fetchrow_hashref
186 6 2 $primary_key_data ? :
191 8 0 if $table_name
192 6 2 if $primary_key
193 8 0 if @columns
205 0 141 unless $fields
211 558 50 if $class->can($pkg_accessor_name)
213 13 81 if (scalar @_ > 1)
230 0 84 unless $fields
237 83 1 if $class->can($pkg_accessor_name)
239 0 2 if scalar @_ > 1
255 0 0 unless $error_message
258 4 0 unless exists $options->{'HandleError'}
260 4 0 if ($@) { }
293 0 9 if ($class->can('_get_table_schema') and $class->can('_get_primary_key'))
336 22 22 if $what_key eq 'primary_key'
341 22 0 if $what_key eq 'foreign_key'
343 22 0 $what_key eq 'foreign_key' ? :
349 0 0 if $_ =~ /$rx/
383 0 0 unless eval { do { require SQL::Translator } }
386 0 0 unless $class->can('_get_table_schema')
413 7 15 if ($class->can('_get_relations')) { }
431 11 7 if (scalar @args == 1) { }
7 0 elsif (scalar @args > 1) { }
433 11 0 if (ref $arg and ref $arg eq 'ARRAY') { }
0 0 elsif (ref $arg and ref $arg eq 'HASH') { }
461 0 0 unless eval { do { require SQL::Translator } }
480 0 0 if ($class->can('_get_table_schema'))
492 0 15 if $class->can('_get_table_schema')
509 13 24 ref $_[0] ? :
511 0 37 if $class =~ /^ActiveRecord::Simple/
513 36 1 $class->can('_get_table_name') ? :
524 1 141 unless defined $is_on
544 82 134 if (not $class->can($pkg_method_name))
553 3 314 if ($dbh)
554 0 3 if ($connector) { }
570 0 11 unless $self->dbh
574 0 0 if $self->_smart_saving_used and defined $self->{'snapshoot'} and $self->{'snapshoot'} eq freeze($self->to_hash)
577 0 11 if exists $self->{'read_only'} and $self->{'read_only'} == 1
582 10 1 $self->can('_get_primary_key') ? :
586 3 36 if defined $pkey and $field eq $pkey and not $self->{$pkey}
587 0 38 if ref $field and ref $field eq 'HASH'
593 41 3 unless ref $self->{$field}
594 0 3 unless $self->can('_get_relations')
595 2 1 unless grep {$_ eq $field;} keys %{$self->_get_relations;}
597 0 1 unless my $relation = $self->_get_relations->{$field}
598 0 1 unless $relation->{'type'} and $relation->{'type'} eq 'one'
607 4 7 if ($self->{'isin_database'}) { }
613 11 0 if $result
614 11 0 if $result
616 11 0 defined $result ? :
625 0 0 unless exists $params->{$field}
626 0 0 unless $params->{$field}
637 0 7 unless $self->dbh and $param
641 0 1 $self->can('_get_secondary_key') ? :
6 1 $self->can('_get_primary_key') ? :
648 1 19 if (ref $param->{$_} eq 'SCALAR') { }
663 0 7 if ($self->dbh->{'Driver'}{'Name'} eq 'Pg') { }
664 0 0 if ($primary_key) { }
665 0 0 if $primary_key
683 3 4 if ($primary_key and defined $self->{$primary_key}) { }
691 6 0 if (defined $primary_key and $self->can($primary_key) and $pkey_val)
702 0 4 unless $self->dbh and $param
706 0 0 $self->can('_get_secondary_key') ? :
4 0 $self->can('_get_primary_key') ? :
711 0 17 if (ref $param->{$_} eq 'SCALAR') { }
739 0 2 unless $self->dbh
744 0 2 unless $self->{$pkey}
749 0 0 if $param and $param->{'cascade'}
754 2 0 if ($self->dbh->do($sql, undef, $self->{$pkey}))
777 2 1 if $self->can('_get_mixins')
781 0 15 if ref $field
782 7 8 if ($param and $param->{'only_defined_fields'}) { }
783 3 4 if defined $self->$field
798 0 0 unless exists $self->{$field}
810 0 0 unless exists $self->{$field}
827 0 0 if (ref $first_arg) { }
832 0 0 if ($class eq 'ActiveRecord::Simple::Find') { }
843 0 0 defined $class->find(@search_criteria)->fetch ? :
864 0 2 unless &blessed($self)
865 1 1 unless $param
867 0 1 unless $self->can('_get_relations')
874 1 1 unless $relation->{'type'} eq 'many' and ref $relation->{'class'} eq 'HASH'
876 0 1 unless $subclass->can('_get_relations')
880 0 2 unless exists $relations2->{$rel_name}
885 0 2 unless $pk and $fk
887 1 1 $rel_name eq $sub ? :