Branch Coverage

blib/lib/Rose/DB/Object/Metadata.pm
Criterion Covered Total %
branch 296 868 34.1


line true false branch
232 0 99 unless my $class = $args{'class'}
249 0 75 $ENV{'MOD_PERL'} ? :
255 12 66 if (ref $self_or_class)
281 0 0 if (defined $Scalar::Util::Clone::VERSION)
303 0 0 $meta->num_columns > 0 ? :
309 1 98 if $Objects{$class}
314 0 198 if (my $parent_meta = $Objects{$parent_class})
316 0 0 unless $meta_class->allow_inheritance_from_meta($parent_meta)
338 100 98 if $sub_class->isa('Rose::DB::Object')
356 0 0 unless @_ > 1
361 0 0 unless ($mode =~ /^(?:return|carp|croak|cluck|confess|fatal)$/)
377 0 0 if $mode eq 'return'
382 0 0 if ($mode eq 'croak' or $mode eq 'fatal') { }
0 0 elsif ($mode eq 'carp') { }
0 0 elsif ($mode eq 'cluck') { }
0 0 elsif ($mode eq 'confess') { }
410 0 5 if $self->is_initialized
419 0 9 if (ref $method eq 'CODE')
427 0 9 if ($method =~ /^((?:auto_(?!helper)|(?:default_)?perl_)\w*)$/)
432 0 9 if ($method eq 'initialize') { }
0 9 elsif ($method eq 'auto_initialize' or $method eq 'auto') { }
0 9 elsif ($method eq 'helpers') { }
434 0 0 ref $args ? :
439 0 0 unless ($method eq 'auto' and not ref $args)
441 0 0 ref $args ? :
451 0 0 ref $args eq 'ARRAY' ? :
457 0 9 unless ($self->can($method))
462 9 0 if (ref $args eq 'ARRAY') { }
467 0 9 if ($method eq 'unique_key' || $method eq 'add_unique_key' and not grep({ref $_;} @$args)) { }
483 0 5 if ($auto_init) { }
499 0 235 unless my $class = $self->class
501 0 235 unless my $db = $self->class->init_db
523 3 429 if (@_)
528 0 3 if (not defined $mgr) { }
3 0 elsif (not ref $mgr) { }
0 0 elsif (not UNIVERSAL::isa($mgr, 'Rose::DB::Object::ConventionManager')) { }
535 1 2 if (UNIVERSAL::isa($mgr, 'Rose::DB::Object::ConventionManager')) { }
541 1 1 unless my $class = $self->convention_manager_class($mgr)
556 336 93 if (defined $self->{'convention_manager'})
572 0 0 @_ > 1 ? :
578 0 0 @_ > 1 ? :
584 0 0 @_ > 1 ? :
590 0 0 @_ > 1 ? :
596 0 0 @_ > 1 ? :
603 0 0 @_ > 1 ? :
611 0 0 unless ref $options eq 'HASH'
622 171 5 unless (@_ > 1)
633 0 0 unless @_ > 1
641 77 0 if $db and not $db->supports_catalog
647 0 0 unless @_ > 1
655 5 72 if $db and not $db->supports_schema
663 99 0 if (@_)
665 0 99 $_[0] ? :
668 0 99 if ($value != $self->{'sql_qualify_column_names_on_load'})
672 0 0 if $self->is_initialized
686 0 0 wantarray ? :
703 0 0 if ($self->{'primary_key_column_names_or_aliases'})
709 0 0 unless $_->alias
721 6 82 unless my $column = $self->column($col_name)
751 0 0 if (@_ == 1 and ref $_[0] eq 'ARRAY') { }
760 0 0 ref $_ eq 'HASH' ? :
0 0 UNIVERSAL::isa($_, 'Rose::DB::Object::Metadata::UniqueKey') ? :
778 0 0 if $uk->name eq $name
793 0 229 if (@_)
799 152 77 wantarray ? :
805 120 0 wantarray ? :
818 0 0 if ($columns->[$i]->name eq $name)
854 0 0 if ($columns->[$i]->name eq $name)
876 0 79 unless ($columns{$col_name})
891 0 0 unless ($columns{$col_name})
911 0 0 unless (@_ == 2)
913 0 0 if @_ < 2
914 0 0 if @_ < 2
924 0 3076 if (@_)
930 2995 81 if $self->{'columns'}{$name}
938 0 0 if (@_)
944 0 0 if $self->{'nonpersistent_columns'}{$name}
953 82 12 if (@_)
966 0 0 if (@_)
987 0 0 wantarray ? :
996 0 0 wantarray ? :
1030 1 218 if (UNIVERSAL::isa($name, 'Rose::DB::Object::Metadata::Column'))
1034 0 1 unless $column->name =~ /\S/
1038 0 1 if $Nonpersistent
1040 0 1 if ($column->nonpersistent) { }
1054 166 52 unless (ref $_[0])
1056 0 166 unless my $column_class = $self->original_class->column_type_class('scalar')
1065 0 52 if (UNIVERSAL::isa($_[0], 'Rose::DB::Object::Metadata::Column')) { }
52 0 elsif (ref $_[0] eq 'HASH') { }
1071 0 0 if $Nonpersistent
1073 0 0 if ($column->nonpersistent) { }
1090 3 49 if ($info->{'primary_key'})
1099 0 52 if ($methods and $add_methods)
1107 0 52 unless my $column_class = $self->original_class->column_type_class($type)
1110 24 28 unless ($self->column_class_is_loaded($column_class))
1119 3 361 if exists $info->{$event}
1122 0 52 if (delete $info->{'temp'})
1133 0 52 if $Nonpersistent
1135 0 52 if ($column->nonpersistent) { }
1147 0 52 if ($methods or $add_methods)
1149 0 0 $methods ? :
1154 0 0 if (ref $methods_arg eq 'HASH') { }
1160 0 0 unless defined $name
1172 0 52 if (defined $alias)
1178 2 50 if (%triggers)
1182 0 3 unless $value
1185 1 2 ref $value eq 'ARRAY' ? :
1203 219 0 if ($column->can('smart_modification') and not defined $column->{'smart_modification'})
1209 85 0 if (@columns)
1215 0 85 if (@nonpersistent_columns)
1221 0 85 wantarray ? :
1228 1 56 if (@_)
1234 25 32 if $self->{'relationships'}{$name}
1249 26 175 if (@_)
1257 175 26 wantarray ? :
1265 26 0 unless $self->{'relationships'}
1268 0 0 unless $self->{'relationships'}{$name}->foreign_key
1285 32 42 if (UNIVERSAL::isa($name, 'Rose::DB::Object::Metadata::Relationship'))
1289 0 32 unless $relationship->name =~ /\S/
1292 0 32 if (defined $self->{'relationships'}{$relationship->name})
1304 15 27 unless (ref $_[0])
1312 1 26 if (UNIVERSAL::isa($_[0], 'Rose::DB::Object::Metadata::Relationship')) { }
26 0 elsif (ref $_[0] eq 'HASH') { }
1324 0 26 if (defined $self->{'relationships'}{$name})
1332 0 26 if ($methods and $add_methods)
1338 0 26 unless my $type = $info->{'type'}
1347 0 26 if ($methods or $add_methods)
1349 0 0 $methods ? :
1354 0 0 if (ref $methods_arg eq 'HASH') { }
1360 0 0 unless defined $name
1384 0 26 unless my $name = $args{'name'}
1385 0 26 unless my $info = $args{'info'}
1386 0 26 unless my $type = $args{'type'}
1389 0 26 unless my $relationship_class = $class->relationship_type_class($type)
1392 5 21 unless ($self->relationship_class_is_loaded($relationship_class))
1397 0 26 if $Debug
1402 0 26 unless ($relationship)
1421 21 3 unless (UNIVERSAL::isa($column_class, 'Rose::DB::Object::Metadata::Column'))
1432 0 21 if $error
1466 0 5 if $error
1483 26 32 if (UNIVERSAL::isa($name, 'Rose::DB::Object::Metadata::ForeignKey'))
1487 0 26 unless $fk->name =~ /\S/
1490 0 26 if (defined $self->{'foreign_keys'}{$fk->name})
1500 26 0 unless (defined $self->relationship($fk->name))
1514 26 6 unless (ref $_[0])
1516 26 0 if (my $fk = $self->convention_manager->auto_foreign_key($name)) { }
1530 6 0 if (ref $_[0] eq 'HASH') { }
1534 0 6 if (defined $self->{'foreign_keys'}{$name})
1542 0 6 if ($methods and $add_methods)
1548 0 6 if $Debug
1556 0 6 if ($methods or $add_methods)
1558 0 0 $methods ? :
1563 0 0 if (ref $methods_arg eq 'HASH') { }
1569 0 0 unless defined $name
1581 6 0 unless (defined $self->relationship($name))
1603 0 4 if (@_)
1609 4 0 if $self->{'foreign_keys'}{$name}
1630 0 0 if ($rel->foreign_key eq $fk)
1647 18 277 if (@_)
1655 277 18 wantarray ? :
1663 0 77 if $Debug
1665 0 77 if (my $code = $self->pre_init_hook)
1667 0 0 ref $code eq 'ARRAY' ? :
1673 0 77 unless my $class = $self->class
1679 0 77 unless defined $table and $table =~ /\S/
1683 0 77 unless @pk
1688 0 77 unless @column_names
1693 0 79 unless my $column = $self->column($name)
1696 0 79 if ($column->is_lazy)
1707 76 0 unless ($args{'passive'})
1717 75 0 unless ($args{'stay_connected'})
1724 0 75 if $Debug
1726 0 75 if (my $code = $self->post_init_hook)
1728 0 0 ref $code eq 'ARRAY' ? :
1738 0 75 if $self->auto_prime_caches
1750 0 76 unless my $class = $self->class
1756 76 0 $db ? :
1759 76 0 unless defined $catalog
1760 75 1 unless defined $schema
1762 76 0 $db ? :
1764 0 76 unless my $table = $self->table
1767 71 5 if $db->likes_lowercase_table_names
1785 71 5 if defined $default_schema
1799 152 0 wantarray ? :
1813 1 1 ref $self_or_class ? :
1816 1 1 $self ? :
1821 2 0 unless defined $catalog
1822 2 0 unless defined $schema
1824 1 1 $db ? :
1825 1 1 unless defined $default_schema
1827 0 2 unless my $table = $args{'table'}
1830 1 1 if $db and $db->likes_lowercase_table_names
1847 0 2 unless ($f_class)
1884 0 194 unless ($column->validate_specification)
1896 0 194 unless $method = $self->method_name_from_column_name($name, $type)
1900 1 193 if (my $reason = $self->method_name_is_reserved($method, $class))
1978 0 0 unless ($column->validate_specification)
1990 0 0 unless $method = $self->method_name_from_column_name($name, $type)
1994 0 0 if (my $reason = $self->method_name_is_reserved($method, $class))
2040 0 64 if (my $reason = $self->method_name_is_reserved($method, $class))
2049 32 0 if ($self->auto_load_related_classes and my $fclass = $foreign_key->class)
2051 0 32 unless ($fclass->isa('Rose::DB::Object'))
2062 0 0 if $Debug
2064 0 0 if ($error)
2067 0 0 unless ($error =~ /\.pm in \@INC/ or UNIVERSAL::isa($error, 'Rose::DB::Object::Exception::ClassNotReady'))
2077 20 12 if ($foreign_key->is_ready_to_make_methods) { }
2079 0 20 if ($Debug and not $args{'preserve_existing'})
2093 0 12 if $Debug
2105 0 60 unless $relationship->type eq $fk_rel_type
2107 32 28 if ($fk_id eq $relationship->id)
2123 0 0 wantarray ? :
2135 0 0 if $arg->{'class'} eq $task->{'class'} and $arg->{'method'} eq $task->{'method'}
2154 0 0 if ($task->{'class'} eq $class)
2176 0 0 unless (&$check())
2182 0 76 if (join(',', sort(@Deferred_Tasks)) ne join(',', sort(@tasks)))
2192 152 0 wantarray ? :
2204 0 0 if $fk->class eq $class
2210 0 0 if ($task->{'class'} eq $class and $task->{'method'} eq 'auto_init_foreign_keys')
2223 12 0 if @_
2225 0 0 if (defined $self->{'has_outstanding_metadata_tasks'})
2230 0 0 if ($self->has_deferred_foreign_keys or $self->has_deferred_relationships or $self->has_deferred_tasks)
2250 0 0 if $fk->id eq $arg->id
2279 12 24 if ($foreign_key->is_ready_to_make_methods) { }
2281 0 12 if $Debug
2294 12 140 if (join(',', sort(@Deferred_Foreign_Keys)) ne join(',', sort(@foreign_keys)))
2303 4926 0 unless $meta->allow_auto_initialization and $meta->has_outstanding_metadata_tasks
2304 0 0 unless $meta->auto_init_args
2325 0 58 if $args{'name'} and $relationship->name ne $args{'name'}
2336 0 134 if (my $reason = $self->method_name_is_reserved($method, $class))
2345 0 134 if ($self->is_auto_initializating)
2350 46 88 if $args{'preserve_existing'}
2356 134 0 if ($relationship->can('id'))
2362 64 28 if ($rel_id eq $fk->id)
2372 58 0 if ($self->auto_load_related_classes)
2374 44 14 if ($relationship->can('class'))
2378 12 32 unless ($fclass->isa('Rose::DB::Object') and $fclass->meta->is_initialized)
2389 0 12 if $Debug
2392 12 0 if ($error)
2395 0 0 unless ($error =~ /\.pm in \@INC/ or UNIVERSAL::isa($error, 'Rose::DB::Object::Exception::ClassNotReady'))
2404 14 44 if ($relationship->can('map_class'))
2408 2 12 unless ($map_class->isa('Rose::DB::Object') and $map_class->meta->is_initialized)
2419 0 2 if $Debug
2422 2 0 if ($error)
2425 0 0 unless ($error =~ /\.pm in \@INC/ or UNIVERSAL::isa($error, 'Rose::DB::Object::Exception::ClassNotReady'))
2437 44 14 if ($relationship->is_ready_to_make_methods) { }
2 12 elsif (not $relationship->can('foreign_key') && $relationship->foreign_key) { }
2439 0 44 if ($Debug and not $args{'preserve_existing'})
2453 0 2 if $Debug
2469 76 0 wantarray ? :
2481 0 0 if ($rel->can('class') and $rel->class eq $class or $rel->can('map_class') and $rel->map_class eq $class)
2491 0 0 if ($task->{'class'} eq $class and $task->{'method'} eq 'auto_init_relationships')
2508 0 1 if $rel->id eq $arg->id
2535 7 0 if ($rebuild_rel)
2542 2 5 if ($relationship->is_ready_to_make_methods) { }
2544 0 2 if $Debug
2563 1 74 if (join(',', sort(@Deferred_Relationships)) ne join(',', sort(@relationships)))
2590 0 0 if (my $code = $self->primary_key_generator)
2599 0 0 if ($seqs and @$seqs) { }
2607 0 0 unless (defined $seq)
2615 0 0 unless ($id)
2651 0 84 if ($self->{'primary_key_column_accessor_names'})
2659 6 78 unless @column_names == @columns
2664 77 1 unless @methods
2674 0 84 if ($self->{'primary_key_column_mutator_names'})
2682 6 78 unless @column_names == @columns
2687 77 1 unless @methods
2699 0 0 if (defined $self->{'fq_primary_key_sequence_names'}{$db_id})
2701 0 0 unless my $seqs = $self->{'fq_primary_key_sequence_names'}{$db_id}
2702 0 0 wantarray ? :
2705 0 0 unless my $db = $args{'db'}
2710 0 0 if (@seqs)
2718 0 0 if (defined $seq and index($seq, '.') < 0)
2726 0 0 wantarray ? :
2735 0 0 UNIVERSAL::isa($db, 'Rose::DB') ? :
2747 0 0 if UNIVERSAL::isa($_[0], 'Rose::DB')
2748 0 0 $db ? :
2751 0 0 if (@_)
2756 0 0 @_ == 1 && ref $_[0] ? :
2760 0 0 $db ? :
2762 0 0 wantarray ? :
2765 0 0 if ($self->{'primary_key_sequence_names'}{$db_id})
2768 0 0 wantarray ? :
2779 0 0 if ($seqs)
2782 0 0 if (@pks == grep({defined $_;} @$seqs)) { }
2785 0 0 wantarray ? :
2793 0 0 unless ($db)
2800 0 0 unless my $table = $self->table
2813 0 0 if ($column->type eq 'scalar') { }
0 0 elsif ($column->type =~ /^(?:big)?serial$/ and $db->use_auto_sequence_name) { }
2827 0 0 unless (exists $seqs[$i] and defined $seqs[$i])
2829 0 0 if defined $seq
2836 0 0 if ($self->is_initialized)
2841 0 0 wantarray ? :
2849 0 0 unless $db->driver eq 'pg'
2851 0 0 if $db->likes_lowercase_table_names
2866 0 0 unless my $sth = $dbh->column_info($catalog, $schema, $table, $column)
2876 0 0 if $error or not $col_info
2885 0 0 if (defined $seq and defined $implicit_schema and not defined $schema)
2897 537 0 wantarray ? :
2904 76 0 wantarray ? :
2911 0 0 wantarray ? :
2918 0 0 wantarray ? :
2944 0 0 wantarray ? :
2969 0 0 unless ($list)
2973 0 0 if ($self->sql_qualify_column_names_on_load) { }
2985 0 0 wantarray ? :
2994 0 0 unless ($list)
2998 0 0 if ($self->sql_qualify_column_names_on_load) { }
3010 0 0 wantarray ? :
3017 0 0 unless (defined $self->{'method_columns'})
3023 0 0 if (my $method = $column->method_name($type))
3042 0 154 wantarray ? :
3053 0 153 wantarray ? :
3064 0 76 wantarray ? :
3075 0 0 wantarray ? :
3086 0 153 wantarray ? :
3097 0 0 wantarray ? :
3108 0 0 wantarray ? :
3119 0 0 wantarray ? :
3130 0 0 wantarray ? :
3141 0 0 wantarray ? :
3148 0 1 unless @_ == 3
3152 0 1 unless $self->{'columns'}{$name}
3154 0 1 unless $name ne $new_name
3169 1 0 if (my $column = $self->column($name))
3179 116 0 unless @_ > 1
3180 0 0 ref $_[1] eq 'HASH' ? :
3185 499 0 $_[0]->column($_[1]) ? :
3191 0 0 $_[0]->nonpersistent_column($_[1]) ? :
3203 0 75 if $self->{'key_column_accessor_method'}
3223 267 0 $_[0]->column($_[1]) ? :
3229 0 0 $_[0]->nonpersistent_column($_[1]) ? :
3284 0 0 $self->sql_qualify_column_names_on_load ? :
3304 0 0 $self->sql_qualify_column_names_on_load ? :
3327 0 0 $fq ? :
0 0 defined $$key_values[$i++] ? :
3349 0 0 $fq ? :
0 0 defined $$key_values[$i++] ? :
3364 0 0 if $self->{'update_all_sql'}{$cache_key}
3398 0 0 if not $key{$_->name}
3403 0 0 unless ($self->dbi_requires_bind_param($db))
3447 0 0 unless $obj->{'__xrdbopriv_modified_columns'}
3449 0 0 unless @modified
3539 0 0 unless my $db = $obj->db
3550 0 0 if not $key{$_}
3556 0 0 if ($column->should_inline_value($db, $value)) { }
3566 0 0 if ($do_bind_params)
3583 0 0 $do_bind_params ? :
3603 0 0 unless my $db = $obj->db
3615 0 0 if not $key{$_->{'name'}}
3620 0 0 if ($column->should_inline_value($db, $value)) { }
3630 0 0 if ($do_bind_params)
3637 0 0 unless @updates
3649 0 0 $do_bind_params ? :
3675 0 0 unless $$modified{$_->{'name'}}
3677 0 0 unless (@modified)
3682 0 0 if ($db->supports_arbitrary_defaults_on_insert) { }
3727 0 0 if ($obj->{'__xrdbopriv_in_db'}) { }
3734 0 0 unless $obj->{'__xrdbopriv_modified_columns'}
3735 0 0 unless not $_->{'lazy'}
0 0 $changes_only ? :
3754 0 0 unless (@key_values)
3765 0 0 unless (@key_values)
3772 0 0 unless $obj->{'__xrdbopriv_modified_columns'}
3773 0 0 $changes_only ? :
3774 0 0 if not $skip{"$_"}
3805 0 0 unless my $db = $obj->db
3816 0 0 if ($column->should_inline_value($db, $value)) { }
3825 0 0 if ($do_bind_params)
3834 0 0 $do_bind_params ? :
3859 0 0 if ($obj->{'__xrdbopriv_in_db'}) { }
3866 0 0 unless $obj->{'__xrdbopriv_modified_columns'}
3867 0 0 unless not $_->{'lazy'}
0 0 $changes_only ? :
3880 0 0 unless (@key_values)
3891 0 0 unless (@key_values)
3898 0 0 unless $obj->{'__xrdbopriv_modified_columns'}
3899 0 0 $changes_only ? :
3900 0 0 if not $skip{"$_"}
3913 0 0 if ($column->should_inline_value($db, $value)) { }
3922 0 0 if ($do_bind_params)
3935 0 0 $do_bind_params ? :
3944 0 0 unless my $db = $obj->db
3947 0 0 unless $$modified{$_->{'name'}}
3949 0 0 unless (@modified)
3954 0 0 if ($db->supports_arbitrary_defaults_on_insert) { }
3977 0 0 if ($column->should_inline_value($db, $value)) { }
3986 0 0 if ($do_bind_params)
3996 0 0 $do_bind_params ? :
4017 0 0 unless my $db = $object->db
4018 0 0 unless my $dbh = $db->dbh
4038 0 0 if $Debug or $Rose::DB::Object::Debug
4048 0 0 if ($error)
4091 0 0 if defined $self->{'has_lazy_columns'}
4243 0 392 if (not defined $class and UNIVERSAL::isa($self, 'Rose::DB::Object::Metadata'))
4245 0 0 unless $class ||= $self->class
4248 0 392 unless defined $name
4251 0 392 if (index($name, '__xrdbopriv') == 0) { }
1 782 elsif ($name =~ /^(?:meta|dbh?|_?init_db|error|not_found|load|save|update|insert|delete|DESTROY)$/ or $class->isa('Rose::DB::Object::Cached') and $name =~ /^(?:remember|forget(?:_all)?)$/) { }
4268 0 194 unless my $column = $self->column($column_name) || $self->nonpersistent_column($column_name)
4285 0 194 if (my $code = $self->column_name_to_method_name_mapper)
4291 0 0 unless (defined $method_name)
4306 0 0 if defined $self->{'dbi_requires_bind_param'}{$db->{'id'}}
4310 0 0 if ($column->dbi_requires_bind_param($db))
4332 1 1 if ($error)
4345 0 3 if (@_ == 1) { }
4357 0 3 unless ($args{'class'} =~ /^\w+(?:::\w+)*$/)
4361 0 0 length $args{'class'} ? :
4364 3 0 unless ($args{'isa'})
4367 0 3 @def == 1 && ref $def[0] ? :
4370 0 3 unless ref $args{'isa'}
4376 0 3 unless ($class =~ /^\w+(?:::\w+)*$/)
4383 2 1 unless not $class =~ /^Rose::DB::/ and %{"${class}::";}
4385 1 2 if UNIVERSAL::isa($class, 'Rose::DB::Object::Manager')
4388 2 1 unless ($ok)
4398 0 1 if (@{"$args{'class'}::ISA";})
4431 0 0 if ($AUTOLOAD =~ /::((?:auto_(?!helper)|(?:default_)?perl_)\w*)$/)
4437 0 0 unless ($self->can($method))
4452 0 2 if (@_) { }
4455 0 0 if @_
4460 0 2 unless my $db = $self->db
4474 1 0 unless ($self->isa($self->auto_helper_class))
4481 1 0 unless (@{"${auto_helper_class}::ISA";})
4492 0 1 if $error
4500 0 1 if (my $new_class = $Rebless{join $;, $class, $auto_helper_class}) { }
4507 0 1 if ($class eq 'Rose::DB::Object::Metadata') { }
4514 1 0 if (index($auto_helper_class, 'Rose::DB::') == 0) { }
4532 3 8 if $name =~ /^[A-Z]+$/
4537 3 5 if (defined &Rose::DB::Object::Metadata::auto_symbol and not defined &Rose::DB::Object::Metadata::existing_symbol)
4539 0 3 if $Debug
4570 1 0 if (@_)
4582 0 297 if (@_)
4584 0 0 $_[0] ? :
4588 0 297 if defined $self->{'column_undef_overrides_default'}