| 1 | package Rose::DB::Object::Metadata::Relationship::ManyToOne; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 61 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 61 | ▶ | use Carp(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 61 | ▶ | use Scalar::Util(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 61 | ▶ | use Rose::DB::Object::Metadata::Relationship; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 61 | our @ISA = qw(Rose::DB::Object::Metadata::Relationship); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 61 | ▶ | use Rose::Object::MakeMethods::Generic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 61 | ▶ | use Rose::DB::Object::MakeMethods::Generic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 61 | our $VERSION = '0.781'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 61 | __PACKAGE__->default_auto_method_types(qw(get_set_on_save delete_on_save)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 61 | __PACKAGE__->add_common_method_maker_argument_names | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | qw(class share_db key_columns required manager_class manager_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | manager_count_method manager_iterator_method manager_find_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | manager_delete_method manager_args query_args join_args object_args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | use Rose::Object::MakeMethods::Generic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 61 | ▶ | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 61 | boolean => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | #'required' => { default => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | '_share_db' => { default => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 'with_column_triggers' => { default => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 'disable_column_triggers', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | hash => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | _key_column => { hash_key => 'key_columns' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | _key_columns => { interface => 'get_set_all' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 61 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 61 | Rose::Object::MakeMethods::Generic->make_methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | { preserve_existing => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | scalar => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | __PACKAGE__->common_method_maker_argument_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 61 | __PACKAGE__->method_maker_info | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | get_set => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | type => 'object_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | get_set_now => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | type => 'object_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | interface => 'get_set_now', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | get_set_on_save => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | type => 'object_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | interface => 'get_set_on_save', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | delete_now => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | type => 'object_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | interface => 'delete_now', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | delete_on_save => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | type => 'object_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | interface => 'delete_on_save', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 76 | ▶ | sub type { 'many to one' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub is_singular { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_singular: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub foreign_class { shift->class(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
foreign_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 32 | ▶ | sub share_db { shift->_fk_or_self(share_db => @_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
share_db: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub key_column { shift->_fk_or_self(key_column => @_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key_column: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 316 | ▶ | sub key_columns { shift->_fk_or_self(key_columns => @_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key_columns: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 61 | *map_column = \&key_column; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 61 | *column_map = \&key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | sub _fk_or_self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 348 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fk_or_self: called CC=7 SCAR=20.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 348 | my($self, $method) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 348 | ▶ | if((@_ && $method eq 'key_columns') || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
@_ and $method eq "key_columns" or @_ > 1 and $method eq "key_column"
@_ and $method eq "key_columns"
@_ > 1 and $method eq "key_column"
MC/DC25%1/4
@_ and $method eq "key_columns" or @_ > 1 and $method eq "key_column"
@_
$method eq "key_columns"
@_ > 1
$method eq "key_column"
Truth table28%2/7
A and B or C and D
A= @_B= $method eq "key_columns"C= @_ > 1D= $method eq "key_column"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | (@_ > 1 && $method eq 'key_column')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 8 | $self->{'default_required'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 348 | ▶ | if(my $fk = $self->foreign_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 244 | return $fk->$method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 104 | ▶ | $method = "_$method" if($self->can("_$method")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 104 | return $self->$method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | sub method_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 176 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
method_name: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 176 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 176 | ▶ | if(my $fk = $self->foreign_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 128 | return $fk->method_name(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 48 | return $self->SUPER::method_name(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | sub is_ready_to_make_methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 40 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ready_to_make_methods: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 40 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 40 | ▶ | if(my $fk = $self->foreign_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 32 | return $fk->is_ready_to_make_methods(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 8 | return $self->SUPER::is_ready_to_make_methods(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | sub make_methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 28 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_methods: called CC=8 SCAR=36.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 28 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 28 | ▶ | if(my $fk = $self->foreign_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 20 | return $fk->make_methods(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 8 | $self->SUPER::make_methods(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 8 | ▶ | if($self->with_column_triggers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | my $method = $self->method_name('get_set_on_save') || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->method_name('get_set_on_save') || $self->method_name('get_set')
MC/DC0%0/2
$self->method_name('get_set_on_save') || $self->method_name('get_set')
$self->method_name('get_set_on_save')
$self->method_name('get_set')
Truth table0%0/3
A || B
A= $self->method_name('get_set_on_save')B= $self->method_name('get_set')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | $self->method_name('get_set'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if($method) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | my $meta = $self->parent or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | Carp::croak "Missing parent for relationship '", $self->name, "'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $column_map = $self->column_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | foreach my $column_name (keys %$column_map) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $column = $meta->column($column_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $accessor = $column->accessor_method_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $trigger_name = 'clear_rel_' . $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | unless(defined $column->builtin_trigger_index('on_set', $trigger_name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | Scalar::Util::weaken(my $wolumn = $column); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | $column->add_builtin_trigger( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | event => 'on_set', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | name => $trigger_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | code => sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my($obj) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | return if($self->{'disable_column_triggers'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | local $wolumn->{'triggers_disabled'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | $obj->$method(undef) unless(defined $obj->$accessor()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | sub id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 260 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 260 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 260 | my $column_map = $self->column_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | return $self->parent->class . ' ' . $self->class . ' ' . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 260 | join("\0", map { join("\1", lc $_, lc $column_map->{$_}) } sort keys %$column_map) . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 260 | ▶ | join("\0", map { $_ . '=' . ($self->$_() || 0) } qw(required)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->$_ || 0
MC/DC100%1/1
$self->$_ || 0
$self->$_
Truth table100%2/2
A
A= $self->$_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | sub build_method_name_for_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_method_name_for_type: called CC=6 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 16 | my($self, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 16 | ▶ | if($type eq 'get_set' || $type eq 'get_set_now' || $type eq 'get_set_on_save') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
$type eq "get_set" or $type eq "get_set_now" or $type eq "get_set_on_save"
$type eq "get_set" or $type eq "get_set_now"
MC/DC33%1/3
$type eq "get_set" or $type eq "get_set_now" or $type eq "get_set_on_save"
$type eq "get_set"
$type eq "get_set_now"
$type eq "get_set_on_save"
Truth table50%2/4
A or B or C
A= $type eq "get_set"B= $type eq "get_set_now"C= $type eq "get_set_on_save"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 8 | return $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ▶ | elsif($type eq 'delete_now' || $type eq 'delete_on_save') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$type eq "delete_now" or $type eq "delete_on_save"
MC/DC0%0/2
$type eq "delete_now" or $type eq "delete_on_save"
$type eq "delete_now"
$type eq "delete_on_save"
Truth table33%1/3
A or B
A= $type eq "delete_now"B= $type eq "delete_on_save"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 8 | return 'delete_' . $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | sub optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optional: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if(@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $self->required(!$_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | return ! $self->required; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 61 | *soft = \&optional; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | sub required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 292 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
required: called CC=12 SCAR=32.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 292 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 292 | my $fk = $self->foreign_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 292 | ▶ | return $fk->referential_integrity(@_) if($fk); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 48 | ▶ | return $self->{'required'} = ($_[0] ? 1 : 0) if(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 48 | ▶ | return $self->{'required'} if(defined $self->{'required'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 48 | ▶ | return $self->{'default_required'} if(defined $self->{'default_required'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 8 | ▶ | my $meta = $self->parent or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | Carp::croak "Missing parent for foreign key '", $self->name, "'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 8 | my $column_map = $self->column_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # If any local key column allows null values, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # the related object is not required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 8 | foreach my $column_name (keys %$column_map) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 8 | ▶ | my $column = $meta->column($column_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | or Carp::confess "No such column '$column_name' in table '", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | $self->parent->table, "' referenced from relationship '", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | $self->name, "'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 8 | ▶ | unless($column->not_null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 8 | return $self->{'default_required'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # If the local key columns are the same as the primary key columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # then the related object is not required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $local_columns = join("\0", sort keys %$column_map); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $pk_columns = join("\0", sort $meta->primary_key_column_names); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if($local_columns eq $pk_columns && length($local_columns)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$local_columns eq $pk_columns and length $local_columns
MC/DC0%0/2
$local_columns eq $pk_columns and length $local_columns
$local_columns eq $pk_columns
length $local_columns
Truth table0%0/3
A and B
A= $local_columns eq $pk_columnsB= length $local_columns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return $self->{'default_required'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | return $self->{'default_required'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 61 | *referential_integrity = \&required; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub requires_preexisting_parent_object { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
requires_preexisting_parent_object: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 61 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||