line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::DB::Object::Metadata::Relationship::OneToOne; |
2
|
|
|
|
|
|
|
|
3
|
61
|
|
|
61
|
|
482
|
use strict; |
|
61
|
|
|
|
|
161
|
|
|
61
|
|
|
|
|
2092
|
|
4
|
|
|
|
|
|
|
|
5
|
61
|
|
|
61
|
|
30914
|
use Rose::DB::Object::Metadata::Relationship::ManyToOne; |
|
61
|
|
|
|
|
225
|
|
|
61
|
|
|
|
|
13717
|
|
6
|
|
|
|
|
|
|
our @ISA = qw(Rose::DB::Object::Metadata::Relationship::ManyToOne); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.771'; |
9
|
|
|
|
|
|
|
|
10
|
16
|
|
|
16
|
1
|
122
|
sub type { 'one to one' } |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
1
|
|
sub is_singular { 1 } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub requires_preexisting_parent_object |
15
|
|
|
|
|
|
|
{ |
16
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $meta = $self->parent; |
19
|
0
|
|
|
|
|
|
my $f_meta = $self->class->meta; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $column_map = $self->column_map; |
22
|
0
|
|
|
|
|
|
my %pk = map { $_ => 1 } $meta->primary_key_column_names; |
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
foreach my $local_column (keys %$column_map) |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
0
|
|
|
|
|
if($pk{$local_column}) |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
|
|
|
return $self->{'requires_preexisting_parent_object'} = 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $self->{'requires_preexisting_parent_object'} = 0; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Rose::DB::Object::Metadata::Relationship::OneToOne - One to one table relationship metadata object. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Rose::DB::Object::Metadata::Relationship::OneToOne; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$rel = Rose::DB::Object::Metadata::Relationship::OneToOne->new(...); |
49
|
|
|
|
|
|
|
$rel->make_methods(...); |
50
|
|
|
|
|
|
|
... |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Objects of this class store and manipulate metadata for relationships in which a single row from one table refers to a single row in another table. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This class inherits from L<Rose::DB::Object::Metadata::Relationship>. Inherited methods that are not overridden will not be documented a second time here. See the L<Rose::DB::Object::Metadata::Relationship> documentation for more information. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 METHOD MAP |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over 4 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item C<get_set> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<object_by_key|Rose::DB::Object::MakeMethods::Generic/object_by_key>, ... |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item C<get_set_now> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<object_by_key|Rose::DB::Object::MakeMethods::Generic/object_by_key>, C<interface =E<gt> 'get_set_now'> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item C<get_set_on_save> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<object_by_key|Rose::DB::Object::MakeMethods::Generic/object_by_key>, C<interface =E<gt> 'get_set_on_save'> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item C<delete_now> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<object_by_key|Rose::DB::Object::MakeMethods::Generic/object_by_key>, C<interface =E<gt> 'delete_now'> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item C<delete_on_save> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<object_by_key|Rose::DB::Object::MakeMethods::Generic/object_by_key>, C<interface =E<gt> 'delete_on_save'> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
See the L<Rose::DB::Object::Metadata::Relationship|Rose::DB::Object::Metadata::Relationship/"MAKING METHODS"> documentation for an explanation of this method map. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 CLASS METHODS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over 4 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item B<default_auto_method_types [TYPES]> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Get or set the default list of L<auto_method_types|Rose::DB::Object::Metadata::Relationship/auto_method_types>. TYPES should be a list of relationship method types. Returns the list of default relationship method types (in list context) or a reference to an array of the default relationship method types (in scalar context). The default list contains "get_set_on_save" and "delete_on_save". |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item B<column_map [HASH | HASHREF]> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Get or set a reference to a hash that maps local column names to foreign column names. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item B<build_method_name_for_type TYPE> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Return a method name for the relationship method type TYPE. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
For the method types "get_set", "get_set_now", and "get_set_on_save", the relationship's L<name|Rose::DB::Object::Metadata::Relationship/name> is returned. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
For the method types "delete_now" and "delete_on_save", the relationship's L<name|Rose::DB::Object::Metadata::Relationship/name> prefixed with "delete_" is returned. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Otherwise, undef is returned. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item B<is_singular> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns true. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item B<foreign_key [FK]> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Get or set the L<Rose::DB::Object::Metadata::ForeignKey> object to which this object delegates all responsibility. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
One to one relationships encapsulate essentially the same information as foreign keys. If a foreign key object is stored in this relationship object, then I<all compatible operations are passed through to the foreign key object.> This includes making object method(s) and adding or modifying the local-to-foreign column map. In other words, if a L<foreign_key|/foreign_key> is set, the relationship object simply acts as a proxy for the foreign key object. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item B<manager_class [CLASS]> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Get or set the name of the L<Rose::DB::Object::Manager>-derived class used to fetch the object. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item B<manager_method [METHOD]> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Get or set the name of the L<manager_class|/manager_class> class method to call when fetching the object. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item B<manager_args [HASHREF]> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Get or set a reference to a hash of name/value arguments to pass to the L<manager_method|/manager_method> when fetching the object. See the documentation for L<Rose::DB::Object::Manager>'s L<get_objects|Rose::DB::Object::Manager/get_objects> method for a full list of valid arguments for use with the C<manager_args> parameter. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
B<Note:> when the name of a relationship that has C<manager_args> is used in a L<Rose::DB::Object::Manager> L<with_objects|Rose::DB::Object::Manager/with_objects> or L<require_objects|Rose::DB::Object::Manager/require_objects> parameter value, I<only> the L<sort_by|Rose::DB::Object::Manager/sort_by> argument will be copied from C<manager_args> and incorporated into the query. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item B<map_column LOCAL [, FOREIGN]> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
If passed a local column name LOCAL, return the corresponding column name in the foreign table. If passed both a local column name LOCAL and a foreign column name FOREIGN, set the local/foreign mapping and return the foreign column name. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item B<optional [BOOL]> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This method is the mirror image of the L<required|/required> method. Passing a true value to this method is the same thing as setting L<required|/required> to false, and vice versa. Similarly, the return value is the logical negation of L<required|/required>. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item B<query_args [ARRAYREF]> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Get or set a reference to an array of query arguments to add to the L<query|Rose::DB::Object::Manager/query> passed to the L<manager_method|/manager_method> when fetching the object. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item B<required [BOOL]> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Get or set the boolean value that determines what happens when the local columns in the L<column_map|/column_map> have L<defined|perlfunc/defined> values, but the object they relate to is not found. If true, a fatal error will occur when the methods that fetch objects through this relationship are called. If false, then the methods will simply return undef. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
The default is false if one or more of the local columns L<allow null values|Rose::DB::Object::Metadata::Column/not_null> or if the local columns in the column map are the same as the L<primary key columns|Rose::DB::Object::Metadata/primary_key_columns>, true otherwise. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item B<type> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Returns "one to one". |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=back |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 AUTHOR |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 LICENSE |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is |
169
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same terms |
170
|
|
|
|
|
|
|
as Perl itself. |