« blib/lib/DBIx/Class/Schema/Loader/DBObject/Sybase.pm
↑ Summary
blib/lib/DBIx/Class/Schema/Loader/DBI/ODBC/SQL_Anywhere.pm »
| 1 | package DBIx::Class::Schema::Loader::RelBuilder; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 51 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 51 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 51 | ▶ | use base 'Class::Accessor::Grouped'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 51 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 51 | ▶ | use Carp::Clan qw/^DBIx::Class/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 51 | ▶ | use Scalar::Util 'weaken'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 51 | ▶ | use DBIx::Class::Schema::Loader::Utils qw/split_name slurp_file array_eq apply uniq/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 51 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 51 | ▶ | use List::Util qw/all any first/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 51 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 51 | ▶ | use Lingua::EN::Inflect::Phrase (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 51 | ▶ | use Lingua::EN::Tagger (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 51 | ▶ | use String::ToIdentifier::EN (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 51 | ▶ | use String::ToIdentifier::EN::Unicode (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 51 | ▶ | use Class::Unload (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 51 | ▶ | use Class::Inspector (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 51 | our $VERSION = '0.07053'; | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Glossary: | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # local_relname -- name of relationship from the local table referring to the remote table | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # remote_relname -- name of relationship from the remote table referring to the local table | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # remote_method -- relationship type from remote table to local table, usually has_many | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | DBIx::Class::Schema::Loader::RelBuilder - Builds relationships for DBIx::Class::Schema::Loader | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | See L<DBIx::Class::Schema::Loader> and L<DBIx::Class::Schema::Loader::Base>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | This class builds relationships for L<DBIx::Class::Schema::Loader>. This | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | is module is not (yet) for external use. | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | Arguments: $loader object | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | =head2 generate_code | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Arguments: | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | [ local_moniker1 (scalar), fk_info1 (arrayref), uniq_info1 (arrayref) ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | [ local_moniker2 (scalar), fk_info2 (arrayref), uniq_info2 (arrayref) ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | This generates the code for the relationships of each table. | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | C<local_moniker> is the moniker name of the table which had the REFERENCES | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | statements. The fk_info arrayref's contents should take the form: | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | local_table => 'some_table', | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | local_moniker => 'SomeTable', | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | local_columns => [ 'col2', 'col3' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | remote_table => 'another_table_moniker', | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | remote_moniker => 'AnotherTableMoniker', | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | remote_columns => [ 'col5', 'col7' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | local_table => 'some_other_table', | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | local_moniker => 'SomeOtherTable', | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | local_columns => [ 'col1', 'col4' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | remote_table => 'yet_another_table_moniker', | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | remote_moniker => 'YetAnotherTableMoniker', | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | remote_columns => [ 'col1', 'col2' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | The uniq_info arrayref's contents should take the form: | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | uniq_constraint_name => [ 'col1', 'col2' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | another_uniq_constraint_name => [ 'col1', 'col2' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | This method will return the generated relationships as a hashref keyed on the | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | class names. The values are arrayrefs of hashes containing method name and | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | arguments, like so: | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 'Some::Source::Class' => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | { method => 'belongs_to', arguments => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 'col1', 'Another::Source::Class' ] }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | { method => 'has_many', arguments => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 'anothers', 'Yet::Another::Source::Class', 'col15' ] }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 'Another::Source::Class' => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 51 | __PACKAGE__->mk_group_accessors('simple', qw/ | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | loader | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | schema | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | inflect_plural | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | inflect_singular | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | relationship_attrs | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | rel_collision_map | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | rel_name_map | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | allow_extra_m2m_cols | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | _temp_classes | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | __tagger | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | /); | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 135 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 135 | my ($class, $loader) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # from old POD about this constructor: | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # C<$schema_class> should be a schema class name, where the source | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # classes have already been set up and registered. Column info, | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # primary key, and unique constraints will be drawn from this | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # schema for all of the existing source monikers. | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # Options inflect_plural and inflect_singular are optional, and | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # are better documented in L<DBIx::Class::Schema::Loader::Base>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | my $self = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | loader => $loader, | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 135 | (map { $_ => $loader->$_ } qw( | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | schema inflect_plural inflect_singular | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | relationship_attrs rel_collision_map | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | rel_name_map allow_extra_m2m_cols | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | )), | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | _temp_classes => [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 135 | weaken $self->{loader}; #< don't leak | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 135 | bless $self => $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # validate the relationship_attrs arg | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 135 | ▶ | if( defined $self->relationship_attrs ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 5 | ▶ | (ref $self->relationship_attrs eq 'HASH' || ref $self->relationship_attrs eq 'CODE') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $self->relationship_attrs eq "HASH" or ref $self->relationship_attrs eq "CODE"
MC/DC100%2/2
ref $self->relationship_attrs eq "HASH" or ref $self->relationship_attrs eq "CODE"
ref $self->relationship_attrs eq "HASH"
ref $self->relationship_attrs eq "CODE"
Truth table100%3/3
A or B
A= ref $self->relationship_attrs eq "HASH"B= ref $self->relationship_attrs eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | or croak "relationship_attrs must be a hashref or coderef"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 133 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # pluralize a relationship name | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 896 | ▶ | sub _inflect_plural { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inflect_plural: called CC=8 SCAR=23.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 896 | my ($self, $relname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 896 | ▶ | return '' if !defined $relname || $relname eq ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $relname or $relname eq ""
MC/DC0%0/2
not defined $relname or $relname eq ""
not defined $relname
$relname eq ""
Truth table33%1/3
not(A) or B
A= not defined $relnameB= $relname eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 896 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | 896 | my $mapped = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 896 | ▶ | if( ref $self->inflect_plural eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 404 | ▶ | if (exists $self->inflect_plural->{$relname}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 6 | $result = $self->inflect_plural->{$relname}; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 6 | $mapped = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | elsif( ref $self->inflect_plural eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $inflected = $self->inflect_plural->($relname); | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($inflected) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $result = $inflected; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $mapped = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 896 | ▶ | return ($result, $mapped) if $mapped; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 890 | return ($self->_to_PL($relname), 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # Singularize a relationship name | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 734 | ▶ | sub _inflect_singular { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inflect_singular: called CC=8 SCAR=23.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 734 | my ($self, $relname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 734 | ▶ | return '' if !defined $relname || $relname eq ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $relname or $relname eq ""
MC/DC0%0/2
not defined $relname or $relname eq ""
not defined $relname
$relname eq ""
Truth table33%1/3
not(A) or B
A= not defined $relnameB= $relname eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 734 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | 734 | my $mapped = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 734 | ▶ | if( ref $self->inflect_singular eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 297 | ▶ | if (exists $self->inflect_singular->{$relname}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 6 | $result = $self->inflect_singular->{$relname}; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | $mapped = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | elsif( ref $self->inflect_singular eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $inflected = $self->inflect_singular->($relname); | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ($inflected) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $result = $inflected; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $mapped = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 734 | ▶ | return ($result, $mapped) if $mapped; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 728 | return ($self->_to_S($relname), 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 825 | ▶ | sub _to_PL { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_PL: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 825 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 825 | $name =~ s/_/ /g; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | 825 | my $plural = Lingua::EN::Inflect::Phrase::to_PL($name); | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | 825 | $plural =~ s/ /_/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 825 | return $plural; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 662 | ▶ | sub _to_S { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_S: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 662 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 662 | $name =~ s/_/ /g; | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | 662 | my $singular = Lingua::EN::Inflect::Phrase::to_S($name); | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | 662 | $singular =~ s/ /_/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 662 | return $singular; | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1226 | ▶ | sub _default_relationship_attrs { +{ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_relationship_attrs: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1226 | has_many => { | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | cascade_delete => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | cascade_copy => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | might_have => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | cascade_delete => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | cascade_copy => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | belongs_to => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | on_delete => 'CASCADE', | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | on_update => 'CASCADE', | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | is_deferrable => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } } | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # Accessor for options to be passed to each generated relationship type. takes | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # the relationship type name and optionally any attributes from the database | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # (such as FK ON DELETE/UPDATE and DEFERRABLE clauses), and returns a | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # hashref or undef if nothing is set. | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # The attributes from the database override the default attributes, which in | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # turn are overridden by user supplied attributes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1298 | ▶ | sub _relationship_attrs { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_relationship_attrs: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1298 | my ( $self, $reltype, $db_attrs, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1298 | my $r = $self->relationship_attrs; | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | my %composite = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1298 | ▶ | %{ $self->_default_relationship_attrs->{$reltype} || {} }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_default_relationship_attrs->{$reltype} || {}
MC/DC100%1/1
$self->_default_relationship_attrs->{$reltype} || {}
$self->_default_relationship_attrs->{$reltype}
Truth table100%2/2
A
A= $self->_default_relationship_attrs->{$reltype}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1298 | ▶ | %{ $db_attrs || {} }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$db_attrs || {}
MC/DC0%0/1
$db_attrs || {}
$db_attrs
Truth table50%1/2
A
A= $db_attrs
| |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ref $r eq 'HASH' ? ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 546 | ▶ | %{ $r->{all} || {} }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$r->{'all'} || {}
MC/DC100%1/1
$r->{'all'} || {}
$r->{'all'}
Truth table100%2/2
A
A= $r->{'all'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1298 | ▶ | %{ $r->{$reltype} || {} }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$r->{$reltype} || {}
MC/DC100%1/1
$r->{$reltype} || {}
$r->{$reltype}
Truth table100%2/2
A
A= $r->{$reltype}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | : | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | () | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1298 | ▶ | if (ref $r eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 2 | $params->{attrs} = \%composite; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | ▶ | my %ret = %{ $r->(%$params) || {} }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
&$r(%$params) || {}
MC/DC0%0/1
&$r(%$params) || {}
&$r(%$params)
Truth table50%1/2
A
A= &$r(%$params)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | ▶ | %composite = %ret if %ret; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 1298 | ▶ | return %composite ? \%composite : undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub _strip_id_postfix { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_id_postfix: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $name =~ s/_?(?:id|ref|cd|code|num)\z//i; | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | return $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 588 | ▶ | sub _remote_attrs { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remote_attrs: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 588 | my ($self, $local_moniker, $local_cols, $fk_attrs, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # get our set of attrs from _relationship_attrs, which uses the FK attrs if available | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 588 | ▶ | my $attrs = $self->_relationship_attrs('belongs_to', $fk_attrs, $params) || {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_relationship_attrs('belongs_to', $fk_attrs, $params) || {}
MC/DC0%0/1
$self->_relationship_attrs('belongs_to', $fk_attrs, $params) || {}
$self->_relationship_attrs('belongs_to', $fk_attrs, $params)
Truth table50%1/2
A
A= $self->_relationship_attrs('belongs_to', $fk_attrs, $params)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # If any referring column is nullable, make 'belongs_to' an | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # outer join, unless explicitly set by relationship_attrs | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 588 | ▶ | my $nullable = first { $self->schema->source($local_moniker)->column_info($_)->{is_nullable} } @$local_cols; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 588 | ▶ | $attrs->{join_type} = 'LEFT' if $nullable && !defined $attrs->{join_type}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$nullable and not defined $attrs->{"join_type"}
MC/DC50%1/2
$nullable and not defined $attrs->{"join_type"}
$nullable
not defined $attrs->{"join_type"}
Truth table66%2/3
A and not(B)
A= $nullableB= not defined $attrs->{"join_type"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 588 | return $attrs; | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 2119 | ▶ | sub _sanitize_name { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sanitize_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 2119 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2119 | $name = $self->loader->_to_identifier('relationships', $name, '_'); | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 2119 | $name =~ s/\W+/_/g; # if naming >= 8 to_identifier takes care of it | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 2119 | return $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 2087 | ▶ | sub _normalize_name { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_normalize_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 2087 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 2087 | $name = $self->_sanitize_name($name); | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 2087 | my @words = split_name $name, $self->loader->_get_naming_v('relationships'); | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 2087 | return join '_', map lc, @words; | |||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 589 | ▶ | sub _local_relname { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_local_relname: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 589 | my ($self, $remote_table, $cond) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 589 | my $local_relname; | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | # for single-column case, set the remote relname to the column | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # name, to make filter accessors work, but strip trailing _id | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 589 | ▶ | if(scalar keys %{$cond} == 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 540 | my ($col) = values %{$cond}; | |||||||||||||||||||||||||||||||||||||||||||||
| 338 | 540 | $col = $self->_strip_id_postfix($self->_normalize_name($col)); | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | 540 | ($local_relname) = $self->_inflect_singular($col); | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 49 | ($local_relname) = $self->_inflect_singular($self->_normalize_name($remote_table)); | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 589 | return $local_relname; | |||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 1372 | ▶ | sub _resolve_relname_collision { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_relname_collision: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 1372 | my ($self, $moniker, $cols, $relname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1372 | ▶ | return $relname if $relname eq 'id'; # this shouldn't happen, but just in case | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 1358 | my $table = $self->loader->moniker_to_table->{$moniker}; | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 1358 | ▶ | if ($self->loader->_is_result_class_method($relname, $table)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 14 | ▶ | if (my $map = $self->rel_collision_map) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 12 | for my $re (keys %$map) { | |||||||||||||||||||||||||||||||||||||||||||||
| 358 | 12 | ▶ | if (my @matches = $relname =~ /$re/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 6 | return sprintf $map->{$re}, @matches; | |||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 8 | my $new_relname = $relname; | |||||||||||||||||||||||||||||||||||||||||||||
| 365 | 8 | ▶ | while ($self->loader->_is_result_class_method($new_relname, $table)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 8 | $new_relname .= '_rel' | |||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 8 | warn <<"EOF"; | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | 8 | Relationship '$relname' in source '$moniker' for columns '@{[ join ',', @$cols ]}' collides with an inherited method. Renaming to '$new_relname'. | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | See "RELATIONSHIP NAME COLLISIONS" in perldoc DBIx::Class::Schema::Loader::Base . | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 8 | return $new_relname; | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1344 | return $relname; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 138 | ▶ | sub generate_code { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_code: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 138 | my ($self, $tables) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # make a copy to destroy | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 138 | my @tables = @$tables; | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 138 | my $all_code = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 138 | ▶ | while (my ($local_moniker, $rels, $uniqs) = @{ shift @tables || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
shift @tables || []
MC/DC100%1/1
shift @tables || []
shift @tables
Truth table100%2/2
A
A= shift @tables
| |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 817 | my $local_class = $self->schema->class($local_moniker); | |||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 817 | my %counters; | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | 817 | foreach my $rel (@$rels) { | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | 647 | ▶ | next if !$rel->{remote_source}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 647 | $counters{$rel->{remote_source}}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 817 | foreach my $rel (@$rels) { | |||||||||||||||||||||||||||||||||||||||||||||
| 398 | my $remote_moniker = $rel->{remote_source} | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 647 | ▶ | or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 647 | my $remote_class = $self->schema->class($remote_moniker); | |||||||||||||||||||||||||||||||||||||||||||||
| 402 | 647 | my $remote_obj = $self->schema->source($remote_moniker); | |||||||||||||||||||||||||||||||||||||||||||||
| 403 | 647 | ▶ | my $remote_cols = $rel->{remote_columns} || [ $remote_obj->primary_columns ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$rel->{'remote_columns'} || [$remote_obj->primary_columns]
MC/DC100%1/1
$rel->{'remote_columns'} || [$remote_obj->primary_columns]
$rel->{'remote_columns'}
Truth table100%2/2
A
A= $rel->{'remote_columns'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 647 | my $local_cols = $rel->{local_columns}; | |||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 647 | ▶ | if($#$local_cols != $#$remote_cols) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | croak "Column count mismatch: $local_moniker (@$local_cols) " | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | . "$remote_moniker (@$remote_cols)"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 647 | my %cond; | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | 647 | @cond{@$remote_cols} = @$local_cols; | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 647 | my ( $local_relname, $remote_relname, $remote_method ) = | |||||||||||||||||||||||||||||||||||||||||||||
| 416 | $self->_relnames_and_method( $local_moniker, $rel, \%cond, $uniqs, \%counters ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 647 | my $local_method = 'belongs_to'; | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 647 | ($local_relname) = $self->_rel_name_map( | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | $local_relname, $local_method, | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | $local_class, $local_moniker, $local_cols, | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | $remote_class, $remote_moniker, $remote_cols, | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 646 | ($remote_relname) = $self->_rel_name_map( | |||||||||||||||||||||||||||||||||||||||||||||
| 425 | $remote_relname, $remote_method, | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | $remote_class, $remote_moniker, $remote_cols, | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | $local_class, $local_moniker, $local_cols, | ||||||||||||||||||||||||||||||||||||||||||||||
| 428 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 646 | $local_relname = $self->_resolve_relname_collision( | |||||||||||||||||||||||||||||||||||||||||||||
| 431 | $local_moniker, $local_cols, $local_relname, | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 646 | $remote_relname = $self->_resolve_relname_collision( | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | $remote_moniker, $remote_cols, $remote_relname, | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | my $rel_attrs_params = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | rel_name => $local_relname, | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | rel_type => $local_method, | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | local_source => $self->schema->source($local_moniker), | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | remote_source => $self->schema->source($remote_moniker), | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | local_table => $rel->{local_table}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | local_cols => $local_cols, | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | remote_table => $rel->{remote_table}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 646 | remote_cols => $remote_cols, | |||||||||||||||||||||||||||||||||||||||||||||
| 446 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 646 | push @{$all_code->{$local_class}}, { | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | method => $local_method, | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | args => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 451 | $local_relname, | ||||||||||||||||||||||||||||||||||||||||||||||
| 452 | $remote_class, | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | \%cond, | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 646 | $self->_remote_attrs($local_moniker, $local_cols, $rel->{attrs}, $rel_attrs_params), | |||||||||||||||||||||||||||||||||||||||||||||
| 455 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 456 | extra => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 457 | local_class => $local_class, | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | local_moniker => $local_moniker, | ||||||||||||||||||||||||||||||||||||||||||||||
| 459 | remote_moniker => $remote_moniker, | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 646 | my %rev_cond = reverse %cond; | |||||||||||||||||||||||||||||||||||||||||||||
| 464 | 646 | for (keys %rev_cond) { | |||||||||||||||||||||||||||||||||||||||||||||
| 465 | 695 | $rev_cond{"foreign.$_"} = "self.".$rev_cond{$_}; | |||||||||||||||||||||||||||||||||||||||||||||
| 466 | 695 | delete $rev_cond{$_}; | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | $rel_attrs_params = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | rel_name => $remote_relname, | ||||||||||||||||||||||||||||||||||||||||||||||
| 471 | rel_type => $remote_method, | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | local_source => $self->schema->source($remote_moniker), | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | remote_source => $self->schema->source($local_moniker), | ||||||||||||||||||||||||||||||||||||||||||||||
| 474 | local_table => $rel->{remote_table}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | local_cols => $remote_cols, | ||||||||||||||||||||||||||||||||||||||||||||||
| 476 | remote_table => $rel->{local_table}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 646 | remote_cols => $local_cols, | |||||||||||||||||||||||||||||||||||||||||||||
| 478 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 646 | push @{$all_code->{$remote_class}}, { | |||||||||||||||||||||||||||||||||||||||||||||
| 481 | method => $remote_method, | ||||||||||||||||||||||||||||||||||||||||||||||
| 482 | args => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | $remote_relname, | ||||||||||||||||||||||||||||||||||||||||||||||
| 484 | $local_class, | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | \%rev_cond, | ||||||||||||||||||||||||||||||||||||||||||||||
| 486 | $self->_relationship_attrs($remote_method, {}, $rel_attrs_params), | ||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 488 | extra => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 489 | local_class => $remote_class, | ||||||||||||||||||||||||||||||||||||||||||||||
| 490 | local_moniker => $remote_moniker, | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | remote_moniker => $local_moniker, | ||||||||||||||||||||||||||||||||||||||||||||||
| 492 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 493 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 137 | $self->_generate_m2ms($all_code); | |||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # disambiguate rels with the same name | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 137 | foreach my $class (keys %$all_code) { | |||||||||||||||||||||||||||||||||||||||||||||
| 501 | 725 | my $dups = $self->_duplicates($all_code->{$class}); | |||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 725 | ▶ | $self->_disambiguate($all_code, $class, $dups) if $dups; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 137 | $self->_cleanup; | |||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 137 | return $all_code; | |||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||
| 511 | # Find classes with only 2 FKs which are the PK and make many_to_many bridges for them. | ||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 137 | ▶ | sub _generate_m2ms { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_m2ms: called CC=14 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 137 | my ($self, $all_code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | LINK_CLASS: | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 137 | foreach my $link_class (sort keys %$all_code) { | |||||||||||||||||||||||||||||||||||||||||||||
| 517 | 725 | my @rels = grep $_->{method} eq 'belongs_to', @{$all_code->{$link_class}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 518 | 725 | ▶ | next unless @rels == 2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 118 | my @class; | |||||||||||||||||||||||||||||||||||||||||||||
| 521 | 118 | foreach my $this (0, 1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 522 | 229 | ▶ | my $that = $this ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 229 | my %class; | |||||||||||||||||||||||||||||||||||||||||||||
| 524 | 229 | $class[$this] = \%class; | |||||||||||||||||||||||||||||||||||||||||||||
| 525 | 229 | $class{local_moniker} = $rels[$this]{extra}{remote_moniker}; | |||||||||||||||||||||||||||||||||||||||||||||
| 526 | 229 | $class{remote_moniker} = $rels[$that]{extra}{remote_moniker}; | |||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 229 | $class{class} = $rels[$this]{args}[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 229 | ▶ | my %link_cols = map { $_ => 1 } apply { s/^self\.//i } values %{ $rels[$this]{args}[2] }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 496 | ▶ | $class{link_table_rel} = first { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 533 | $_->{method} eq 'has_many' | ||||||||||||||||||||||||||||||||||||||||||||||
| 534 | and | ||||||||||||||||||||||||||||||||||||||||||||||
| 535 | $_->{args}[1] eq $link_class | ||||||||||||||||||||||||||||||||||||||||||||||
| 536 | and | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 496 | ▶ | all { $link_cols{$_} } apply { s/^foreign\.//i } keys %{$_->{args}[2]} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%3/3
$_->{"method"} eq "has_many" and $_->{"args"}[1] eq $link_class
MC/DC100%2/2
$_->{"method"} eq "has_many" and $_->{"args"}[1] eq $link_class
$_->{"method"} eq "has_many"
$_->{"args"}[1] eq $link_class
Truth table100%3/3
A and B
A= $_->{"method"} eq "has_many"B= $_->{"args"}[1] eq $link_class
| |||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 229 | } @{ $all_code->{$class{class}} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 229 | ▶ | next LINK_CLASS unless $class{link_table_rel}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 222 | $class{link_table_rel_name} = $class{link_table_rel}{args}[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 222 | $class{link_rel} = $rels[$that]{args}[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 264 | ▶ | $class{from_cols} = [ apply { s/^self\.//i } values %{ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 222 | $class{link_table_rel}->{args}[2] | |||||||||||||||||||||||||||||||||||||||||||||
| 548 | } ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 222 | ▶ | $class{to_cols} = [ apply { s/^foreign\.//i } keys %{ $rels[$that]{args}[2] } ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 222 | ▶ | $class{from_link_cols} = [ apply { s/^self\.//i } values %{ $rels[$this]{args}[2] } ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 111 | my $link_moniker = $rels[0]{extra}{local_moniker}; | |||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | my @link_table_cols = | ||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 111 | @{[ $self->schema->source($link_moniker)->columns ]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||
| 560 | my @link_table_primary_cols = | ||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 111 | @{[ $self->schema->source($link_moniker)->primary_columns ]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | next unless array_eq( | ||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 111 | ▶ | [ sort +uniq @{$class[0]{from_link_cols}}, @{$class[1]{from_link_cols}} ], | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
&array_eq([sort(&uniq(@{$class[0]{"from_link_cols"};}, @{$class[1]{"from_link_cols"};}))], [sort(@link_table_primary_cols)]) and $self->allow_extra_m2m_cols || @link_table_cols == @link_table_primary_cols
$self->allow_extra_m2m_cols or @link_table_cols == @link_table_primary_cols
MC/DC33%1/3
&array_eq([sort(&uniq(@{$class[0]{"from_link_cols"};}, @{$class[1]{"from_link_cols"};}))], [sort(@link_table_primary_cols)]) and $self->allow_extra_m2m_cols || @link_table_cols == @link_table_primary_cols
&array_eq([sort(&uniq(@{$class[0]{"from_link_cols"};}, @{$class[1]{"from_link_cols"};}))], [sort(@link_table_primary_cols)])
$self->allow_extra_m2m_cols
@link_table_cols == @link_table_primary_cols
Truth table50%2/4
A and B or C
A= &array_eq([sort(&uniq(@{$class[0]{"from_link_cols"};}, @{$class[1]{"from_link_cols"};}))], [sort(@link_table_primary_cols)])B= $self->allow_extra_m2m_colsC= @link_table_cols == @link_table_primary_cols
| |||||||||||||||||||||||||||||||||||||||||||||||
| 565 | [ sort @link_table_primary_cols ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 566 | ) && ($self->allow_extra_m2m_cols || @link_table_cols == @link_table_primary_cols); | ||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 32 | foreach my $this (0, 1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 569 | 64 | ▶ | my $that = $this ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 570 | ($class[$this]{m2m_relname}) = $self->_rel_name_map( | ||||||||||||||||||||||||||||||||||||||||||||||
| 571 | ($self->_inflect_plural($class[$this]{link_rel}))[0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 'many_to_many', | ||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 64 | @{$class[$this]}{qw(class local_moniker from_cols)}, | |||||||||||||||||||||||||||||||||||||||||||||
| 574 | $class[$that]{class}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 64 | @{$class[$this]}{qw(remote_moniker to_cols)}, | |||||||||||||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 577 | link_class => $link_class, | ||||||||||||||||||||||||||||||||||||||||||||||
| 578 | link_moniker => $link_moniker, | ||||||||||||||||||||||||||||||||||||||||||||||
| 579 | link_rel_name => $class[$this]{link_table_rel_name}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 580 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 64 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||
| 583 | $class[$this]{m2m_relname} = $self->_resolve_relname_collision( | ||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 64 | @{$class[$this]}{qw(local_moniker from_cols m2m_relname)}, | |||||||||||||||||||||||||||||||||||||||||||||
| 585 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 32 | for my $this (0, 1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 589 | 64 | ▶ | my $that = $this ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 64 | push @{$all_code->{$class[$this]{class}}}, { | |||||||||||||||||||||||||||||||||||||||||||||
| 592 | method => 'many_to_many', | ||||||||||||||||||||||||||||||||||||||||||||||
| 593 | args => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 64 | ▶ | @{$class[$this]}{qw(m2m_relname link_table_rel_name link_rel)}, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->_relationship_attrs('many_to_many', {}, {'rel_type', 'many_to_many', 'rel_name', $class[$this]{'class2_relname'}, 'local_source', $self->schema->source($class[$this]{'local_moniker'}), 'remote_source', $self->schema->source($class[$this]{'remote_moniker'}), 'local_table', $self->loader->class_to_table->{$class[$this]{'class'}}, 'local_cols', $class[$this]{'from_cols'}, 'remote_table', $self->loader->class_to_table->{$class[$that]{'class'}}, 'remote_cols', $class[$that]{'from_cols'}}) || ()
MC/DC0%0/2
$self->_relationship_attrs('many_to_many', {}, {'rel_type', 'many_to_many', 'rel_name', $class[$this]{'class2_relname'}, 'local_source', $self->schema->source($class[$this]{'local_moniker'}), 'remote_source', $self->schema->source($class[$this]{'remote_moniker'}), 'local_table', $self->loader->class_to_table->{$class[$this]{'class'}}, 'local_cols', $class[$this]{'from_cols'}, 'remote_table', $self->loader->class_to_table->{$class[$that]{'class'}}, 'remote_cols', $class[$that]{'from_cols'}}) || ()
$self->_relationship_attrs('many_to_many', {}, {'rel_type', 'many_to_many', 'rel_name', $class[$this]{'class2_relname'}, 'local_source', $self->schema->source($class[$this]{'local_moniker'}), 'remote_source', $self->schema->source($class[$this]{'remote_moniker'}), 'local_table', $self->loader->class_to_table->{$class[$this]{'class'}}, 'local_cols', $class[$this]{'from_cols'}, 'remote_table', $self->loader->class_to_table->{$class[$that]{'class'}}, 'remote_cols', $class[$that]{'from_cols'}})
()
Truth table66%2/3
A || B
A= $self->_relationship_attrs('many_to_many', {}, {'rel_type', 'many_to_many', 'rel_name', $class[$this]{'class2_relname'}, 'local_source', $self->schema->source($class[$this]{'local_moniker'}), 'remote_source', $self->schema->source($class[$this]{'remote_moniker'}), 'local_table', $self->loader->class_to_table->{$class[$this]{'class'}}, 'local_cols', $class[$this]{'from_cols'}, 'remote_table', $self->loader->class_to_table->{$class[$that]{'class'}}, 'remote_cols', $class[$that]{'from_cols'}})B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 595 | $self->_relationship_attrs('many_to_many', {}, { | ||||||||||||||||||||||||||||||||||||||||||||||
| 596 | rel_type => 'many_to_many', | ||||||||||||||||||||||||||||||||||||||||||||||
| 597 | rel_name => $class[$this]{class2_relname}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 598 | local_source => $self->schema->source($class[$this]{local_moniker}), | ||||||||||||||||||||||||||||||||||||||||||||||
| 599 | remote_source => $self->schema->source($class[$this]{remote_moniker}), | ||||||||||||||||||||||||||||||||||||||||||||||
| 600 | local_table => $self->loader->class_to_table->{$class[$this]{class}}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 601 | local_cols => $class[$this]{from_cols}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 602 | remote_table => $self->loader->class_to_table->{$class[$that]{class}}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 603 | remote_cols => $class[$that]{from_cols}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 604 | }) || (), | ||||||||||||||||||||||||||||||||||||||||||||||
| 605 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 606 | extra => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 607 | local_class => $class[$this]{class}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 608 | link_class => $link_class, | ||||||||||||||||||||||||||||||||||||||||||||||
| 609 | local_moniker => $class[$this]{local_moniker}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 610 | remote_moniker => $class[$this]{remote_moniker}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 611 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 64 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 741 | ▶ | sub _duplicates { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_duplicates: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 741 | my ($self, $rels) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 741 | my @rels = map [ $_->{args}[0] => $_ ], @$rels; | |||||||||||||||||||||||||||||||||||||||||||||
| 621 | 741 | my %rel_names; | |||||||||||||||||||||||||||||||||||||||||||||
| 622 | 741 | $rel_names{$_}++ foreach map $_->[0], @rels; | |||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 741 | my @dups = grep $rel_names{$_} > 1, keys %rel_names; | |||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 741 | my %dups; | |||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 741 | foreach my $dup (@dups) { | |||||||||||||||||||||||||||||||||||||||||||||
| 629 | 18 | $dups{$dup} = [ map $_->[1], grep { $_->[0] eq $dup } @rels ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 741 | ▶ | return if not %dups; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 18 | return \%dups; | |||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 14 | ▶ | sub _tagger { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tagger: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 14 | ▶ | $self->__tagger(Lingua::EN::Tagger->new) unless $self->__tagger; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 14 | return $self->__tagger; | |||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 14 | ▶ | sub _adjectives { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_adjectives: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 14 | my ($self, @cols) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 14 | my @adjectives; | |||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 14 | foreach my $col (@cols) { | |||||||||||||||||||||||||||||||||||||||||||||
| 651 | 14 | my @words = split_name $col; | |||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 14 | my $tagged = $self->_tagger->get_readable(join ' ', @words); | |||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 14 | push @adjectives, $tagged =~ m{\G(\w+)/JJ\s+}g; | |||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 14 | return @adjectives; | |||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | sub _name_to_identifier { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_name_to_identifier: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||
| 664 | my $to_identifier = $self->loader->naming->{force_ascii} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | \&String::ToIdentifier::EN::to_identifier | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 666 | : \&String::ToIdentifier::EN::Unicode::to_identifier; | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | return join '_', map lc, split_name $to_identifier->($name, '_'); | |||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 16 | ▶ | sub _disambiguate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_disambiguate: called CC=25 SCAR=38.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 16 | my ($self, $all_code, $in_class, $dups) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 16 | DUP: foreach my $dup (keys %$dups) { | |||||||||||||||||||||||||||||||||||||||||||||
| 675 | 16 | my @rels = @{ $dups->{$dup} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||
| 677 | # Check if there are rels to the same table name in different | ||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # schemas/databases, if so qualify them. | ||||||||||||||||||||||||||||||||||||||||||||||
| 679 | my @tables = map $self->loader->moniker_to_table->{$_->{extra}{remote_moniker}}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 16 | @rels; | |||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # databases are different, prepend database | ||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 16 | ▶ | if ($tables[0]->can('database') && (uniq map $_->database||'', @tables) > 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition20%1/5
$tables[0]->can("database") and &uniq(map(($_->database || ""), @tables)) > 1
$_->database || ''
MC/DC0%0/2
$tables[0]->can("database") and &uniq(map(($_->database || ""), @tables)) > 1
$tables[0]->can("database")
&uniq(map(($_->database || ""), @tables)) > 1
MC/DC0%0/1
$_->database || ''
$_->database
Truth table33%1/3
A and B
A= $tables[0]->can("database")B= &uniq(map(($_->database || ""), @tables)) > 1
Truth table0%0/2
A
A= $_->database
| |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | # If any rels are in the same database, we have to distinguish by | ||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # both schema and database. | ||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my %db_counts; | |||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | $db_counts{$_}++ for map $_->database, @tables; | |||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | my $use_schema = any { $_ > 1 } values %db_counts; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | foreach my $i (0..$#rels) { | |||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my $rel = $rels[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | my $table = $tables[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||
| 694 | $rel->{args}[0] = $self->_name_to_identifier($table->database) | ||||||||||||||||||||||||||||||||||||||||||||||
| 695 | . ($use_schema ? ('_' . $self->name_to_identifier($table->schema)) : '') | ||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | . '_' . $rel->{args}[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | next DUP; | |||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 700 | # schemas are different, prepend schema | ||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ▶ | elsif ((uniq map $_->schema||'', @tables) > 1) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->schema || ''
MC/DC0%0/1
$_->schema || ''
$_->schema
Truth table50%1/2
A
A= $_->schema
| |||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | foreach my $i (0..$#rels) { | |||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | my $rel = $rels[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | my $table = $tables[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||
| 706 | $rel->{args}[0] = $self->_name_to_identifier($table->schema) | ||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | . '_' . $rel->{args}[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | next DUP; | |||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 16 | foreach my $rel (@rels) { | |||||||||||||||||||||||||||||||||||||||||||||
| 713 | 32 | ▶ | next if $rel->{method} =~ /^(?:belongs_to|many_to_many)\z/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 14 | ▶ | my @to_cols = apply { s/^foreign\.//i } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 14 | keys %{ $rel->{args}[2] }; | |||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 14 | my @adjectives = $self->_adjectives(@to_cols); | |||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # If there are no adjectives, and there is only one might_have | ||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # rel to that class, we hardcode 'active'. | ||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 14 | my $to_class = $rel->{args}[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 14 | ▶ | if ((not @adjectives) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not @adjectives and grep({$_->{"method"} eq "might_have" and $_->{"args"}[1] eq $to_class;} @{$$all_code{$in_class};}) == 1
MC/DC50%1/2
not @adjectives and grep({$_->{"method"} eq "might_have" and $_->{"args"}[1] eq $to_class;} @{$$all_code{$in_class};}) == 1
not @adjectives
grep({$_->{"method"} eq "might_have" and $_->{"args"}[1] eq $to_class;} @{$$all_code{$in_class};}) == 1
Truth table66%2/3
not(A) and B
A= not @adjectivesB= grep({$_->{"method"} eq "might_have" and $_->{"args"}[1] eq $to_class;} @{$$all_code{$in_class};}) == 1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 726 | && (grep { $_->{method} eq 'might_have' | ||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 21 | ▶ | && $_->{args}[1] eq $to_class } @{ $all_code->{$in_class} }) == 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_->{'method'} eq 'might_have' && $_->{'args'}[1] eq $to_class
MC/DC50%1/2
$_->{'method'} eq 'might_have' && $_->{'args'}[1] eq $to_class
$_->{'method'} eq 'might_have'
$_->{'args'}[1] eq $to_class
Truth table66%2/3
A && B
A= $_->{'method'} eq 'might_have'B= $_->{'args'}[1] eq $to_class
| |||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 7 | @adjectives = 'active'; | |||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 14 | ▶ | if (@adjectives) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 14 | my $rel_name = join '_', sort(@adjectives), $rel->{args}[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 14 | ▶ | ($rel_name) = $rel->{method} eq 'might_have' ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 736 | $self->_inflect_singular($rel_name) | ||||||||||||||||||||||||||||||||||||||||||||||
| 737 | : | ||||||||||||||||||||||||||||||||||||||||||||||
| 738 | $self->_inflect_plural($rel_name); | ||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||
| 740 | my ($local_class, $local_moniker, $remote_moniker) | ||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 14 | = @{ $rel->{extra} } | |||||||||||||||||||||||||||||||||||||||||||||
| 742 | 14 | {qw/local_class local_moniker remote_moniker/}; | |||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 14 | ▶ | my @from_cols = apply { s/^self\.//i } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 14 | values %{ $rel->{args}[2] }; | |||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 14 | ($rel_name) = $self->_rel_name_map($rel_name, $rel->{method}, $local_class, $local_moniker, \@from_cols, $to_class, $remote_moniker, \@to_cols); | |||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 14 | $rel_name = $self->_resolve_relname_collision($local_moniker, \@from_cols, $rel_name); | |||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 14 | $rel->{args}[0] = $rel_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||
| 756 | # Check again for duplicates, since the heuristics above may not have resolved them all. | ||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 16 | ▶ | if ($dups = $self->_duplicates($all_code->{$in_class})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 2 | foreach my $dup (keys %$dups) { | |||||||||||||||||||||||||||||||||||||||||||||
| 760 | # sort by method | ||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 2 | my @rels = map $_->[1], sort { $a->[0] <=> $b->[0] } map [ | |||||||||||||||||||||||||||||||||||||||||||||
| 762 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 763 | belongs_to => 3, | ||||||||||||||||||||||||||||||||||||||||||||||
| 764 | has_many => 2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 765 | might_have => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 766 | many_to_many => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 767 | }->{$_->{method}}, $_ | ||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 2 | ], @{ $dups->{$dup} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 2 | my $rel_num = 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 2 | foreach my $rel (@rels[1 .. $#rels]) { | |||||||||||||||||||||||||||||||||||||||||||||
| 773 | 2 | ▶ | my $inflect_type = $rel->{method} =~ /^(?:many_to_many|has_many)\z/ ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 'inflect_plural' | ||||||||||||||||||||||||||||||||||||||||||||||
| 775 | : | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 'inflect_singular'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 2 | my $inflect_method = "_$inflect_type"; | |||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 2 | my $relname_new_uninflected = $rel->{args}[0] . "_$rel_num"; | |||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 2 | $rel_num++; | |||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||
| 784 | my ($local_class, $local_moniker, $remote_moniker) | ||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 2 | = @{ $rel->{extra} } | |||||||||||||||||||||||||||||||||||||||||||||
| 786 | 2 | {qw/local_class local_moniker remote_moniker/}; | |||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 2 | my (@from_cols, @to_cols, $to_class); | |||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 2 | ▶ | if ($rel->{method} eq 'many_to_many') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 2 | ▶ | @from_cols = apply { s/^self\.//i } values %{ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 2 | ▶ | (first { $_->{args}[0] eq $rel->{args}[1] } @{ $all_code->{$local_class} }) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 2 | ->{args}[2] | |||||||||||||||||||||||||||||||||||||||||||||
| 794 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 2 | ▶ | @to_cols = apply { s/^foreign\.//i } keys %{ | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 2 | ▶ | (first { $_->{args}[0] eq $rel->{args}[2] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 2 | @{ $all_code->{ $rel->{extra}{link_class} } }) | |||||||||||||||||||||||||||||||||||||||||||||
| 798 | 2 | ->{args}[2] | |||||||||||||||||||||||||||||||||||||||||||||
| 799 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 2 | $to_class = $self->schema->source($remote_moniker)->result_class; | |||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 802 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | ▶ | @from_cols = apply { s/^self\.//i } values %{ $rel->{args}[2] }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | @to_cols = apply { s/^foreign\.//i } keys %{ $rel->{args}[2] }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $to_class = $rel->{args}[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 2 | my ($relname_new, $inflect_mapped) = | |||||||||||||||||||||||||||||||||||||||||||||
| 809 | $self->$inflect_method($relname_new_uninflected); | ||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 2 | my $rel_name_mapped; | |||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 2 | ($relname_new, $rel_name_mapped) = $self->_rel_name_map($relname_new, $rel->{method}, $local_class, $local_moniker, \@from_cols, $to_class, $remote_moniker, \@to_cols); | |||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 2 | ▶ | my $mapped = $inflect_mapped || $rel_name_mapped; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$inflect_mapped || $rel_name_mapped
MC/DC0%0/2
$inflect_mapped || $rel_name_mapped
$inflect_mapped
$rel_name_mapped
Truth table33%1/3
A || B
A= $inflect_mappedB= $rel_name_mapped
| |||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 2 | ▶ | warn <<"EOF" unless $mapped; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 818 | Could not find a proper name for relationship '$relname_new' in source | ||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | '$local_moniker' for columns '@{[ join ',', @from_cols ]}'. Supply a value in | |||||||||||||||||||||||||||||||||||||||||||||
| 820 | '$inflect_type' for '$relname_new_uninflected' or 'rel_name_map' for | ||||||||||||||||||||||||||||||||||||||||||||||
| 821 | '$relname_new' to name this relationship. | ||||||||||||||||||||||||||||||||||||||||||||||
| 822 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 2 | $relname_new = $self->_resolve_relname_collision($local_moniker, \@from_cols, $relname_new); | |||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 2 | $rel->{args}[0] = $relname_new; | |||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 582 | ▶ | sub _relnames_and_method { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_relnames_and_method: called CC=12 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 582 | my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 582 | my $remote_moniker = $rel->{remote_source}; | |||||||||||||||||||||||||||||||||||||||||||||
| 836 | 582 | my $remote_obj = $self->schema->source( $remote_moniker ); | |||||||||||||||||||||||||||||||||||||||||||||
| 837 | 582 | my $remote_class = $self->schema->class( $remote_moniker ); | |||||||||||||||||||||||||||||||||||||||||||||
| 838 | 582 | my $local_relname = $self->_local_relname( $rel->{remote_table}, $cond); | |||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 582 | my $local_cols = $rel->{local_columns}; | |||||||||||||||||||||||||||||||||||||||||||||
| 841 | 582 | my $local_table = $rel->{local_table}; | |||||||||||||||||||||||||||||||||||||||||||||
| 842 | 582 | my $local_class = $self->schema->class($local_moniker); | |||||||||||||||||||||||||||||||||||||||||||||
| 843 | 582 | my $local_source = $self->schema->source($local_moniker); | |||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 582 | my $remote_relname_uninflected = $self->_normalize_name($local_table); | |||||||||||||||||||||||||||||||||||||||||||||
| 846 | 582 | my ($remote_relname) = $self->_inflect_plural($self->_normalize_name($local_table)); | |||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 582 | my $remote_method = 'has_many'; | |||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||
| 850 | # If the local columns have a UNIQUE constraint, this is a one-to-one rel | ||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 582 | ▶ | if (array_eq([ $local_source->primary_columns ], $local_cols) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
&array_eq([$local_source->primary_columns], $local_cols) or &first(sub {
&array_eq($_->[1], $local_cols);
}
, @$uniqs)
MC/DC100%2/2
&array_eq([$local_source->primary_columns], $local_cols) or &first(sub {
&array_eq($_->[1], $local_cols);
}
, @$uniqs)
&array_eq([$local_source->primary_columns], $local_cols)
&first(sub {
&array_eq($_->[1], $local_cols);
}
, @$uniqs)
Truth table100%3/3
A or B
A= &array_eq([$local_source->primary_columns], $local_cols)B= &first(sub {
&array_eq($_->[1], $local_cols);
}
, @$uniqs)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 187 | ▶ | first { array_eq($_->[1], $local_cols) } @$uniqs) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 70 | $remote_method = 'might_have'; | |||||||||||||||||||||||||||||||||||||||||||||
| 854 | 70 | ($remote_relname) = $self->_inflect_singular($remote_relname_uninflected); | |||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # If more than one rel between this pair of tables, use the local | ||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # col names to distinguish, unless the rel was created previously. | ||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 582 | ▶ | if ($counters->{$remote_moniker} > 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 188 | my $relationship_exists = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 188 | ▶ | if (-f (my $existing_remote_file = $self->loader->get_dump_filename($remote_class))) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 115 | my $class = "${remote_class}Temporary"; | |||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 115 | ▶ | if (not Class::Inspector->loaded($class)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 50 | my $code = slurp_file $existing_remote_file; | |||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 50 | $code =~ s/(?<=package $remote_class)/Temporary/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 50 | $code =~ s/__PACKAGE__->meta->make_immutable[^;]*;//g; | |||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 50 | ▶ | eval $code; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 50 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 50 | push @{ $self->_temp_classes }, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 876 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 115 | ▶ | if ($class->has_relationship($remote_relname)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | my $rel_cols = [ sort { $a cmp $b } apply { s/^foreign\.//i } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 5 | (keys %{ $class->relationship_info($remote_relname)->{cond} }) ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 5 | ▶ | $relationship_exists = 1 if array_eq([ sort @$local_cols ], $rel_cols); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 188 | ▶ | if (not $relationship_exists) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 183 | my $colnames = q{_} . $self->_normalize_name(join '_', @$local_cols); | |||||||||||||||||||||||||||||||||||||||||||||
| 888 | 183 | ▶ | $local_relname .= $colnames if keys %$cond > 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 183 | $remote_relname = $self->_strip_id_postfix($self->_normalize_name($local_table . $colnames)); | |||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 183 | $remote_relname_uninflected = $remote_relname; | |||||||||||||||||||||||||||||||||||||||||||||
| 893 | 183 | ($remote_relname) = $self->_inflect_plural($remote_relname); | |||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||
| 895 | # if colnames were added and this is a might_have, re-inflect | ||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 183 | ▶ | if ($remote_method eq 'might_have') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 2 | ($remote_relname) = $self->_inflect_singular($remote_relname_uninflected); | |||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 582 | return ($local_relname, $remote_relname, $remote_method); | |||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 1373 | ▶ | sub _rel_name_map { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_name_map: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 1373 | my ($self, $relname, $method, $local_class, $local_moniker, $local_cols, | |||||||||||||||||||||||||||||||||||||||||||||
| 907 | $remote_class, $remote_moniker, $remote_cols, $extra) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||
| 909 | my $info = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 1373 | ▶ | %{$extra || {}}, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$extra || {}
MC/DC100%1/1
$extra || {}
$extra
Truth table100%2/2
A
A= $extra
| |||||||||||||||||||||||||||||||||||||||||||||||
| 911 | name => $relname, | ||||||||||||||||||||||||||||||||||||||||||||||
| 912 | type => $method, | ||||||||||||||||||||||||||||||||||||||||||||||
| 913 | local_class => $local_class, | ||||||||||||||||||||||||||||||||||||||||||||||
| 914 | local_moniker => $local_moniker, | ||||||||||||||||||||||||||||||||||||||||||||||
| 915 | local_columns => $local_cols, | ||||||||||||||||||||||||||||||||||||||||||||||
| 916 | remote_class => $remote_class, | ||||||||||||||||||||||||||||||||||||||||||||||
| 917 | remote_moniker => $remote_moniker, | ||||||||||||||||||||||||||||||||||||||||||||||
| 918 | remote_columns => $remote_cols, | ||||||||||||||||||||||||||||||||||||||||||||||
| 919 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 1373 | $self->_run_user_map($self->rel_name_map, $info); | |||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 1375 | ▶ | sub _run_user_map { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_user_map: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 1375 | my ($self, $map, $info) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 1375 | my $new_name = $info->{name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 928 | 1375 | my $mapped = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 1375 | ▶ | if ('HASH' eq ref($map)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 18 | my $name = $info->{name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 932 | 18 | my $moniker = $info->{local_moniker}; | |||||||||||||||||||||||||||||||||||||||||||||
| 933 | 18 | ▶ | if ($map->{$moniker} and 'HASH' eq ref($map->{$moniker}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$map->{$moniker} and "HASH" eq ref $map->{$moniker} and $map->{$moniker}{$name}
$map->{$moniker} and "HASH" eq ref $map->{$moniker}
MC/DC33%1/3
$map->{$moniker} and "HASH" eq ref $map->{$moniker} and $map->{$moniker}{$name}
$map->{$moniker}
"HASH" eq ref $map->{$moniker}
$map->{$moniker}{$name}
Truth table50%2/4
A and B and C
A= $map->{$moniker}B= "HASH" eq ref $map->{$moniker}C= $map->{$moniker}{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 934 | and $map->{$moniker}{$name} | ||||||||||||||||||||||||||||||||||||||||||||||
| 935 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 3 | $new_name = $map->{$moniker}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 937 | 3 | $mapped = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 939 | ▶ | elsif ($map->{$name} and not 'HASH' eq ref($map->{$name})) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$map->{$name} and not "HASH" eq ref $map->{$name}
MC/DC50%1/2
$map->{$name} and not "HASH" eq ref $map->{$name}
$map->{$name}
not "HASH" eq ref $map->{$name}
Truth table66%2/3
A and not(B)
A= $map->{$name}B= not "HASH" eq ref $map->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 3 | $new_name = $map->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 941 | 3 | $mapped = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 944 | elsif ('CODE' eq ref($map)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 3 | ▶ | my $cb = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 3 | my ($cb_map) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 947 | 3 | ▶ | croak "reentered rel_name_map must be a hashref" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 948 | unless 'HASH' eq ref($cb_map); | ||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 2 | my ($cb_name, $cb_mapped) = $self->_run_user_map($cb_map, $info); | |||||||||||||||||||||||||||||||||||||||||||||
| 950 | 2 | ▶ | return $cb_mapped && $cb_name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$cb_mapped && $cb_name
MC/DC0%0/2
$cb_mapped && $cb_name
$cb_mapped
$cb_name
Truth table33%1/3
A && B
A= $cb_mappedB= $cb_name
| |||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 15 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 952 | 15 | my $name = $map->($info, $cb); | |||||||||||||||||||||||||||||||||||||||||||||
| 953 | 14 | ▶ | if ($name) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 6 | $new_name = $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 955 | 6 | $mapped = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 1374 | return ($new_name, $mapped); | |||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 137 | ▶ | sub _cleanup { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 137 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 137 | for my $class (@{ $self->_temp_classes }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 966 | 50 | Class::Unload->unload($class); | |||||||||||||||||||||||||||||||||||||||||||||
| 967 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 137 | $self->_temp_classes([]); | |||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||
| 972 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||
| 974 | See L<DBIx::Class::Schema::Loader/AUTHORS>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||
| 976 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||
| 978 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||
| 979 | the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||
| 981 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 51 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 984 | # vim:et sts=4 sw=4 tw=0: | ||||||||||||||||||||||||||||||||||||||||||||||