Branch Coverage

blib/lib/DBIx/Class/Schema/Loader/Base.pm
Criterion Covered Total %
branch 425 558 76.1


line true false branch
1086 10 1400 unless ref $self->{$_} eq "ARRAY"
1100 0 235 if (exists $args{'column_accessor_map'})
1108 48 1204 unless defined $_
1113 2 233 if (my $config_file = $self->config_file)
1116 0 2 if $@
1118 0 2 unless ref $config_opts eq "HASH"
1121 2 0 unless exists $self->{$k}
1125 0 235 if (defined $self->{'result_component_map'})
1126 0 0 if (defined $self->result_components_map)
1132 0 235 if (defined $self->{'result_role_map'})
1133 0 0 if (defined $self->result_roles_map)
1139 0 235 if not defined $self->use_moose && $self->use_moose and defined $self->result_roles || defined $self->result_roles_map
1153 0 234 if defined $self->result_components_map and ref $self->result_components_map ne "HASH"
1157 2 232 if ($self->result_components_map) { }
1160 4 0 unless ref $rc_map{$moniker}
1169 0 234 if defined $self->result_roles_map and ref $self->result_roles_map ne "HASH"
1173 0 234 if ($self->result_roles_map) { }
1176 0 0 unless ref $rr_map{$moniker}
1184 0 234 if ($self->use_moose)
1185 0 0 if ($self->only_autoclean) { }
1186 0 0 unless ("DBIx::Class::Schema::Loader::Optional::Dependencies"->req_ok_for("use_moose_only_autoclean"))
1192 0 0 unless ("DBIx::Class::Schema::Loader::Optional::Dependencies"->req_ok_for("use_moose"))
1214 0 234 if $self->{'dump_overwrite'}
1218 0 234 if $self->dynamic and $self->dry_run
1233 52 182 if (not defined $self->naming) { }
1240 178 56 if (not ref $self->naming and defined $self->naming) { }
0 56 elsif (ref $self->naming eq 'HASH' and exists $self->naming->{'ALL'}) { }
1255 182 52 if ($self->naming)
1257 531 15 if ($self->naming->{$key} || '') eq "current"
1262 0 234 if ($self->custom_column_info and ref $self->custom_column_info ne "CODE")
1268 28 206 unless defined $self->use_namespaces
1269 232 2 unless defined $self->generate_pod
1270 234 0 unless defined $self->pod_comment_mode
1271 234 0 unless defined $self->pod_comment_spillover_length
1273 2 232 if (my $col_collision_map = $self->col_collision_map)
1274 2 0 if (my $reftype = ref $col_collision_map) { }
1275 0 2 if ($reftype ne "HASH")
1284 2 232 if (my $rel_collision_map = $self->rel_collision_map)
1285 2 0 if (my $reftype = ref $rel_collision_map) { }
1286 0 2 if ($reftype ne "HASH")
1295 10 224 if (defined(my $rel_name_map = $self->rel_name_map))
1297 0 10 if ($reftype ne "HASH" and $reftype ne "CODE")
1302 4 230 if (defined(my $filter = $self->filter_generated_code))
1304 0 4 if ($reftype and $reftype ne "CODE")
1309 12 222 if (defined $self->db_schema)
1310 2 10 if (ref $self->db_schema eq 'ARRAY') { }
10 0 elsif (not ref $self->db_schema) { }
1311 0 2 if (@{$self->db_schema;} > 1 and not defined $self->{'qualify_objects'}) { }
0 2 elsif (@{$self->db_schema;} == 0) { }
1319 0 10 if ($self->db_schema eq "%" and not defined $self->{'qualify_objects'})
1327 226 8 if (not $self->moniker_parts) { }
1331 0 8 unless (ref $self->moniker_parts)
1334 0 8 if (ref $self->moniker_parts ne "ARRAY")
1337 0 8 if (&none(sub { $_ eq "name"; } , @{$self->moniker_parts;}))
1342 228 6 unless (defined $self->moniker_part_separator)
1345 232 2 unless (defined $self->moniker_part_map)
1356 86 148 if ($self->dynamic)
1360 3 83 if (not $self->naming_set) { }
1361 1 2 unless $ENV{'SCHEMA_LOADER_BACKCOMPAT'}
1376 25 61 if (not defined $self->use_namespaces and $self->naming_set)
1383 72 14 if ($self->use_namespaces) { }
1395 62 86 unless -e $filename
1400 0 86 unless $old_ver
1403 86 0 unless (defined $self->use_moose)
1404 0 86 if $old_gen =~ /^ (?!\s*\#) use \s+ Moose/mx
1407 30 56 $old_gen =~ /^__PACKAGE__->load_classes;/m ? :
1409 10 76 $old_gen =~ /result_namespace => (.+)/ ? :
1411 0 86 if $@
1417 10 76 if ($load_classes and not defined $self->use_namespaces) { }
18 58 elsif ($load_classes and $self->use_namespaces) { }
4 54 elsif (not $load_classes and defined $self->use_namespaces and not $self->use_namespaces) { }
52 2 elsif (not defined $self->use_namespaces or $self->use_namespaces) { }
1418 10 0 unless $ENV{'SCHEMA_LOADER_BACKCOMPAT'}
1439 44 8 if (not $self->result_namespace) { }
8 0 elsif ($result_namespace ne $self->result_namespace) { }
1453 54 32 if $v eq $CURRENT_V or $old_ver =~ /^0\.\d\d999/
1455 8 24 if (not %{$self->naming;}) { }
1456 8 0 unless $ENV{'SCHEMA_LOADER_BACKCOMPAT'}
1484 456 1419 unless $self->$k
1486 1405 14 ref $self->$k eq 'ARRAY' ? :
1518 13 36 if ($key =~ /component/ and not $c =~ s/^\+//)
1524 49 0 if (defined $installed) { }
1525 1 48 if ($installed == 0)
1545 30 9452 if -f $fullpath and &try(sub { Cwd::abs_path($fullpath); } ) ne (&try(sub { Cwd::abs_path('File::Spec'->catfile($self->dump_directory, $file)); } ) || '')
1570 1269 538 unless $self->_rewriting
1577 2676 56 unless $old_classes{$1}
1585 4 768 if $self->{'skip_load_external'}
1592 201 567 if $self->_rewriting
1595 158 610 if $old_class and $old_class ne $class
1598 738 30 unless $real_inc_path or $old_real_inc_path
1600 20 10 if ($real_inc_path)
1602 0 20 if $self->debug
1607 7 13 if ($self->dynamic)
1627 10 20 if ($old_real_inc_path)
1640 3 7 if ($self->dynamic)
1694 3 257 unless (exists $self->_tables->{$table->sql_name})
1702 1 257 unless (exists $current{$table->sql_name})
1721 0 123 if $self->{'skip_relationships'}
1757 1 779 if (@$imtables > 1)
1764 0 1 if ($different_databases or $different_schemas) { }
1767 0 0 if ($different_databases)
1784 0 0 if $use_schema and not $have_schema
1785 0 0 if $use_database and not $have_database
1817 1 120 if (@clashes)
1828 118 2 unless ($self->skip_relationships)
1860 118 117 unless defined $unload
1869 1 232 if $self->dry_run
1884 0 1540 if (my $mc = $self->_moose_metaclass($class))
1887 774 766 if $unload
1889 0 1049 if ($source = $have_source{$moniker} and $resultset_class = $source->resultset_class and $resultset_class ne "DBIx::Class::ResultSet")
1895 0 0 if (my $mc = $self->_moose_metaclass($resultset_class))
1898 0 0 if $unload
1899 0 0 if $has_file
1913 1540 0 unless $INC{'Class/MOP.pm'}
1918 0 0 unless my $mc = &try(sub { Class::MOP::class_of($class); } )
1920 0 0 $mc->isa('Moose::Meta::Class') ? :
1966 3 1776 if $self->dry_run
1974 497 6187 unless (-d $dir)
1975 0 497 unless mkdir $dir
1977 1776 4908 unless @name_parts
1989 44 191 unless $self->dynamic or $self->quiet
1998 0 235 $self->only_autoclean ? :
2004 0 235 if ($self->use_moose) { }
2012 0 235 unless $self->schema_components
2014 16 219 if (@schema_components)
2016 4 12 if @schema_components == 1
2021 144 91 if ($self->use_namespaces) { }
2027 24 120 if $self->result_namespace and $self->result_namespace ne "Result"
2031 44 268 if ($self->$attr)
2036 24 120 if $namespace_options
2061 8 1536 unless $result_base_class eq "DBIx::Class::Core"
2064 0 1544 if ($self->use_moose) { }
2068 0 0 if (@{$self->left_base_classes;} or @{$self->additional_base_classes;}) { }
2084 16 217 if (my $result_ns = $self->_downgrading_to_load_classes || $self->_rewriting_result_namespace)
2094 13 3 unless (my(@files) = glob("$result_dir/*"))
2099 42 191 unless $self->dynamic or $self->quiet
2104 1920 12 defined $version ? :
1920 12 defined $ts ? :
2116 30 754 if (-f $filename and $self->really_erase_my_files and not $self->dry_run)
2117 27 3 unless $self->quiet
2125 0 1777 if (not $old_gen and -f $filename)
2134 320 1457 if (my $renamed_class = $self->_upgrading_classes->{$class})
2137 73 247 if (-f $old_filename)
2140 73 0 unless $self->dry_run
2148 0 1777 if ($self->use_moose) { }
0 3554 elsif (defined $self->use_moose and $old_gen) { }
2155 0 0 if ($custom_content eq $non_moose_custom_content) { }
0 0 elsif (not $custom_content =~ quotemeta(join $", @{[$self->_default_moose_custom_content($is_schema)];})) { }
2163 0 0 if $old_gen =~ /use \s+ MooseX?\b/x
2170 235 1542 unless $self->{'_dump_storage'}{$class}
2172 12 1765 if ($self->filter_generated_code)
2175 6 6 if (ref $filter eq 'CODE') { }
2176 2 4 $is_schema ? :
2189 0 6 unless open my $out, qq[$filter < "$temp_file"|]
2200 0 6 unless unlink $temp_file
2203 0 6 if ($exit_code != 0)
2207 2 10 unless ($text and $text =~ /\bpackage\b/)
2208 0 2 if $self->debug
2216 752 1023 if ($old_md5)
2218 624 128 if (Digest::MD5::md5_base64(&encode("UTF-8", $compare_to)) eq $old_md5)
2219 592 32 unless $self->_upgrading_from and $is_schema
2225 3 1180 if $self->dry_run
2227 12 1168 $self->omit_version ? :
12 1168 $self->omit_timestamp ? :
2232 0 1180 unless open my $fh, ">:raw:encoding(UTF-8)", $filename
2240 1155 25 unless $self->{'_ext_storage'}{$class}
2245 0 1180 unless close $fh
2252 0 0 unless ($is_schema)
2263 0 952 if ($self->use_moose)
2273 1025 913 unless -f $fn
2275 0 913 unless open my $fh, "<:encoding(UTF-8)", $fn
2284 913 95646 if (/$mark_re/) { }
2290 913 0 if $ver
2291 913 0 if $ts
2295 4 909 if ($real_md5 ne $mark_md5)
2296 2 2 if ($self->overwrite_modifications) { }
2312 911 0 if $real_md5
2328 0 313 if $self->debug
2339 930 626 unless $blist
2341 0 626 if $self->debug
2351 0 0 unless $rlist
2353 0 0 if $self->debug
2361 311 342 if ref $ns
2363 6 647 if ($ns =~ /^\+(.*)/) { }
2372 637 16 wantarray ? :
2384 596 182 if ($self->use_namespaces)
2393 209 569 if (my $upgrading_v = $self->_upgrading_from or $self->_rewriting)
2395 164 45 if $upgrading_v
2399 97 112 if ($self->_upgrading_from_load_classes) { }
23 89 elsif (my $ns = $self->_downgrading_to_load_classes) { }
18 71 elsif ($ns = $self->_rewriting_result_namespace) { }
2422 164 45 unless $table_class eq $old_class
2438 0 778 unless $self->components
2441 12 766 if exists $self->result_components_map->{$table_moniker}
2445 319 630 unless ($component =~ s/^\+//)
2452 313 465 if @components
2462 3162 0 $table ? :
2464 115 3047 unless defined $self->_result_class_methods
2467 517 2645 unless (exists $self->_result_class_methods->{$table_moniker})
2471 0 517 unless $self->components
2474 2 515 if exists $self->result_components_map->{$table_moniker}
2477 109 56 $c =~ /^\+/ ? :
2480 0 517 unless $self->result_roles
2483 0 517 if exists $self->result_roles_map->{$table_moniker}
2485 0 517 $self->use_moose ? :
2491 0 682 unless "Class::Inspector"->methods($class)
2511 341 1860 if $accessor eq "id"
2513 46 1814 if ($self->_is_result_class_method($accessor, $table))
2516 42 4 if (my $map = $self->col_collision_map)
2518 6 36 if (my(@matches) = $col =~ /$re/)
2525 40 6 unless ($mapped)
2542 1318 4503 if ($map and ref $map eq 'HASH') { }
1319 6368 elsif ($map and ref $map eq 'CODE') { }
2543 1316 2 if (my(@parts) = &try(sub { @{$ident;}; } ))
2547 1302 89 unless exists $part_map->{$part}
2548 14 75 if (not ref $part_map->{$part} || @parts) { }
75 0 elsif (ref $part_map->{$part} eq 'HASH') { }
2557 1303 1 unless ($new_ident or ref $map->{$ident})
2564 0 1313 unless "HASH" eq ref $cb_map
2583 17 3183 $preserve ? :
2591 17 3183 if ($preserve) { }
788 2395 elsif ($v < 7 or not $self->preserve_case) { }
2633 7 771 if my $is_view = $self->_table_is_view($table)
2639 0 778 if ($is_view and my $view_def = $self->_view_definition($table))
2672 2053 148 if $info->{'accessor'} eq $col
2687 751 27 if @$pks
2694 95 177 if $uniq_tag{join "\0", @$cols}++
2702 6 305 if ($self->uniq_to_primary and not @$pks and @non_nullable_uniqs)
2706 6 0 unless (@by_colnum > 1 and $by_colnum[0][0] == $by_colnum[1][0])
2728 757 21 if @$pks
2774 4094 7592 if (($self->naming->{$naming_key} || '') =~ /^v(\d+)\z/) { }
2790 0 5208 $self->naming->{'force_ascii'} ? :
2793 5 5203 $v >= 8 || $force ? :
2817 2 1312 if (length $moniker_part)
2822 5 1307 if ($i != $name_idx or $v >= 8)
2826 14 1298 if ($i == $name_idx and $v == 5)
2830 1069 5 $i == $name_idx ? :
1074 238 $v > 6 ? :
2835 1083 229 if ($i == $name_idx and $v >= 6)
2841 2 1079 ($self->naming->{'monikers'} || '') eq 'preserve' ? :
2 1081 ($self->naming->{'monikers'} || '') eq 'plural' ? :
2892 0 64 unless $DBIx::Class::Schema::Loader::Base::a->[0] <=> $DBIx::Class::Schema::Loader::Base::b->[0]
2899 64 1220 $_->{'method'} eq 'many_to_many' ? :
2913 0 772 unless $self->result_roles
2915 0 772 if exists $self->result_roles_map->{$table_moniker}
2917 0 772 if (@roles)
2950 4080 8 if $self->generate_pod
2953 1448 2640 if @_ < 2
2956 0 4088 if $self->debug
2964 4 1540 unless $self->generate_pod
2979 2 1538 if $comment and $comment_in_name
2983 2 1538 if ($comment and $comment_in_desc)
2998 776 3304 if ($method eq 'table') { }
776 2528 elsif ($method eq 'add_columns') { }
1218 1310 elsif ($method =~ /^(?:belongs_to|has_many|might_have)\z/) { }
64 1246 elsif ($method eq 'many_to_many') { }
171 1075 elsif ($method eq 'add_unique_constraint') { }
755 320 elsif ($method eq 'set_primary_key') { }
3000 0 776 if ref $table eq "SCALAR"
3014 3794 2461 &looks_like_number($s) ? :
22 6255 ref $s ? :
86 6277 ref $s eq 'SCALAR' ? :
7 6363 length $s == 0 ? :
40 6370 !defined($s) ? :
3023 2 2194 if (my $comment = $self->__column_comment($self->class_to_table->{$class}, $col_counter, $name))
3029 665 553 unless $self->{'_relations_started'}{$class}
3037 0 64 unless $self->{'_relations_started'}{$class}
3047 148 23 unless $self->{'_uniqs_started'}{$class}
3079 1860 1252 unless @classes and $self->generate_pod
3095 0 8 unless $self->generate_pod
3103 3730 6 unless defined $txt
3113 1540 0 if (my $code = $self->can("_table_comment"))
3123 2196 0 if (my $code = $self->can("_column_comment"))
3156 1010 1191 if (my $code = $self->custom_column_info)
3166 116 2085 if (grep $_, @{$column_info;}{map "inflate_$_", ("date", "datetime", "timestamp")} or $type =~ /date|timestamp/i)
3168 36 80 if $self->datetime_timezone
3169 36 80 if $self->datetime_locale
3177 5724 3684 $self->preserve_case ? :
3183 0 0 $self->preserve_case ? :