| 1 | package Rose::DB::Object::Metadata::Auto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 32 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 32 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 32 | ▶ | use Carp(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 32 | ▶ | use Rose::DB::Object::Metadata::Column::Scalar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 32 | ▶ | use Rose::DB::Object::Metadata::ForeignKey; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 32 | ▶ | use Rose::DB::Object::Metadata; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 32 | our @ISA = qw(Rose::DB::Object::Metadata); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 32 | our $Debug; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 32 | *Debug = \$Rose::DB::Object::Metadata::Debug; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 32 | our $Sort_Columns_Alphabetically = 0; # hack for test suite | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 32 | our $VERSION = '0.786'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 32 | our $Missing_PK_OK = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | use Rose::Class::MakeMethods::Generic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 32 | ▶ | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 32 | inheritable_scalar => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 'default_perl_indent', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 'default_perl_braces', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 'default_perl_unique_key_style', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | inheritable_hash => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | relationship_type_ranks => { interface => 'get_set_all' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | relationship_type_rank => { interface => 'get_set', hash_key => 'relationship_type_ranks' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | delete_relationship_type_rank => { interface => 'delete', hash_key => 'relationship_type_ranks' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 32 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | use Rose::Object::MakeMethods::Generic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 32 | ▶ | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 32 | 'scalar --get_set_init' => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'column_alias_generator', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 'foreign_key_name_generator', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | scalar => 'auto_init_args', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 32 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 32 | __PACKAGE__->relationship_type_ranks | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'one to one' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'many to one' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 'one to many' => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 'many to many' => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 32 | __PACKAGE__->default_perl_indent(4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 32 | __PACKAGE__->default_perl_braces('k&r'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 32 | __PACKAGE__->default_perl_unique_key_style('array'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | sub auto_formatted_schema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_formatted_schema: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my($self, $db) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $db ||= $self->db; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$db ||= $self->db
MC/DC0%0/2
$db ||= $self->db
$db
$self->db
Truth table0%0/3
A ||= B
A= $dbB= $self->db
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $schema = $self->select_schema($db); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $schema = $db->default_implicit_schema unless(defined $schema); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if(defined $schema) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if($db->likes_lowercase_schema_names) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $schema = lc $schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | elsif($db->likes_uppercase_schema_names) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $schema = uc $schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return $schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | sub auto_formatted_catalog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_formatted_catalog: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my($self, $db) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $db ||= $self->db; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$db ||= $self->db
MC/DC0%0/2
$db ||= $self->db
$db
$self->db
Truth table0%0/3
A ||= B
A= $dbB= $self->db
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $catalog = $self->select_catalog($db); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if(defined $catalog) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if($db->likes_lowercase_catalog_names) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $catalog = lc $catalog; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | elsif($db->likes_uppercase_catalog_names) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $catalog = uc $catalog; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return $catalog; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | sub auto_generate_columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_generate_columns: not called CC=15 SCAR=51.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my($db, $class, %columns, $catalog, $schema, $table, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | TRY: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $class = $self->class or die "Missing class!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $db = $self->db; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $dbh = $db->dbh or die $db->error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | local $dbh->{'FetchHashKeyName'} = 'NAME'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $table = $self->table; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | $table = lc $table if($db->likes_lowercase_table_names); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $table_unquoted = $db->unquote_table_name($table); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $supports_catalog = $db->supports_catalog; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $catalog = $self->auto_formatted_catalog($db); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $schema = $self->auto_formatted_schema($db); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $sth = $dbh->column_info($catalog, $schema, $table_unquoted, '%'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | unless(defined $sth) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 32 | ▶ | no warnings; # undef strings okay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | die "No column information found for catalog '", $catalog, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | "' schema '", $schema, "' table '", $table_unquoted, "'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | COLUMN: while(my $col_info = $sth->fetchrow_hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | CHECK_TABLE: # Make sure this column is from the right table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | no warnings; # Allow undef coercion to empty string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $col_info->{'TABLE_NAME'} = $db->unquote_table_name($col_info->{'TABLE_NAME'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | next COLUMN unless((!$supports_catalog || $col_info->{'TABLE_CAT'} eq $catalog) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | $col_info->{'TABLE_SCHEM'} eq $schema && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $col_info->{'TABLE_NAME'} eq $table_unquoted); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
!$supports_catalog || $col_info->{"TABLE_CAT"} eq $catalog and $col_info->{"TABLE_SCHEM"} eq $schema and $col_info->{"TABLE_NAME"} eq $table_unquoted
!$supports_catalog || $col_info->{"TABLE_CAT"} eq $catalog and $col_info->{"TABLE_SCHEM"} eq $schema
not $supports_catalog or $col_info->{"TABLE_CAT"} eq $catalog
MC/DC0%0/4
!$supports_catalog || $col_info->{"TABLE_CAT"} eq $catalog and $col_info->{"TABLE_SCHEM"} eq $schema and $col_info->{"TABLE_NAME"} eq $table_unquoted
not $supports_catalog
$col_info->{"TABLE_CAT"} eq $catalog
$col_info->{"TABLE_SCHEM"} eq $schema
$col_info->{"TABLE_NAME"} eq $table_unquoted
Truth table0%0/7
not(A) or B and C and D
A= not $supports_catalogB= $col_info->{"TABLE_CAT"} eq $catalogC= $col_info->{"TABLE_SCHEM"} eq $schemaD= $col_info->{"TABLE_NAME"} eq $table_unquoted
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | unless(defined $col_info->{'COLUMN_NAME'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | Carp::croak "Could not extract column name from DBI column_info()"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $db->refine_dbi_column_info($col_info, $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | $columns{$col_info->{'COLUMN_NAME'}} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $self->auto_generate_column($col_info->{'COLUMN_NAME'}, $col_info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if($error || !keys %columns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$error or not keys %columns
MC/DC0%0/2
$error or not keys %columns
$error
not keys %columns
Truth table0%0/3
A or not(B)
A= $errorB= not keys %columns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 32 | ▶ | no warnings; # undef strings okay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | Carp::croak "Could not auto-generate columns for class $class - ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$error || q[no column info found for catalog '] . $catalog . q[' schema '] . $schema . "' table '${table}'"
MC/DC0%0/1
$error || q[no column info found for catalog '] . $catalog . q[' schema '] . $schema . "' table '${table}'"
$error
Truth table0%0/2
A
A= $error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ($error || "no column info found for catalog '" . $catalog . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | "' schema '" . $schema . "' table '$table'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $self->auto_alias_columns(values %columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | return wantarray ? values %columns : \%columns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | sub auto_alias_columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_alias_columns: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | foreach my $column (@_) #(@_ == 1 && ref $_[0] eq 'ARRAY' ? @{$_[0]} : @_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # Auto-alias the column if there will be any conflicts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | foreach my $type ($column->auto_method_types) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $method = $self->method_name_from_column($column, $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if($self->method_name_is_reserved($method, $self->class)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $self->auto_alias_column($column); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | last; # just alias the column once | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # Re-check: errors are fatal this time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | foreach my $type ($column->auto_method_types) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $method = $self->method_name_from_column($column, $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if($self->method_name_is_reserved($method, $self->class)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | Carp::croak "Cannot create '$type' method named '$method' for ", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | "column '$column' - method name is reserved"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | sub auto_generate_column | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_generate_column: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my($self, $name, $col_info) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $type = $col_info->{'TYPE_NAME'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $meta_class = $self->original_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | my $column_class = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$meta_class->column_type_class($type) || $meta_class->column_type_class('scalar')
MC/DC0%0/2
$meta_class->column_type_class($type) || $meta_class->column_type_class('scalar')
$meta_class->column_type_class($type)
$meta_class->column_type_class('scalar')
Truth table0%0/3
A || B
A= $meta_class->column_type_class($type)B= $meta_class->column_type_class('scalar')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | $meta_class->column_type_class($type) || $meta_class->column_type_class('scalar') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | or Carp::croak "No column class set for column types '$type' or 'scalar'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | unless($self->column_class_is_loaded($column_class)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $self->load_column_class($column_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $column = $column_class->new(name => $name, parent => $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $column->init_with_dbi_column_info($col_info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | return $column; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub init_column_alias_generator { sub { $_[1] . '_col' } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
init_column_alias_generator: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | DEFAULT_FK_NAME_GEN: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 32 | my %Seen_FK_Name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | sub default_foreign_key_name_generator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_foreign_key_name_generator: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my($meta, $fk) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $class = $meta->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $key_columns = $fk->key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $name = $fk->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # No single column whose name we can steal and then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # mangle to make the foreign key name, so we'll derive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # the foreign key name from the foreign class name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if(keys %$key_columns > 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $name = $fk->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $name =~ s/::/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $name =~ s/([a-z])([A-Z])/$1_$2/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $name = lc $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my($local_column, $foreign_column) = %$key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # Try to lop off foreign column name. Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # my_foreign_object_id -> my_foreign_object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if($local_column =~ s/_$foreign_column$//) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $name = $local_column; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # Usually, the actual column name is taken by the column accessor, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # but if it's not, we'll use it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if(!$meta->class->can($local_column)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $name = $local_column; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | else # otherwise, append "_object" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $name = $local_column . '_object'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # Make sure the name's not taken, appending numbers until it's unique. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # See, this is why you shouldn't rely on auto_init_* all the time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # You end up with lame method names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if($Seen_FK_Name{$class}{$name}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $num = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my $new_name = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | while($Seen_FK_Name{$class}{$new_name}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $new_name = $name . $num++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $name = $new_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $Seen_FK_Name{$class}{$name}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | sub init_foreign_key_name_generator { \&default_foreign_key_name_generator } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_foreign_key_name_generator: not called CC=1 SCAR=1.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | sub auto_alias_column | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_alias_column: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my($self, $column) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $code = $self->column_alias_generator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | local $_ = $column->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $alias = $code->($self, $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | if($self->method_name_is_reserved($alias, $self->class)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | Carp::croak "Called column_alias_generator() to alias column ", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | "'$_' but the value returned is a reserved method ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | "name: $alias"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $column->alias($alias); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | sub auto_retrieve_primary_key_column_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_retrieve_primary_key_column_names: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | unless(defined wantarray) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | Carp::croak "Useless call to auto_retrieve_primary_key_column_names() in void context"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $db = $self->db; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $catalog = $self->auto_formatted_catalog($db); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $schema = $self->auto_formatted_schema($db); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my($pk_columns, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | TRY: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $pk_columns = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | $self->db->primary_key_column_names(table => $self->table, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | catalog => $catalog, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | schema => $schema); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if($error || (!$Missing_PK_OK && !@$pk_columns)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$error or not $Rose::DB::Object::Metadata::Auto::Missing_PK_OK || @$pk_columns
$Rose::DB::Object::Metadata::Auto::Missing_PK_OK || @$pk_columns
MC/DC0%0/3
$error or not $Rose::DB::Object::Metadata::Auto::Missing_PK_OK || @$pk_columns
$error
$Rose::DB::Object::Metadata::Auto::Missing_PK_OK
@$pk_columns
Truth table0%0/4
A or not(B || C)
A= $errorB= $Rose::DB::Object::Metadata::Auto::Missing_PK_OKC= @$pk_columns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $error = 'no primary key columns found' unless(defined $error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | Carp::croak "Could not auto-retrieve primary key columns for class ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$error || q[no primary key info found for catalog '] . $catalog . q[' schema '] . $schema . q[' table '] . $self->table
MC/DC0%0/1
$error || q[no primary key info found for catalog '] . $catalog . q[' schema '] . $schema . q[' table '] . $self->table
$error
Truth table0%0/2
A
A= $error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | $self->class, " - ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | ($error || "no primary key info found for catalog '" . $catalog . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | "' schema '" . $schema . "' table '" . $self->table, "'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | $pk_columns ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$pk_columns ||= []
MC/DC0%0/1
$pk_columns ||= []
$pk_columns
Truth table0%0/2
A
A= $pk_columns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | return wantarray ? @$pk_columns : $pk_columns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 32 | my %Warned; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | sub auto_generate_foreign_keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_generate_foreign_keys: not called CC=31 SCAR=67.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | unless(defined wantarray) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | Carp::croak "Useless call to auto_generate_foreign_keys() in void context"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my $no_warnings = $args{'no_warnings'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my($class, @foreign_keys, $total_fks, %used_names, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | TRY: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | $class = $self->class or die "Missing class!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my $db = $self->db; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | my $dbh = $db->dbh or die $db->error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | local $dbh->{'FetchHashKeyName'} = 'NAME'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $catalog = $self->auto_formatted_catalog($db); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $schema = $self->auto_formatted_schema($db); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | my $table = $db->likes_lowercase_table_names ? lc $self->table : $self->table; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my $sth = $dbh->foreign_key_info(undef, undef, undef, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | $catalog, $schema, $table); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # This happens when the table has no foreign keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | return unless(defined $sth); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my(%fk, @fk_info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | FK: while(my $fk_info = $sth->fetchrow_hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | $db->refine_dbi_foreign_key_info($fk_info, $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | CHECK_TABLE: # Make sure this column is from the right table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | no warnings; # Allow undef coercion to empty string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | next FK unless($fk_info->{'FK_TABLE_CAT'} eq $catalog && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | $fk_info->{'FK_TABLE_SCHEM'} eq $schema && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | $fk_info->{'FK_TABLE_NAME'} eq $table); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$fk_info->{"FK_TABLE_CAT"} eq $catalog and $fk_info->{"FK_TABLE_SCHEM"} eq $schema and $fk_info->{"FK_TABLE_NAME"} eq $table
$fk_info->{"FK_TABLE_CAT"} eq $catalog and $fk_info->{"FK_TABLE_SCHEM"} eq $schema
MC/DC0%0/3
$fk_info->{"FK_TABLE_CAT"} eq $catalog and $fk_info->{"FK_TABLE_SCHEM"} eq $schema and $fk_info->{"FK_TABLE_NAME"} eq $table
$fk_info->{"FK_TABLE_CAT"} eq $catalog
$fk_info->{"FK_TABLE_SCHEM"} eq $schema
$fk_info->{"FK_TABLE_NAME"} eq $table
Truth table0%0/4
A and B and C
A= $fk_info->{"FK_TABLE_CAT"} eq $catalogB= $fk_info->{"FK_TABLE_SCHEM"} eq $schemaC= $fk_info->{"FK_TABLE_NAME"} eq $table
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $local_column = $fk_info->{'FK_COLUMN_NAME'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my $foreign_column = $fk_info->{'UK_COLUMN_NAME'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | my $fk_id = $fk_info->{'RDBO_FK_ID'} = $fk_info->{'FK_NAME'} || $fk_info->{'UK_NAME'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fk_info->{'FK_NAME'} || $fk_info->{'UK_NAME'}
MC/DC0%0/2
$fk_info->{'FK_NAME'} || $fk_info->{'UK_NAME'}
$fk_info->{'FK_NAME'}
$fk_info->{'UK_NAME'}
Truth table0%0/3
A || B
A= $fk_info->{'FK_NAME'}B= $fk_info->{'UK_NAME'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $fk{$fk_id}{'key_columns'}{$local_column} = $foreign_column; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | push(@fk_info, $fk_info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | # This step is important! It ensures that foreign keys will be created | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | # in a deterministic order, which in turn allows the "auto-naming" of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # foreign keys to work in a predictable manner. This exact sort order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # (lowercase table name comparisons) is part of the API for foreign | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | # key auto generation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | @fk_info = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | sort { lc $a->{'UK_TABLE_NAME'} cmp lc $b->{'UK_TABLE_NAME'} } @fk_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my $cm = $self->convention_manager; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my %seen_fk_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | FK_INFO: foreach my $fk_info (@fk_info) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $fk_id = $fk_info->{'RDBO_FK_ID'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | next if($seen_fk_id{$fk_id}++); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | my $foreign_class = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | $self->class_for(catalog => $fk_info->{'UK_TABLE_CAT'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | schema => $fk_info->{'UK_TABLE_SCHEM'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | table => $fk_info->{'UK_TABLE_NAME'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | unless($foreign_class) # Give convention manager a chance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | $foreign_class = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | $self->convention_manager->related_table_to_class( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $fk_info->{'UK_TABLE_NAME'}, $self->class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | unless(UNIVERSAL::isa($foreign_class, 'Rose::DB::Object')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | # Null convention manager may return undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 32 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | eval "require $foreign_class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | $foreign_class = undef if($@ || !UNIVERSAL::isa($foreign_class, 'Rose::DB::Object')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or not UNIVERSAL::isa($foreign_class, "Rose::DB::Object")
MC/DC0%0/2
$@ or not UNIVERSAL::isa($foreign_class, "Rose::DB::Object")
$@
not UNIVERSAL::isa($foreign_class, "Rose::DB::Object")
Truth table0%0/3
A or not(B)
A= $@B= not UNIVERSAL::isa($foreign_class, "Rose::DB::Object")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | unless($foreign_class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | my $key = join($;, map { defined($_) ? $_ : "\034" } $self->class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | @$fk_info{qw(UK_TABLE_CAT UK_TABLE_SCHEM UK_TABLE_NAME)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # Add deferred task | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | $self->add_deferred_task( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | class => $self->class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | method => 'auto_init_foreign_keys', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | args => \%args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | code => sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $self->auto_init_foreign_keys(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $self->make_foreign_key_methods(%args, preserve_existing => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | check => sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $fks = $self->foreign_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | return @$fks == $total_fks ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | unless($no_warnings || $Warned{$key}++ || $self->allow_auto_initialization) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$no_warnings or $Warned{$key}++ or $self->allow_auto_initialization
$no_warnings or $Warned{$key}++
MC/DC0%0/3
$no_warnings or $Warned{$key}++ or $self->allow_auto_initialization
$no_warnings
$Warned{$key}++
$self->allow_auto_initialization
Truth table0%0/4
A or B or C
A= $no_warningsB= $Warned{$key}++C= $self->allow_auto_initialization
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 32 | ▶ | no warnings; # Allow undef coercion to empty string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | Carp::carp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | "No Rose::DB::Object-derived class found for catalog '", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | $fk_info->{'UK_TABLE_CAT'}, "' schema '", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | $fk_info->{'UK_TABLE_SCHEM'}, "' table '", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $fk_info->{'UK_TABLE_NAME'}, "'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $total_fks++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | next FK_INFO; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $fk{$fk_id}{'class'} = $foreign_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | my $key_name = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | $cm->auto_foreign_key_name($foreign_class, $fk_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $fk{$fk_id}{'key_columns'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | \%used_names); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | $used_names{$key_name}++ if(defined $key_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | if(defined $key_name && length $key_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $key_name and length $key_name
MC/DC0%0/2
defined $key_name and length $key_name
defined $key_name
length $key_name
Truth table0%0/3
A and B
A= defined $key_nameB= length $key_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $fk{$fk_id}{'name'} = $key_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $total_fks++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | my(%seen, %seen_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | foreach my $fk_info (@fk_info) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | next if($seen{$fk_info->{'RDBO_FK_ID'}}++); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my $info = $fk{$fk_info->{'RDBO_FK_ID'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $fk = Rose::DB::Object::Metadata::ForeignKey->new(%$info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | next unless(defined $fk->class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | unless(defined $fk->name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $fk->name($self->foreign_key_name_generator->($self, $fk)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | push(@foreign_keys, $fk); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | if($error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | Carp::croak "Could not auto-generate foreign keys for class $class - $error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | @foreign_keys = sort { lc $a->name cmp lc $b->name } @foreign_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | return wantarray ? @foreign_keys : \@foreign_keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | sub auto_init_columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_columns: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my $auto_columns = $self->auto_generate_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | my $existing_columns = $self->columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | if(!$args{'replace_existing'} && keys %$auto_columns != @$existing_columns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not $args{"replace_existing"} and keys %$auto_columns != @$existing_columns
MC/DC0%0/2
not $args{"replace_existing"} and keys %$auto_columns != @$existing_columns
not $args{"replace_existing"}
keys %$auto_columns != @$existing_columns
Truth table0%0/3
not(A) and B
A= not $args{"replace_existing"}B= keys %$auto_columns != @$existing_columns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | while(my($name, $column) = each(%$auto_columns)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | next if($self->column($name)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $self->add_column($column); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | ▶ | elsif($args{'replace_existing'} || !@$existing_columns) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"replace_existing"} or not @$existing_columns
MC/DC0%0/2
$args{"replace_existing"} or not @$existing_columns
$args{"replace_existing"}
not @$existing_columns
Truth table0%0/3
A or not(B)
A= $args{"replace_existing"}B= not @$existing_columns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $self->columns(values %$auto_columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | sub perl_columns_definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_columns_definition: not called CC=19 SCAR=58.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my $for_setup = $args{'for_setup'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | my $indent = defined $args{'indent'} ? $args{'indent'} : $self->default_perl_indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | my $braces = defined $args{'braces'} ? $args{'braces'} : $self->default_perl_braces; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | unless($indent =~ /^\d+$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'indent'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | "indent size: '$braces'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $indent = ' ' x $indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | my $def_start = $for_setup ? 'columns => ' : "__PACKAGE__->meta->columns"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | my $ob = $for_setup ? '[' : '('; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | my $cb = $for_setup ? ']' : ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | if($braces eq 'bsd') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | $def_start .= "\n$ob\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | elsif($braces eq 'k&r') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | $def_start .= "$ob\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'braces'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | "brace style: '$braces'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $max_len = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $min_len = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | foreach my $name ($self->column_names) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | $max_len = length($name) if(length $name > $max_len); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | $min_len = length($name) if(length $name < $min_len || $min_len < 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $name < $min_len or $min_len < 0
MC/DC0%0/2
length $name < $min_len or $min_len < 0
length $name < $min_len
$min_len < 0
Truth table0%0/3
A or B
A= length $name < $min_lenB= $min_len < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | my @col_defs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 32 | ▶ | no warnings 'uninitialized'; # ordinal_position may be undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | foreach my $column (sort __by_rank $self->columns) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | push(@col_defs, $column->perl_hash_definition(inline => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | name_padding => $max_len)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | $cb = $for_setup ? '],' : ');'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | my $perl = $def_start . join(",\n", map { "$indent$_" } @col_defs) . ",\n$cb\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if($for_setup) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | for($perl) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | s/^/$indent/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | s/\n\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | s/^[ \t]+$//mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | return $perl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | sub __by_rank | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__by_rank: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my $pos1 = $a->ordinal_position; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $pos2 = $b->ordinal_position; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | if(!$Sort_Columns_Alphabetically && defined $pos1 && defined $pos2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $Rose::DB::Object::Metadata::Auto::Sort_Columns_Alphabetically and defined $pos1 and defined $pos2
not $Rose::DB::Object::Metadata::Auto::Sort_Columns_Alphabetically and defined $pos1
MC/DC0%0/3
not $Rose::DB::Object::Metadata::Auto::Sort_Columns_Alphabetically and defined $pos1 and defined $pos2
not $Rose::DB::Object::Metadata::Auto::Sort_Columns_Alphabetically
defined $pos1
defined $pos2
Truth table0%0/4
not(A) and B and C
A= not $Rose::DB::Object::Metadata::Auto::Sort_Columns_AlphabeticallyB= defined $pos1C= defined $pos2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | return $pos1 <=> $pos2 || lc($a->name) cmp lc($b->name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$pos1 <=> $pos2 || lc $a->name cmp lc $b->name
MC/DC0%0/2
$pos1 <=> $pos2 || lc $a->name cmp lc $b->name
$pos1 <=> $pos2
lc $a->name cmp lc $b->name
Truth table0%0/3
A || B
A= $pos1 <=> $pos2B= lc $a->name cmp lc $b->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | return lc($a->name) cmp lc($b->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | sub perl_foreign_keys_definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_foreign_keys_definition: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | my $indent = defined $args{'indent'} ? $args{'indent'} : $self->default_perl_indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | my $braces = defined $args{'braces'} ? $args{'braces'} : $self->default_perl_braces; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | unless($indent =~ /^\d+$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'indent'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | "indent size: '$braces'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | my $indent_txt = ' ' x $indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my $for_setup = $args{'for_setup'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | my $def = $for_setup ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | $indent_txt . 'foreign_keys => ' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | '__PACKAGE__->meta->foreign_keys'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | my $ob = $for_setup ? '[' : '('; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | my $cb = $for_setup ? ']' : ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | if($braces eq 'bsd') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | $def .= "\n$ob\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | elsif($braces eq 'k&r') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $def .= "$ob\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'braces'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | "brace style: '$braces'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my @fk_defs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | foreach my $fk ($self->foreign_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | push(@fk_defs, $fk->perl_hash_definition(indent => $indent, braces => $braces)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | return '' unless(@fk_defs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | foreach my $fk_def (@fk_defs) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | for($fk_def) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | s/^/$indent_txt/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | s/^[ \t]+$//mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | $def .= "$fk_def,\n" . ($fk_def eq $fk_defs[-1] ? '' : "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | if($for_setup) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | $def .= "],\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | for($def) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | s/^/$indent_txt/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | s/\n\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | s/\A$indent_txt//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | s/^[ \t]+$//mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | return $def; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | return $def . ");\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | sub perl_relationships_definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_relationships_definition: not called CC=20 SCAR=60.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | my $indent = defined $args{'indent'} ? $args{'indent'} : $self->default_perl_indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | my $braces = defined $args{'braces'} ? $args{'braces'} : $self->default_perl_braces; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | unless($indent =~ /^\d+$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'indent'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | "indent size: '$braces'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | my $indent_txt = ' ' x $indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my $for_setup = $args{'for_setup'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | ▶ | my $def = $for_setup ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | $indent_txt . 'relationships => ' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | '__PACKAGE__->meta->relationships'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | my $ob = $for_setup ? '[' : '('; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | my $cb = $for_setup ? ']' : ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | if($braces eq 'bsd') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | $def .= "\n$ob\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | elsif($braces eq 'k&r') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | $def .= "$ob\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'braces'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | "brace style: '$braces'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | my @rel_defs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | foreach my $rel ($self->relationships) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | next if($rel->can('foreign_key') && $rel->foreign_key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rel->can("foreign_key") and $rel->foreign_key
MC/DC0%0/2
$rel->can("foreign_key") and $rel->foreign_key
$rel->can("foreign_key")
$rel->foreign_key
Truth table0%0/3
A and B
A= $rel->can("foreign_key")B= $rel->foreign_key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | push(@rel_defs, $rel->perl_hash_definition(indent => $indent, braces => $braces)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | return '' unless(@rel_defs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | foreach my $rel_def (@rel_defs) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | for($rel_def) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | s/^/$indent_txt/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | s/^[ \t]+$//mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | $def .= "$rel_def,\n" . ($rel_def eq $rel_defs[-1] ? '' : "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | if($for_setup) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | $def .= "],\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | for($def) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | s/^/$indent_txt/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | s/\n\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | s/\A$indent_txt//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | s/^[ \t]+$//mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | return $def; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | return $def . ");\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | sub perl_unique_keys_definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_unique_keys_definition: not called CC=23 SCAR=63.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | my $style = defined $args{'style'} ? $args{'style'} : $self->default_perl_unique_key_style; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | my $indent = defined $args{'indent'} ? $args{'indent'} : $self->default_perl_indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | my $braces = defined $args{'braces'} ? $args{'braces'} : $self->default_perl_braces; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | ▶ | unless($indent =~ /^\d+$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'indent'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | "indent size: '$braces'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | $indent = ' ' x $indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | my $uk_perl_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | if($style eq 'array') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | $uk_perl_method = 'perl_array_definition'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | elsif($style eq 'object') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | $uk_perl_method = 'perl_object_definition'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'style'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | "unique key style: '$style'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | my @uk_defs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | foreach my $uk ($self->unique_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | push(@uk_defs, $uk->$uk_perl_method()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | return '' unless(@uk_defs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | my $for_setup = $args{'for_setup'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | my $def_start = $for_setup ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | $indent . 'unique_keys => ' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | '__PACKAGE__->meta->unique_keys'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | my $ob = $for_setup ? '[' : '('; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | ▶ | my $cb = $for_setup ? ']' : ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | ▶ | if(@uk_defs == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | $def_start .= $ob; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | elsif($braces eq 'bsd') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | $def_start .= "\n$ob\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | elsif($braces eq 'k&r') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | $def_start .= "$ob\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'braces'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | "brace style: '$braces'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | ▶ | if($for_setup) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | if(@uk_defs == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | $def_start =~ s/^(\s*)unique_keys/$1unique_key/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | for($uk_defs[0]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | s/\A\[ //; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | s/ \]\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | return "$def_start $uk_defs[0] ],"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | my $perl = $def_start . join(",\n", map { "$indent$_" } @uk_defs) . ",\n],"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | for($perl) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | s/^/$indent/mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | s/\A$indent//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | s/^[ \t]+$//mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | return $perl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | if(@uk_defs == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | return "$def_start$uk_defs[0]);\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | return $def_start . join(",\n", map { "$indent$_" } @uk_defs) . ",\n);\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | sub perl_metadata_attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_metadata_attributes: not called CC=8 SCAR=39.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | my $for_setup = $args{'for_setup'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | my $indent = defined $args{'indent'} ? $args{'indent'} : $self->default_perl_indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | ▶ | $indent = $for_setup ? (' ' x $indent) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | my @attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | foreach my $attr (qw(allow_inline_column_values)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 32 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | if(my $value = $self->$attr()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | if($for_setup) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | push(@attrs, "$attr => " . $self->perl_quote_value($value) . ','); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | push(@attrs, "__PACKAGE__->meta->$attr(" . $self->perl_quote_value($value) . ');'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | ▶ | return @attrs ? (join("\n", map { "$indent$_" } @attrs) . ($for_setup ? '' : "\n")) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | sub perl_quote_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_quote_value: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | my($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | ▶ | return $value if($value =~ /^\d+$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | for($value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | s/\\/\\\\/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | s/'/\\'/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | return qq('$value'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | sub perl_table_definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_table_definition: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my $for_setup = $args{'for_setup'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | ▶ | my $indent = defined $args{'indent'} ? $args{'indent'} : $self->default_perl_indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | my $table = $self->table; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | $table =~ s/'/\\'/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | if($args{'for_setup'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | $indent = ' ' x $indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | return qq(${indent}table => '$table',); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | return qq(__PACKAGE__->meta->table('$table');); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | sub perl_primary_key_columns_definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_primary_key_columns_definition: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | my @pk_cols = $self->primary_key->column_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | Carp::croak "No primary key columns found for class ", ref($self) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | unless(@pk_cols); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | ▶ | if($args{'for_setup'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | ▶ | my $indent = defined $args{'indent'} ? $args{'indent'} : $self->default_perl_indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | $indent = ' ' x $indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | return $indent . 'primary_key_columns => ' . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | $self->primary_key->perl_array_definition . ','; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | return '__PACKAGE__->meta->primary_key_columns(' . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | $self->primary_key->perl_array_definition . ");\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | sub perl_class_definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_class_definition: not called CC=16 SCAR=54.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | my $indent = defined $args{'indent'} ? $args{'indent'} : $self->default_perl_indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | ▶ | my $braces = defined $args{'braces'} ? $args{'braces'} : $self->default_perl_braces; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | my $class = $self->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 32 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | ▶ | my $isa = delete $args{'isa'} || [ ${"${class}::ISA"}[0] || 'Rose::DB::Object' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
delete $args{'isa'} || [do {
"${class}::ISA"
}->[0] || 'Rose::DB::Object']
do {
"${class}::ISA"
}->[0] || 'Rose::DB::Object'
MC/DC0%0/1
delete $args{'isa'} || [do {
"${class}::ISA"
}->[0] || 'Rose::DB::Object']
delete $args{'isa'}
MC/DC0%0/1
do {
"${class}::ISA"
}->[0] || 'Rose::DB::Object'
do {
"${class}::ISA"
}->[0]
Truth table0%0/2
A
A= delete $args{'isa'}
Truth table0%0/2
A
A= do {
"${class}::ISA"
}->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | ▶ | $isa = [ $isa ] unless(ref $isa); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | my %use; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | foreach my $fk ($self->foreign_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | $use{$fk->class}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | foreach my $rel ($self->relationships) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | ▶ | if($rel->can('map_class')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | $use{$rel->map_class}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | $use{$rel->class}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | my $foreign_modules = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | ▶ | if(%use && !$self->auto_load_related_classes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
%use and not $self->auto_load_related_classes
MC/DC0%0/2
%use and not $self->auto_load_related_classes
%use
not $self->auto_load_related_classes
Truth table0%0/3
A and not(B)
A= %useB= not $self->auto_load_related_classes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | $foreign_modules = "\n\n" . join("\n", map { "use $_;"} sort keys %use); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | ▶ | if(defined $args{'use_setup'} && !$args{'use_setup'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args{"use_setup"} and not $args{"use_setup"}
MC/DC0%0/2
defined $args{"use_setup"} and not $args{"use_setup"}
defined $args{"use_setup"}
not $args{"use_setup"}
Truth table0%0/3
A and not(B)
A= defined $args{"use_setup"}B= not $args{"use_setup"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | return<<"EOF"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | package $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | use base qw(@$isa);$foreign_modules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | @{[ $self->perl_table_definition(%args) ]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | @{[join("\n", grep { /\S/ } $self->perl_columns_definition(%args), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | $self->perl_primary_key_columns_definition(%args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | $self->perl_unique_keys_definition(%args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | $self->perl_metadata_attributes(%args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | $self->perl_foreign_keys_definition(%args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | $self->perl_relationships_definition(%args))]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | __PACKAGE__->meta->initialize; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | my $setup_start = '__PACKAGE__->meta->setup'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | ▶ | if($braces eq 'bsd') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | $setup_start .= "\n("; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | elsif($braces eq 'k&r') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | $setup_start .= "("; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | Carp::croak 'Invalid ', (defined $args{'braces'} ? '' : 'default '), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | "brace style: '$braces'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | $args{'for_setup'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | $indent = ' ' x $indent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | return<<"EOF"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | package $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | use base qw(@$isa);$foreign_modules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | $setup_start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | @{[join("\n\n", grep { /\S/ } $self->perl_table_definition(%args), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | $self->perl_columns_definition(%args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | $self->perl_primary_key_columns_definition(%args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | $self->perl_unique_keys_definition(%args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | $self->perl_metadata_attributes(%args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | $self->perl_foreign_keys_definition(%args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | $self->perl_relationships_definition(%args))]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | ▶ | sub auto_generate_unique_keys { die "Override in subclass" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_generate_unique_keys: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | sub auto_init_unique_keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_unique_keys: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | ▶ | return if(exists $args{'with_unique_keys'} && !$args{'with_unique_keys'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $args{"with_unique_keys"} and not $args{"with_unique_keys"}
MC/DC0%0/2
exists $args{"with_unique_keys"} and not $args{"with_unique_keys"}
exists $args{"with_unique_keys"}
not $args{"with_unique_keys"}
Truth table0%0/3
A and not(B)
A= exists $args{"with_unique_keys"}B= not $args{"with_unique_keys"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | my $pk_cols = join("\0", $self->primary_key_columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | ▶ | unless(length $pk_cols) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | $pk_cols = join("\0", $self->auto_retrieve_primary_key_column_names); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | my $auto_unique_keys = $self->auto_generate_unique_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | my $existing_unique_keys = $self->unique_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | ▶ | if(!$args{'replace_existing'} && @$auto_unique_keys != @$existing_unique_keys) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not $args{"replace_existing"} and @$auto_unique_keys != @$existing_unique_keys
MC/DC0%0/2
not $args{"replace_existing"} and @$auto_unique_keys != @$existing_unique_keys
not $args{"replace_existing"}
@$auto_unique_keys != @$existing_unique_keys
Truth table0%0/3
not(A) and B
A= not $args{"replace_existing"}B= @$auto_unique_keys != @$existing_unique_keys
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | KEY: foreach my $key (@$auto_unique_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | my $id = join("\0", sort map { lc } $key->column_names); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | foreach my $existing_key (@$existing_unique_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | next KEY if($id eq join("\0", sort map { lc } $existing_key->column_names)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | # Skip primary key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | ▶ | next KEY if($pk_cols eq join("\0", $key->column_names)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | $self->add_unique_key($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | ▶ | elsif($args{'replace_existing'} || !@$existing_unique_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"replace_existing"} or not @$existing_unique_keys
MC/DC0%0/2
$args{"replace_existing"} or not @$existing_unique_keys
$args{"replace_existing"}
not @$existing_unique_keys
Truth table0%0/3
A or not(B)
A= $args{"replace_existing"}B= not @$existing_unique_keys
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | $self->unique_keys(@$auto_unique_keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | sub auto_init_foreign_keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_foreign_keys: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | ▶ | if(exists $args{'with_foreign_keys'} && !$args{'with_foreign_keys'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $args{"with_foreign_keys"} and not $args{"with_foreign_keys"}
MC/DC0%0/2
exists $args{"with_foreign_keys"} and not $args{"with_foreign_keys"}
exists $args{"with_foreign_keys"}
not $args{"with_foreign_keys"}
Truth table0%0/3
A and not(B)
A= exists $args{"with_foreign_keys"}B= not $args{"with_foreign_keys"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | $self->initialized_foreign_keys(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | my $auto_foreign_keys = $self->auto_generate_foreign_keys(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | my $existing_foreign_keys = $self->foreign_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | ▶ | if(!$args{'replace_existing'} && @$auto_foreign_keys != @$existing_foreign_keys) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not $args{"replace_existing"} and @$auto_foreign_keys != @$existing_foreign_keys
MC/DC0%0/2
not $args{"replace_existing"} and @$auto_foreign_keys != @$existing_foreign_keys
not $args{"replace_existing"}
@$auto_foreign_keys != @$existing_foreign_keys
Truth table0%0/3
not(A) and B
A= not $args{"replace_existing"}B= @$auto_foreign_keys != @$existing_foreign_keys
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | KEY: foreach my $key (@$auto_foreign_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | my $id = __fk_key_to_id($key); # $key->id; # might not have parent yet | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | foreach my $existing_key (@$existing_foreign_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | ▶ | next KEY if($id eq __fk_key_to_id($existing_key)); # $existing_key->id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | $self->add_foreign_key($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | ▶ | elsif($args{'replace_existing'} || !@$existing_foreign_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"replace_existing"} or not @$existing_foreign_keys
MC/DC0%0/2
$args{"replace_existing"} or not @$existing_foreign_keys
$args{"replace_existing"}
not @$existing_foreign_keys
Truth table0%0/3
A or not(B)
A= $args{"replace_existing"}B= not @$existing_foreign_keys
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | $self->foreign_keys(@$auto_foreign_keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | $self->initialized_foreign_keys(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | sub __fk_key_to_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__fk_key_to_id: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | my($fk) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | my $key_columns = $fk->key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | join("\0", map { join("\1", $_, $key_columns->{$_}) } sort keys %$key_columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | sub auto_init_primary_key_columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_primary_key_columns: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | my $primary_key_columns = $self->auto_retrieve_primary_key_column_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | unless($primary_key_columns && @$primary_key_columns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$primary_key_columns and @$primary_key_columns
MC/DC0%0/2
$primary_key_columns and @$primary_key_columns
$primary_key_columns
@$primary_key_columns
Truth table0%0/3
A and B
A= $primary_key_columnsB= @$primary_key_columns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | ▶ | if($Missing_PK_OK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | $primary_key_columns = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | Carp::croak "Could not retrieve primary key columns for class ", ref($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | $self->primary_key_columns(@$primary_key_columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | my %Auto_Rel_Types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | sub auto_init_relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_relationships: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | my(%args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | my $type_map = $self->relationship_type_classes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | my @all_types = keys %$type_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | my %types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | ▶ | if(delete $args{'restore_types'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | ▶ | if(my $types = $Auto_Rel_Types{$self->class}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | $args{'types'} = $types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | ▶ | if(exists $args{'relationship_types'} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $args{"relationship_types"} or exists $args{"types"} or exists $args{"with_relationships"}
exists $args{"relationship_types"} or exists $args{"types"}
MC/DC0%0/3
exists $args{"relationship_types"} or exists $args{"types"} or exists $args{"with_relationships"}
exists $args{"relationship_types"}
exists $args{"types"}
exists $args{"with_relationships"}
Truth table0%0/4
A or B or C
A= exists $args{"relationship_types"}B= exists $args{"types"}C= exists $args{"with_relationships"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | exists $args{'types'} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | exists $args{'with_relationships'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | my $types = exists $args{'relationship_types'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | delete $args{'relationship_types'} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | exists $args{'types'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | delete $args{'types'} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | exists $args{'with_relationships'} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | ▶ | delete $args{'with_relationships'} : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | ▶ | if(ref $types) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | %types = map { $_ => 1 } @$types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | $Auto_Rel_Types{$self->class} = $types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | elsif($types) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | %types = map { $_ => 1 } @all_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 0 | $Auto_Rel_Types{$self->class} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 0 | %types = map { $_ => 1 } @all_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | ▶ | if(delete $args{'replace_existing'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 0 | foreach my $rel ($self->relationships) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | ▶ | next unless($types{$rel->type}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | $self->delete_relationship($rel->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | foreach my $type (sort { $self->sort_relationship_types($a, $b) } keys %types) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | my $type_name = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | for($type_name) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | s/ /_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 0 | s/\W+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 0 | my $method = 'auto_init_' . $type_name . '_relationships'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | ▶ | if($self->can($method)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | $self->$method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | sub sort_relationship_types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_relationship_types: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 0 | my($self, $a, $b) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | return $self->relationship_type_rank($a) <=> $self->relationship_type_rank($b); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | sub auto_init_one_to_one_relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_one_to_one_relationships: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | my $class = $self->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | # For each foreign key in this class, try to make a "one to one" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | # relationship in the table that the foreign key points to. But | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | # don't do so unless the keys on both sides of the relationship | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | # are unique or primary keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 0 | FK: foreach my $fk ($self->foreign_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | my $f_class = $fk->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | ▶ | next unless($f_class && UNIVERSAL::isa($f_class, 'Rose::DB::Object')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$f_class and UNIVERSAL::isa($f_class, "Rose::DB::Object")
MC/DC0%0/2
$f_class and UNIVERSAL::isa($f_class, "Rose::DB::Object")
$f_class
UNIVERSAL::isa($f_class, "Rose::DB::Object")
Truth table0%0/3
A and B
A= $f_classB= UNIVERSAL::isa($f_class, "Rose::DB::Object")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | my $f_meta = $f_class->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | my $key_cols = $fk->key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | # If both sides of the column map are unique or primary keys, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | # this is really a one-to-one relationship | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | my $local_key = join("\0", sort keys %$key_cols); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | my $remote_key = join("\0", sort values %$key_cols); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | my($local_unique, $remote_unique); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | my $local_meta = $class->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | foreach my $uk ($local_meta->primary_key, $local_meta->unique_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | my $key = join("\0", sort $uk->columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | ▶ | if($key eq $local_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | $local_unique = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | foreach my $uk ($f_meta->primary_key, $f_meta->unique_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | my $key = join("\0", sort $uk->columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | ▶ | if($key eq $remote_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | $remote_unique = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | ▶ | unless($local_unique && $remote_unique) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$local_unique and $remote_unique
MC/DC0%0/2
$local_unique and $remote_unique
$local_unique
$remote_unique
Truth table0%0/3
A and B
A= $local_uniqueB= $remote_unique
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | next FK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | # This is really a one-to-one fk/relationship | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | $fk->relationship_type('one to one'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | # Find the associated relationship and change its type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | foreach my $rel ($self->relationships) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | ▶ | next unless($rel->can('foreign_key')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | ▶ | my $rel_fk = $rel->foreign_key or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | ▶ | if($rel_fk eq $fk) # string match on stringified object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 0 | my $new_rel = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | $self->_build_relationship(name => $rel->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | type => 'one to one', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | info => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | class => $rel->class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | column_map => scalar $rel->column_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | $new_rel->foreign_key($fk); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | $self->relationship($rel->name => $new_rel); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 0 | my $cm = $f_meta->convention_manager; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | # Also don't add one to one relationships between a class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | # and one of its map classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 0 | ▶ | if($cm->is_map_class($class) && !$args{'include_map_class_relationships'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$cm->is_map_class($class) and not $args{"include_map_class_relationships"}
MC/DC0%0/2
$cm->is_map_class($class) and not $args{"include_map_class_relationships"}
$cm->is_map_class($class)
not $args{"include_map_class_relationships"}
Truth table0%0/3
A and not(B)
A= $cm->is_map_class($class)B= not $args{"include_map_class_relationships"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 0 | ▶ | $Debug && warn "$f_class - Refusing to make one to one relationship ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | "to map class to $class\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 0 | next FK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 0 | my $name = $cm->auto_relationship_name_one_to_one($self->table, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | my $relationship = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | $f_meta->_build_relationship(name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | type => 'one to one', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | info => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | column_map => { reverse %$key_cols }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | # Skip if there's already a relationship with the same id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | foreach my $rel ($f_meta->relationships) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | ▶ | next FK if($relationship->id eq $rel->id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | # Add the one to one relationship to the foreign class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | ▶ | unless($f_meta->relationship($name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | ▶ | $Debug && warn "$f_class - Adding one to one relationship ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | "'$name' to $class\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 0 | $f_meta->add_relationship($relationship); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | # Create the methods, preserving existing methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | $f_meta->make_relationship_methods(name => $name, preserve_existing => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 0 | ▶ | sub auto_init_many_to_one_relationships { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_many_to_one_relationships: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | sub auto_init_one_to_many_relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_one_to_many_relationships: not called CC=27 SCAR=66.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 0 | my $class = $self->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | # For each foreign key in this class, try to make a "one to many" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | # relationship in the table that the foreign key points to. But | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | # don't do so if there's already a one to one relationship in that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | # class that references all of the foreign key's columns. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | 0 | FK: foreach my $fk ($self->foreign_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 0 | my $f_class = $fk->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | ▶ | next unless($f_class && UNIVERSAL::isa($f_class, 'Rose::DB::Object')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$f_class and UNIVERSAL::isa($f_class, "Rose::DB::Object")
MC/DC0%0/2
$f_class and UNIVERSAL::isa($f_class, "Rose::DB::Object")
$f_class
UNIVERSAL::isa($f_class, "Rose::DB::Object")
Truth table0%0/3
A and B
A= $f_classB= UNIVERSAL::isa($f_class, "Rose::DB::Object")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | my $f_meta = $f_class->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | my $key_cols = $fk->key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | # Check for any one to one relationships that reference the foreign | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | # key's columns. If found, don't try to make the one to many rel. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | REL: foreach my $rel ($f_meta->relationships) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | ▶ | if($rel->can('map_class')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 0 | ▶ | next unless($rel->map_class eq $class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | ▶ | next unless($rel->class eq $class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | ▶ | if($rel->type eq 'one to one' && !$rel->foreign_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rel->type eq "one to one" and not $rel->foreign_key
MC/DC0%0/2
$rel->type eq "one to one" and not $rel->foreign_key
$rel->type eq "one to one"
not $rel->foreign_key
Truth table0%0/3
A and not(B)
A= $rel->type eq "one to one"B= not $rel->foreign_key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | 0 | my $skip = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | 0 | ▶ | my $col_map = $rel->column_map or next REL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 0 | foreach my $remote_col (values %$col_map) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 0 | ▶ | $skip = 0 unless($key_cols->{$remote_col}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 0 | ▶ | next FK if($skip); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | # If both sides of the column map are unique or primary keys, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | # this is really a one-to-one relationship | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 0 | my $local_key = join("\0", sort keys %$key_cols); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | my $remote_key = join("\0", sort values %$key_cols); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 0 | my($local_unique, $remote_unique); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | my $local_meta = $class->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | foreach my $uk ($local_meta->primary_key, $local_meta->unique_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | 0 | my $key = join("\0", sort $uk->columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 0 | ▶ | if($key eq $local_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 0 | $local_unique = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 0 | foreach my $uk ($f_meta->primary_key, $f_meta->unique_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | 0 | my $key = join("\0", sort $uk->columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | ▶ | if($key eq $remote_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 0 | $remote_unique = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | ▶ | if($local_unique && $remote_unique) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$local_unique and $remote_unique
MC/DC0%0/2
$local_unique and $remote_unique
$local_unique
$remote_unique
Truth table0%0/3
A and B
A= $local_uniqueB= $remote_unique
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | next FK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 0 | my $cm = $f_meta->convention_manager; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | # Also don't add one to many relationships between a class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | # and one of its map classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 0 | ▶ | if($cm->is_map_class($class) && !$args{'include_map_class_relationships'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$cm->is_map_class($class) and not $args{"include_map_class_relationships"}
MC/DC0%0/2
$cm->is_map_class($class) and not $args{"include_map_class_relationships"}
$cm->is_map_class($class)
not $args{"include_map_class_relationships"}
Truth table0%0/3
A and not(B)
A= $cm->is_map_class($class)B= not $args{"include_map_class_relationships"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | ▶ | $Debug && warn "$f_class - Refusing to make one to many relationship ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | "to map class to $class\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | next FK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | 0 | my $name = $cm->auto_relationship_name_one_to_many($self->table, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | my $relationship = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | $f_meta->_build_relationship(name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | type => 'one to many', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | info => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | column_map => { reverse %$key_cols }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | # Skip if there's already a relationship with the same id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 0 | foreach my $rel ($f_meta->relationships) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | ▶ | next FK if($relationship->id eq $rel->id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | # Add the one to many relationship to the foreign class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 0 | ▶ | unless($f_meta->relationship($name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | ▶ | $Debug && warn "$f_class - Adding one to many relationship ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | "'$name' to $class\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 0 | $f_meta->add_relationship($relationship); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | # Create the methods, preserving existing methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 0 | $f_meta->make_relationship_methods(name => $name, preserve_existing => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | sub auto_init_many_to_many_relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_many_to_many_relationships: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | my $class = $self->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | 0 | my $cm = $self->convention_manager; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | # Nevermind if this isn't a map class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 0 | ▶ | return unless($cm->is_map_class($class)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | my @fks = $self->foreign_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | # It's got to have just two foreign keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | ▶ | return unless(@fks == 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | my $key_cols1 = $fks[0]->key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | my $key_cols2 = $fks[1]->key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | # Each foreign key must have key columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 0 | ▶ | return unless($key_cols1 && keys %$key_cols1 && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$key_cols1 and keys %$key_cols1 and $key_cols2 and keys %$key_cols2
$key_cols1 and keys %$key_cols1 and $key_cols2
$key_cols1 and keys %$key_cols1
MC/DC0%0/4
$key_cols1 and keys %$key_cols1 and $key_cols2 and keys %$key_cols2
$key_cols1
keys %$key_cols1
$key_cols2
keys %$key_cols2
Truth table0%0/5
A and B and C and D
A= $key_cols1B= keys %$key_cols1C= $key_cols2D= keys %$key_cols2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | $key_cols2 && keys %$key_cols2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 0 | my $map_class = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | # Make many to many relationships in both foreign classes that go | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | # through this map table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | PAIR: foreach my $pair ([ @fks ], [ reverse @fks ]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | my($fk1, $fk2) = @$pair; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | my $class1 = $fk1->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | my $class2 = $fk2->class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | 0 | my $meta = $class1->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | my $name = $cm->auto_relationship_name_many_to_many($fk2, $map_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 0 | my $relationship = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | $meta->_build_relationship(name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | type => 'many to many', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | info => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | map_class => $map_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | map_from => $fk1->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | map_to => $fk2->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | # Skip if there's already a relationship with the same id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 0 | foreach my $rel ($meta->relationships) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 0 | ▶ | next PAIR if($relationship->id eq $rel->id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | ▶ | unless($meta->relationship($name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 0 | ▶ | $Debug && warn "$class1 - Adding many to many relationship '$name' ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | "through $map_class to $class2\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | $meta->add_relationship($relationship); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | # Create the methods, preserving existing methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 0 | $meta->make_relationship_methods(name => $name, preserve_existing => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | sub auto_init_metadata_attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_init_metadata_attributes: not called CC=3 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | foreach my $column ($self->columns) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | 32 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 0 | ▶ | if($column->default =~ /^\w+\(.*\)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 0 | $self->allow_inline_column_values(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | sub auto_initialize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_initialize: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 0 | my(%args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 0 | $self->auto_init_args({ %args }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | $self->allow_auto_initialization(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | $self->is_auto_initializating(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 0 | $self->auto_init_columns(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | 0 | $self->auto_init_primary_key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | $self->auto_init_unique_keys(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 0 | $self->auto_init_foreign_keys(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 0 | $self->auto_init_relationships(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 0 | $self->auto_init_metadata_attributes(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | $self->initialize(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | # Don't seem to need this anymore... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | #unless($args{'passive'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | #{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | # for(1 .. 2) # two passes are required to catch everything | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | # $self->retry_deferred_foreign_keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | # $self->retry_deferred_relationships; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | # $self->retry_deferred_tasks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 0 | ▶ | unless($args{'stay_connected'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | my $meta_class = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | $meta_class->clear_all_dbs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 0 | $self->is_auto_initializating(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 0 | $self->was_auto_initialized(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 32 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||