line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package #hide from pause |
2
|
|
|
|
|
|
|
DBIx::Class::Schema::PopulateMore::Test::Schema::Result::Person; |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
2370
|
use parent 'DBIx::Class::Schema::PopulateMore::Test::Schema::Result'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
19
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
DBIx::Class::Schema::PopulateMore::Test::Schema::Result::Person - A Person Class |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Tests for this type of FK relationship |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 PACKAGE METHODS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This module defines the following package methods |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 table |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Name of the Physical table in the database |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__PACKAGE__ |
25
|
|
|
|
|
|
|
->table('person'); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 add_columns |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Add columns and meta information |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head3 person_id |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Primary Key which is an auto generated autoinc |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head3 fk_gender_id |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
foreign key to the Gender table |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head3 name |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Just an ordinary name |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head3 age |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The person's age |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head3 created |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
When the person was added to the database |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__PACKAGE__ |
55
|
|
|
|
|
|
|
->add_columns( |
56
|
|
|
|
|
|
|
person_id => { |
57
|
|
|
|
|
|
|
data_type=>'integer', |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
fk_gender_id => { |
60
|
|
|
|
|
|
|
data_type=>'integer', |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
name => { |
63
|
|
|
|
|
|
|
data_type=>'varchar', |
64
|
|
|
|
|
|
|
size=>32, |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
age => { |
67
|
|
|
|
|
|
|
data_type=>'integer', |
68
|
|
|
|
|
|
|
default_value=>25, |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
created => { |
71
|
|
|
|
|
|
|
data_type=>'datetime', |
72
|
|
|
|
|
|
|
default_value=>\'CURRENT_TIMESTAMP', |
73
|
|
|
|
|
|
|
}); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 primary_key |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Sets the Primary keys for this table |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__PACKAGE__ |
83
|
|
|
|
|
|
|
->set_primary_key(qw/person_id/); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 friendlist |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Each Person might have a resultset of friendlist |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__PACKAGE__ |
93
|
|
|
|
|
|
|
->has_many( |
94
|
|
|
|
|
|
|
friendlist => 'DBIx::Class::Schema::PopulateMore::Test::Schema::Result::FriendList', |
95
|
|
|
|
|
|
|
{'foreign.fk_person_id' => 'self.person_id'}); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 gender |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This person's gender |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__PACKAGE__ |
105
|
|
|
|
|
|
|
->belongs_to( gender => 'DBIx::Class::Schema::PopulateMore::Test::Schema::Result::Gender', { |
106
|
|
|
|
|
|
|
'foreign.gender_id' => 'self.fk_gender_id' }); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 fanlist |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
A resultset of the people listing me as a friend (if any) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__PACKAGE__ |
116
|
|
|
|
|
|
|
->belongs_to( fanlist => 'DBIx::Class::Schema::PopulateMore::Test::Schema::Result::FriendList', { |
117
|
|
|
|
|
|
|
'foreign.fk_friend_id' => 'self.person_id' }); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 friends |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
A resultset of Persons who are in my FriendList |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__PACKAGE__ |
127
|
|
|
|
|
|
|
->many_to_many( friends => 'friendlist', 'friendee' ); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 fans |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
A resultset of people that have me in their friendlist |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__PACKAGE__ |
137
|
|
|
|
|
|
|
->many_to_many( fans => 'fanlist', 'befriender' ); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 companies_person |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Each Person might have a resultset from the company_person table. This is a |
143
|
|
|
|
|
|
|
bridge table in a many-many type relationship |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__PACKAGE__ |
148
|
|
|
|
|
|
|
->has_many( |
149
|
|
|
|
|
|
|
companies_person => 'DBIx::Class::Schema::PopulateMore::Test::Schema::Result::CompanyPerson', |
150
|
|
|
|
|
|
|
{'foreign.fk_person_id' => 'self.person_id'}); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 companies |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
A resultset of Companies via a resultset of connecting CompanyPersons |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
__PACKAGE__ |
160
|
|
|
|
|
|
|
->many_to_many( companies => 'companies_person', 'company' ); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 METHODS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This module defines the following methods. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 AUTHOR |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Please see L<DBIx::Class::Schema::PopulateMore> For authorship information |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 LICENSE |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Please see L<DBIx::Class::Schema::PopulateMore> For licensing terms. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |