line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ObjectDB::Meta::Relationship::OneToMany; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'ObjectDB::Meta::Relationship'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
338
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '3.28'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Carp; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
0
|
|
sub type { 'one to many' } |
13
|
0
|
|
|
0
|
0
|
|
sub is_multi { 1 } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub to_source { |
16
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
17
|
0
|
|
|
|
|
|
my (%options) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
0
|
|
|
|
my $name = $self->name || Carp::croak('Name is required'); |
20
|
0
|
|
|
|
|
|
my $table = $self->orig_class->meta->table; |
21
|
0
|
|
|
|
|
|
my $rel_table = $self->class->meta->table; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my ($from, $to) = %{ $self->{map} }; |
|
0
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $constraint = |
26
|
0
|
0
|
|
|
|
|
[ "$table.$from" => { -col => "$name.$to" }, @{ $self->{constraint} || [] } ]; |
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my @columns; |
29
|
0
|
0
|
|
|
|
|
if ($options{columns}) { |
30
|
|
|
|
|
|
|
$options{columns} = [ $options{columns} ] |
31
|
0
|
0
|
|
|
|
|
unless ref $options{columns} eq 'ARRAY'; |
32
|
0
|
|
|
|
|
|
@columns = @{ $options{columns} }; |
|
0
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
unshift @columns, $self->class->meta->get_primary_key; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
0
|
|
|
|
|
|
@columns = $self->class->meta->get_columns; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return { |
40
|
|
|
|
|
|
|
table => $rel_table, |
41
|
|
|
|
|
|
|
as => $name, |
42
|
|
|
|
|
|
|
join => $self->{join}, |
43
|
0
|
|
|
|
|
|
constraint => $constraint, |
44
|
|
|
|
|
|
|
columns => [@columns] |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |