| 1 | package Rose::DB::Object::Metadata::Relationship::OneToMany; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Rose::DB::Object::Metadata::Relationship; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | our @ISA = qw(Rose::DB::Object::Metadata::Relationship); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Rose::Object::MakeMethods::Generic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Rose::DB::Object::MakeMethods::Generic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our $Debug = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | our $VERSION = '0.781'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | __PACKAGE__->default_auto_method_types(qw(find get_set_on_save add_on_save)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | __PACKAGE__->add_common_method_maker_argument_names | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | qw(class share_db key_columns manager_class manager_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | manager_count_method manager_iterator_method manager_find_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | manager_args query_args join_args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | use Rose::Object::MakeMethods::Generic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | boolean => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 'share_db' => { default => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | hash => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | key_column => { hash_key => 'key_columns' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | key_columns => { interface => 'get_set_all' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | Rose::Object::MakeMethods::Generic->make_methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | { preserve_existing => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | scalar => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | __PACKAGE__->common_method_maker_argument_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | __PACKAGE__->method_maker_info | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | count => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | type => 'objects_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | interface => 'count', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | find => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | type => 'objects_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | interface => 'find', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | iterator => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | type => 'objects_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | interface => 'iterator', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | get_set => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | type => 'objects_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | interface => 'get_set', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | get_set_now => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | type => 'objects_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | interface => 'get_set_now', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | get_set_on_save => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | type => 'objects_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | interface => 'get_set_on_save', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | add_now => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | type => 'objects_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | interface => 'add_now', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | add_on_save => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | class => 'Rose::DB::Object::MakeMethods::Generic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | type => 'objects_by_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | interface => 'add_on_save', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 8 | ▶ | sub type { 'one to many' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub is_singular { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_singular: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub foreign_class { shift->class(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
foreign_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | *map_column = \&key_column; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | *column_map = \&key_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | sub id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 12 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 12 | my $column_map = $self->column_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | return $self->parent->class . ' ' . $self->class . ' ' . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 12 | join("\0", map { join("\1", lc $_, lc $column_map->{$_}) } sort keys %$column_map); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | #join("\0", map { $_ . '=' . ($self->$_() || 0) } qw(required)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | sub build_method_name_for_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_method_name_for_type: called CC=9 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 12 | my($self, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 12 | ▶ | if($type eq 'get_set' || $type eq 'get_set_now' || $type eq 'get_set_on_save') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 4 | return $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ▶ | elsif($type eq 'add_now' || $type eq 'add_on_save') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type eq "add_now" or $type eq "add_on_save"
MC/DC50%1/2
$type eq "add_now" or $type eq "add_on_save"
$type eq "add_now"
$type eq "add_on_save"
Truth table66%2/3
A or B
A= $type eq "add_now"B= $type eq "add_on_save"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | return 'add_' . $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | elsif($type eq 'find') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 4 | return 'find_' . $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | elsif($type eq 'iterator') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | return $self->name . '_iterator'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | elsif($type eq 'count') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return $self->name . '_count'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | sub is_ready_to_make_methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ready_to_make_methods: called CC=10 SCAR=39.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 4 | ▶ | if($Debug || $Rose::DB::Object::Metadata::Debug) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Rose::DB::Object::Metadata::Relationship::OneToMany::Debug or $Rose::DB::Object::Metadata::Debug
MC/DC0%0/2
$Rose::DB::Object::Metadata::Relationship::OneToMany::Debug or $Rose::DB::Object::Metadata::Debug
$Rose::DB::Object::Metadata::Relationship::OneToMany::Debug
$Rose::DB::Object::Metadata::Debug
Truth table33%1/3
A or B
A= $Rose::DB::Object::Metadata::Relationship::OneToMany::DebugB= $Rose::DB::Object::Metadata::Debug
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if(!$self->class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $error = "does not belong to a class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ▶ | elsif(!$self->key_columns && !$self->query_args) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->key_columns || $self->query_args
MC/DC0%0/2
$self->key_columns || $self->query_args
$self->key_columns
$self->query_args
Truth table0%0/3
A || B
A= $self->key_columnsB= $self->query_args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $error = "has no key columns or query args"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | warn $self->parent->class, ': one-to-many relationship ', $self->name, " NOT READY - $error" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | if($error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | ▶ | return $self->class && ($self->key_columns || $self->query_args) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->class and $self->key_columns || $self->query_args
$self->key_columns or $self->query_args
MC/DC0%0/3
$self->class and $self->key_columns || $self->query_args
$self->class
$self->key_columns
$self->query_args
Truth table25%1/4
A and B or C
A= $self->classB= $self->key_columnsC= $self->query_args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||