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