line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::ActiveRecord::Arel; |
2
|
2
|
|
|
2
|
|
42041
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
51
|
|
4
|
2
|
|
|
2
|
|
3288
|
use Storable; |
|
2
|
|
|
|
|
13466
|
|
|
2
|
|
|
|
|
181
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
2493
|
use DBIx::ActiveRecord::Arel::Column; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
7
|
2
|
|
|
2
|
|
1094
|
use DBIx::ActiveRecord::Arel::Where; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
54
|
|
8
|
2
|
|
|
2
|
|
1093
|
use DBIx::ActiveRecord::Arel::Join; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
48
|
|
9
|
2
|
|
|
2
|
|
1133
|
use DBIx::ActiveRecord::Arel::Order; |
|
2
|
|
|
|
|
180
|
|
|
2
|
|
|
|
|
57
|
|
10
|
2
|
|
|
2
|
|
1075
|
use DBIx::ActiveRecord::Arel::Value; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
56
|
|
11
|
2
|
|
|
2
|
|
1262
|
use DBIx::ActiveRecord::Arel::Native; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
58
|
|
12
|
2
|
|
|
2
|
|
1293
|
use DBIx::ActiveRecord::Arel::NakidWhere; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
54
|
|
13
|
2
|
|
|
2
|
|
1249
|
use DBIx::ActiveRecord::Arel::SubQuery; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
60
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
1256
|
use DBIx::ActiveRecord::Arel::Query::Select; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
58
|
|
16
|
2
|
|
|
2
|
|
1207
|
use DBIx::ActiveRecord::Arel::Query::Insert; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
17
|
2
|
|
|
2
|
|
1368
|
use DBIx::ActiveRecord::Arel::Query::Update; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
52
|
|
18
|
2
|
|
|
2
|
|
1305
|
use DBIx::ActiveRecord::Arel::Query::Delete; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
52
|
|
19
|
2
|
|
|
2
|
|
1868
|
use DBIx::ActiveRecord::Arel::Query::Count; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4139
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub create { |
22
|
3
|
|
|
3
|
0
|
21
|
my ($self, $table_name) = @_; |
23
|
3
|
|
|
|
|
13
|
my $o = bless { |
24
|
|
|
|
|
|
|
table => $table_name, |
25
|
|
|
|
|
|
|
query => undef, |
26
|
|
|
|
|
|
|
}, $self; |
27
|
3
|
|
|
|
|
20
|
$o->{query} = DBIx::ActiveRecord::Arel::Query::Select->new($o); |
28
|
3
|
|
|
|
|
10
|
$o; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
215
|
|
|
215
|
0
|
714
|
sub query {shift->{query}}; |
32
|
212
|
|
|
212
|
0
|
1166
|
sub table {shift->{table}} |
33
|
37
|
|
|
37
|
0
|
85
|
sub binds {shift->query->binds} |
34
|
39
|
|
|
39
|
0
|
363
|
sub to_sql {shift->query->to_sql} |
35
|
104
|
|
|
104
|
0
|
9422
|
sub clone {Storable::dclone(shift)} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _col { |
38
|
121
|
|
|
121
|
|
156
|
my ($self, $name) = @_; |
39
|
121
|
100
|
|
|
|
462
|
$name = DBIx::ActiveRecord::Arel::Column->new($self, $name) if ref $name ne 'DBIx::ActiveRecord::Arel::Native'; |
40
|
121
|
|
|
|
|
415
|
$name; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub where { |
44
|
3
|
|
|
3
|
0
|
23
|
my $self = shift; |
45
|
3
|
|
|
|
|
4
|
my $statement = shift; |
46
|
3
|
|
|
|
|
6
|
my $o = $self->clone; |
47
|
3
|
|
|
|
|
8
|
$o->query->add_where(DBIx::ActiveRecord::Arel::NakidWhere->new($statement, \@_)); |
48
|
3
|
|
|
|
|
10
|
$o; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _value2instance { |
52
|
37
|
|
|
37
|
|
50
|
my ($self, $value) = @_; |
53
|
37
|
50
|
|
|
|
86
|
return $value if ref $value eq 'DBIx::ActiveRecord::Arel::Native'; |
54
|
37
|
100
|
|
|
|
73
|
return DBIx::ActiveRecord::Arel::SubQuery->new($value) if ref $value eq 'DBIx::ActiveRecord::Arel'; |
55
|
36
|
|
|
|
|
114
|
DBIx::ActiveRecord::Arel::Value->new($value); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _add_where { |
59
|
37
|
|
|
37
|
|
50
|
my ($self, $operator, $key, $value) = @_; |
60
|
37
|
|
|
|
|
70
|
my $o = $self->clone; |
61
|
37
|
|
|
|
|
85
|
$value = $self->_value2instance($value); |
62
|
37
|
|
|
|
|
75
|
$o->query->add_where(DBIx::ActiveRecord::Arel::Where->new($operator, $self->_col($key), $value)); |
63
|
37
|
|
|
|
|
142
|
$o; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub eq { |
67
|
20
|
|
|
20
|
0
|
42
|
my ($self, $key, $value) = @_; |
68
|
20
|
|
|
|
|
47
|
$self->_add_where('=', $key, $value); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub ne { |
72
|
1
|
|
|
1
|
0
|
2
|
my ($self, $key, $value) = @_; |
73
|
1
|
|
|
|
|
4
|
$self->_add_where('!=', $key, $value); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub in { |
77
|
3
|
|
|
3
|
0
|
6
|
my ($self, $key, $value) = @_; |
78
|
3
|
|
|
|
|
10
|
$self->_add_where('IN', $key, $value); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub not_in { |
82
|
1
|
|
|
1
|
0
|
2
|
my ($self, $key, $value) = @_; |
83
|
1
|
|
|
|
|
3
|
$self->_add_where('NOT IN', $key, $value); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub null { |
87
|
1
|
|
|
1
|
0
|
4
|
my ($self, $key) = @_; |
88
|
1
|
|
|
|
|
3
|
$self->_add_where('IS NULL', $key); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub not_null { |
92
|
1
|
|
|
1
|
0
|
3
|
my ($self, $key) = @_; |
93
|
1
|
|
|
|
|
4
|
$self->_add_where('IS NOT NULL', $key); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub gt { |
97
|
1
|
|
|
1
|
0
|
4
|
my ($self, $key, $value) = @_; |
98
|
1
|
|
|
|
|
5
|
$self->_add_where('>', $key, $value); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub lt { |
102
|
1
|
|
|
1
|
0
|
3
|
my ($self, $key, $value) = @_; |
103
|
1
|
|
|
|
|
3
|
$self->_add_where('<', $key, $value); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub ge { |
107
|
2
|
|
|
2
|
0
|
4
|
my ($self, $key, $value) = @_; |
108
|
2
|
|
|
|
|
6
|
$self->_add_where('>=', $key, $value); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub le { |
112
|
2
|
|
|
2
|
0
|
4
|
my ($self, $key, $value) = @_; |
113
|
2
|
|
|
|
|
5
|
$self->_add_where('<=', $key, $value); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub like { |
117
|
4
|
|
|
4
|
0
|
9
|
my ($self, $key, $value) = @_; |
118
|
4
|
|
|
|
|
7
|
$self->_add_where('LIKE', $key, $value); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub contains { |
122
|
1
|
|
|
1
|
0
|
3
|
my ($self, $key, $value) = @_; |
123
|
1
|
|
|
|
|
3
|
$self->like($key, "%$value%"); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub starts_with { |
127
|
1
|
|
|
1
|
0
|
2
|
my ($self, $key, $value) = @_; |
128
|
1
|
|
|
|
|
4
|
$self->like($key, "$value%"); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub ends_with { |
132
|
1
|
|
|
1
|
0
|
3
|
my ($self, $key, $value) = @_; |
133
|
1
|
|
|
|
|
4
|
$self->like($key, "%$value"); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub between { |
137
|
1
|
|
|
1
|
0
|
3
|
my ($self, $key, $value1, $value2) = @_; |
138
|
1
|
|
|
|
|
3
|
$self->ge($key, $value1)->le($key, $value2); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub left_join { |
142
|
14
|
|
|
14
|
0
|
35
|
my ($self, $target, $opt) = @_; |
143
|
14
|
|
|
|
|
50
|
my $o = $self->clone; |
144
|
14
|
|
|
|
|
34
|
$o->query->merge_as($target->query); |
145
|
14
|
|
|
|
|
31
|
$o->query->add_join(DBIx::ActiveRecord::Arel::Join->new('LEFT JOIN', $self->_col($opt->{primary_key}), $target->_col($opt->{foreign_key}))); |
146
|
14
|
|
|
|
|
50
|
$o; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub inner_join { |
150
|
2
|
|
|
2
|
0
|
8
|
my ($self, $target, $opt) = @_; |
151
|
2
|
|
|
|
|
6
|
my $o = $self->clone; |
152
|
2
|
|
|
|
|
7
|
$o->query->merge_as($target->query); |
153
|
2
|
|
|
|
|
7
|
$o->query->add_join(DBIx::ActiveRecord::Arel::Join->new('INNER JOIN', $self->_col($opt->{foreign_key}), $target->_col($opt->{primary_key}))); |
154
|
2
|
|
|
|
|
9
|
$o; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub merge { |
158
|
9
|
|
|
9
|
0
|
12
|
my ($self, $arel) = @_; |
159
|
9
|
|
|
|
|
18
|
my $o = $self->clone; |
160
|
9
|
|
|
|
|
21
|
my $s = $arel->clone; |
161
|
9
|
|
|
|
|
22
|
$o->query->merge($s->query); |
162
|
9
|
|
|
|
|
24
|
$o; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub select { |
166
|
7
|
|
|
7
|
0
|
10
|
my $self = shift; |
167
|
7
|
|
|
|
|
15
|
my $o = $self->clone; |
168
|
7
|
|
|
|
|
26
|
$o->query->add_select($self->_col($_)) for @_; |
169
|
7
|
|
|
|
|
38
|
$o; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub limit { |
173
|
1
|
|
|
1
|
0
|
5
|
my ($self, $limit) = @_; |
174
|
1
|
|
|
|
|
4
|
my $o = $self->clone; |
175
|
1
|
|
|
|
|
3
|
$o->query->set_limit($limit); |
176
|
1
|
|
|
|
|
4
|
$o; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub offset { |
180
|
1
|
|
|
1
|
0
|
2
|
my ($self, $offset) = @_; |
181
|
1
|
|
|
|
|
3
|
my $o = $self->clone; |
182
|
1
|
|
|
|
|
3
|
$o->query->set_offset($offset); |
183
|
1
|
|
|
|
|
3
|
$o; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub lock { |
187
|
1
|
|
|
1
|
0
|
3
|
my ($self) = @_; |
188
|
1
|
|
|
|
|
3
|
my $o = $self->clone; |
189
|
1
|
|
|
|
|
3
|
$o->query->set_lock; |
190
|
1
|
|
|
|
|
2
|
$o; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub group { |
194
|
5
|
|
|
5
|
0
|
6
|
my $self = shift; |
195
|
5
|
|
|
|
|
10
|
my $o = $self->clone; |
196
|
5
|
|
|
|
|
17
|
$o->query->add_group($o->_col($_)) for @_; |
197
|
5
|
|
|
|
|
13
|
$o; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub asc { |
201
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
202
|
3
|
|
|
|
|
6
|
my $o = $self->clone; |
203
|
3
|
|
|
|
|
9
|
$o->query->add_order(DBIx::ActiveRecord::Arel::Order->new('', $self->_col($_))) for @_; |
204
|
3
|
|
|
|
|
60
|
$o; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub desc { |
208
|
4
|
|
|
4
|
0
|
6
|
my $self = shift; |
209
|
4
|
|
|
|
|
8
|
my $o = $self->clone; |
210
|
4
|
|
|
|
|
13
|
$o->query->add_order(DBIx::ActiveRecord::Arel::Order->new('DESC', $self->_col($_))) for @_; |
211
|
4
|
|
|
|
|
14
|
$o; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub reorder { |
215
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
216
|
1
|
|
|
|
|
2
|
my $o = $self->clone; |
217
|
1
|
|
|
|
|
2
|
$o->query->reset_order; |
218
|
1
|
|
|
|
|
11
|
$o; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub reverse { |
222
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
223
|
0
|
|
|
|
|
0
|
my $o = $self->clone; |
224
|
0
|
|
|
|
|
0
|
$o->query->reverse_order; |
225
|
0
|
|
|
|
|
0
|
$o; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub as { |
229
|
3
|
|
|
3
|
0
|
5
|
my ($self, $alias) = @_; |
230
|
3
|
|
|
|
|
4
|
my $s = $self->clone; |
231
|
3
|
|
|
|
|
7
|
$s->query->add_as($s->table, $alias); |
232
|
3
|
|
|
|
|
9
|
$s; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub insert { |
236
|
1
|
|
|
1
|
0
|
2
|
my ($self, $hash, $columns) = @_; |
237
|
1
|
|
|
|
|
2
|
my $o = $self->clone; |
238
|
1
|
|
|
|
|
9
|
$o->{query} = DBIx::ActiveRecord::Arel::Query::Insert->new($self, $hash, $columns); |
239
|
1
|
|
|
|
|
4
|
$o; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub update { |
243
|
1
|
|
|
1
|
0
|
2
|
my ($self, $hash, $columns) = @_; |
244
|
1
|
|
|
|
|
3
|
my $o = $self->clone; |
245
|
1
|
|
|
|
|
12
|
$o->{query} = DBIx::ActiveRecord::Arel::Query::Update->new($self, $hash, $columns); |
246
|
1
|
|
|
|
|
23
|
$o; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub delete { |
250
|
1
|
|
|
1
|
0
|
1
|
my ($self) = @_; |
251
|
1
|
|
|
|
|
3
|
my $o = $self->clone; |
252
|
1
|
|
|
|
|
9
|
$o->{query} = DBIx::ActiveRecord::Arel::Query::Delete->new($self); |
253
|
1
|
|
|
|
|
7
|
$o; |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub count { |
257
|
1
|
|
|
1
|
0
|
2
|
my ($self) = @_; |
258
|
1
|
|
|
|
|
3
|
my $o = $self->clone; |
259
|
1
|
|
|
|
|
8
|
$o->{query} = DBIx::ActiveRecord::Arel::Query::Count->new($self); |
260
|
1
|
|
|
|
|
6
|
$o; |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
1; |