line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Fey::Types::Internal; |
2
|
|
|
|
|
|
|
|
3
|
29
|
|
|
29
|
|
12303712
|
use strict; |
|
29
|
|
|
|
|
67
|
|
|
29
|
|
|
|
|
1281
|
|
4
|
29
|
|
|
29
|
|
179
|
use warnings; |
|
29
|
|
|
|
|
45
|
|
|
29
|
|
|
|
|
1879
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.43'; |
7
|
|
|
|
|
|
|
|
8
|
29
|
|
|
29
|
|
1958
|
use List::AllUtils qw( all ); |
|
29
|
|
|
|
|
10137
|
|
|
29
|
|
|
|
|
1936
|
|
9
|
29
|
|
|
29
|
|
163
|
use overload (); |
|
29
|
|
|
|
|
45
|
|
|
29
|
|
|
|
|
462
|
|
10
|
29
|
|
|
29
|
|
209
|
use Scalar::Util qw( blessed ); |
|
29
|
|
|
|
|
47
|
|
|
29
|
|
|
|
|
2172
|
|
11
|
|
|
|
|
|
|
|
12
|
29
|
|
|
|
|
311
|
use MooseX::Types -declare => [ |
13
|
|
|
|
|
|
|
qw( |
14
|
|
|
|
|
|
|
ArrayRefOfColumns |
15
|
|
|
|
|
|
|
ArrayRefOfFunctionArgs |
16
|
|
|
|
|
|
|
CanQuote |
17
|
|
|
|
|
|
|
Column |
18
|
|
|
|
|
|
|
ColumnLikeOrName |
19
|
|
|
|
|
|
|
ColumnOrName |
20
|
|
|
|
|
|
|
ColumnWithTable |
21
|
|
|
|
|
|
|
DefaultValue |
22
|
|
|
|
|
|
|
FunctionArg |
23
|
|
|
|
|
|
|
FK |
24
|
|
|
|
|
|
|
GenericTypeName |
25
|
|
|
|
|
|
|
GroupByElement |
26
|
|
|
|
|
|
|
IntoElement |
27
|
|
|
|
|
|
|
LiteralTermArg |
28
|
|
|
|
|
|
|
Named |
29
|
|
|
|
|
|
|
NamedObjectSet |
30
|
|
|
|
|
|
|
NonNullableInsertValue |
31
|
|
|
|
|
|
|
NonNullableUpdateValue |
32
|
|
|
|
|
|
|
NullableInsertValue |
33
|
|
|
|
|
|
|
NullableUpdateValue |
34
|
|
|
|
|
|
|
OrderByElement |
35
|
|
|
|
|
|
|
OuterJoinType |
36
|
|
|
|
|
|
|
PosInteger |
37
|
|
|
|
|
|
|
PosOrZeroInteger |
38
|
|
|
|
|
|
|
SelectElement |
39
|
|
|
|
|
|
|
SetOperationArg |
40
|
|
|
|
|
|
|
Schema |
41
|
|
|
|
|
|
|
Table |
42
|
|
|
|
|
|
|
TableLikeOrName |
43
|
|
|
|
|
|
|
TableOrName |
44
|
|
|
|
|
|
|
WhereBoolean |
45
|
|
|
|
|
|
|
WhereClause |
46
|
|
|
|
|
|
|
WhereClauseSide |
47
|
|
|
|
|
|
|
) |
48
|
29
|
|
|
29
|
|
158
|
]; |
|
29
|
|
|
|
|
44
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use MooseX::Types::Moose |
51
|
29
|
|
|
29
|
|
463386
|
qw( ArrayRef Defined Int Item Object Str Undef Value ); |
|
29
|
|
|
|
|
72
|
|
|
29
|
|
|
|
|
399
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
subtype GenericTypeName, as Str, where { |
54
|
|
|
|
|
|
|
/^(?:text|blob|integer|float|date|datetime|time|boolean|other)$/xism |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
subtype PosInteger, as Int, where { $_ > 0 }; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
subtype PosOrZeroInteger, as Int, where { $_ >= 0 }; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
role_type DefaultValue, { role => 'Fey::Role::IsLiteral' }; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
coerce DefaultValue, |
64
|
|
|
|
|
|
|
from Undef, via { Fey::Literal::Null->new() }, |
65
|
|
|
|
|
|
|
from Value, via { Fey::Literal->new_from_scalar($_) }; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
class_type NamedObjectSet, { class => 'Fey::NamedObjectSet' }; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
class_type Column, { class => 'Fey::Column' }; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
subtype ArrayRefOfColumns, as ArrayRef [Column], where { |
72
|
|
|
|
|
|
|
@{$_} >= 1 |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
coerce ArrayRefOfColumns, from Column, via { [$_] }; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
role_type Named, { role => 'Fey::Role::Named' }; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
subtype FunctionArg, as Object, |
80
|
|
|
|
|
|
|
where { $_->can('does') && $_->does('Fey::Role::Selectable') }; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
coerce FunctionArg, |
83
|
|
|
|
|
|
|
from Undef, via { Fey::Literal::Null->new() }, |
84
|
|
|
|
|
|
|
from Value, via { Fey::Literal->new_from_scalar($_) }; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
subtype ArrayRefOfFunctionArgs, as ArrayRef [FunctionArg]; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
coerce ArrayRefOfFunctionArgs, from ArrayRef, via { |
89
|
|
|
|
|
|
|
[ map { FunctionArg->coerce($_) } @{$_} ]; |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
subtype LiteralTermArg, as ArrayRef, where { |
93
|
|
|
|
|
|
|
return unless $_ and @{$_}; |
94
|
|
|
|
|
|
|
all { |
95
|
|
|
|
|
|
|
blessed($_) |
96
|
|
|
|
|
|
|
? $_->can('sql_or_alias') || overload::Overloaded($_) |
97
|
|
|
|
|
|
|
: defined && !ref; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
@{$_}; |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
coerce LiteralTermArg, from Value, via { [$_] }; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
for my $thing ( |
105
|
|
|
|
|
|
|
[ 'Table', 'Fey::Table', TableOrName, TableLikeOrName ], |
106
|
|
|
|
|
|
|
[ 'Column', 'Fey::Column', ColumnOrName, ColumnLikeOrName ] |
107
|
|
|
|
|
|
|
) { |
108
|
|
|
|
|
|
|
my ( $thing, $class, $name_type, $like_type ) = @$thing; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
subtype $name_type, as Item, where { |
111
|
|
|
|
|
|
|
return unless defined $_; |
112
|
|
|
|
|
|
|
return 1 unless blessed $_; |
113
|
|
|
|
|
|
|
return $_->isa($class); |
114
|
|
|
|
|
|
|
}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
subtype $like_type, as Item, where { |
117
|
|
|
|
|
|
|
return unless defined $_; |
118
|
|
|
|
|
|
|
return 1 unless blessed $_; |
119
|
|
|
|
|
|
|
return unless $_->can('does'); |
120
|
|
|
|
|
|
|
return $_->can('does') && $_->does( 'Fey::Role::' . $thing . 'Like' ); |
121
|
|
|
|
|
|
|
}; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
role_type SetOperationArg, { role => 'Fey::Role::SQL::ReturnsData' }; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
subtype SelectElement, as Item, where { |
127
|
|
|
|
|
|
|
!blessed $_[0] |
128
|
|
|
|
|
|
|
|| $_[0]->isa('Fey::Table') |
129
|
|
|
|
|
|
|
|| $_[0]->isa('Fey::Table::Alias') |
130
|
|
|
|
|
|
|
|| ( $_[0]->can('is_selectable') |
131
|
|
|
|
|
|
|
&& $_[0]->is_selectable() ); |
132
|
|
|
|
|
|
|
}; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
subtype ColumnWithTable, as Column, where { |
135
|
|
|
|
|
|
|
$_[0]->has_table(); |
136
|
|
|
|
|
|
|
}; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
subtype IntoElement, as Object, where { |
139
|
|
|
|
|
|
|
return $_->isa('Fey::Table') |
140
|
|
|
|
|
|
|
|| ( $_->isa('Fey::Column') |
141
|
|
|
|
|
|
|
&& $_->table() |
142
|
|
|
|
|
|
|
&& !$_->table()->is_alias() ); |
143
|
|
|
|
|
|
|
}; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
subtype NullableInsertValue, as Item, where { |
146
|
|
|
|
|
|
|
!blessed $_ |
147
|
|
|
|
|
|
|
|| ( |
148
|
|
|
|
|
|
|
$_->can('does') |
149
|
|
|
|
|
|
|
&& ( $_->does('Fey::Role::IsLiteral') |
150
|
|
|
|
|
|
|
|| $_->does('Fey::Role::SQL::ReturnsData') ) |
151
|
|
|
|
|
|
|
) |
152
|
|
|
|
|
|
|
|| $_->isa('Fey::Placeholder') |
153
|
|
|
|
|
|
|
|| overload::Overloaded($_); |
154
|
|
|
|
|
|
|
}; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
subtype NonNullableInsertValue, as Defined, where { |
157
|
|
|
|
|
|
|
!blessed $_ |
158
|
|
|
|
|
|
|
|| ( |
159
|
|
|
|
|
|
|
$_->can('does') |
160
|
|
|
|
|
|
|
&& ( $_->does('Fey::Role::IsLiteral') |
161
|
|
|
|
|
|
|
|| $_->does('Fey::Role::SQL::ReturnsData') ) |
162
|
|
|
|
|
|
|
&& !$_->isa('Fey::Literal::Null') |
163
|
|
|
|
|
|
|
) |
164
|
|
|
|
|
|
|
|| $_->isa('Fey::Placeholder') |
165
|
|
|
|
|
|
|
|| overload::Overloaded($_); |
166
|
|
|
|
|
|
|
}; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
subtype NullableUpdateValue, as Item, where { |
169
|
|
|
|
|
|
|
!blessed $_ |
170
|
|
|
|
|
|
|
|| $_->isa('Fey::Column') |
171
|
|
|
|
|
|
|
|| ( |
172
|
|
|
|
|
|
|
$_->can('does') |
173
|
|
|
|
|
|
|
&& ( $_->does('Fey::Role::IsLiteral') |
174
|
|
|
|
|
|
|
|| $_->does('Fey::Role::SQL::ReturnsData') ) |
175
|
|
|
|
|
|
|
) |
176
|
|
|
|
|
|
|
|| $_->isa('Fey::Placeholder') |
177
|
|
|
|
|
|
|
|| overload::Overloaded($_); |
178
|
|
|
|
|
|
|
}; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
subtype NonNullableUpdateValue, as Defined, where { |
181
|
|
|
|
|
|
|
!blessed $_ |
182
|
|
|
|
|
|
|
|| $_->isa('Fey::Column') |
183
|
|
|
|
|
|
|
|| ( |
184
|
|
|
|
|
|
|
$_->can('does') |
185
|
|
|
|
|
|
|
&& ( $_->does('Fey::Role::IsLiteral') |
186
|
|
|
|
|
|
|
|| $_->does('Fey::Role::SQL::ReturnsData') ) |
187
|
|
|
|
|
|
|
&& !$_->isa('Fey::Literal::Null') |
188
|
|
|
|
|
|
|
) |
189
|
|
|
|
|
|
|
|| $_->isa('Fey::Placeholder') |
190
|
|
|
|
|
|
|
|| overload::Overloaded($_); |
191
|
|
|
|
|
|
|
}; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
subtype OrderByElement, as Item, where { |
194
|
|
|
|
|
|
|
if ( !blessed $_ ) { |
195
|
|
|
|
|
|
|
return $_ =~ /^(?:asc|desc)(?: nulls (?:last|first))?$/i; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
return 1 |
199
|
|
|
|
|
|
|
if $_->can('is_orderable') |
200
|
|
|
|
|
|
|
&& $_->is_orderable(); |
201
|
|
|
|
|
|
|
}; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
subtype GroupByElement, as Object, where { |
204
|
|
|
|
|
|
|
return 1 |
205
|
|
|
|
|
|
|
if $_->can('is_groupable') |
206
|
|
|
|
|
|
|
&& $_->is_groupable(); |
207
|
|
|
|
|
|
|
}; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
subtype OuterJoinType, as Str, where { return $_ =~ /^(?:full|left|right)$/ }; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
subtype CanQuote, as Item, |
212
|
|
|
|
|
|
|
where { return $_->isa('DBI::db') || $_->can('quote') }; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
subtype WhereBoolean, as Str, where { return $_ =~ /^(?:AND|OR)$/ }; |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
subtype WhereClauseSide, as Item, where { |
217
|
|
|
|
|
|
|
return 1 if !defined $_; |
218
|
|
|
|
|
|
|
return 0 if ref $_ && !blessed $_; |
219
|
|
|
|
|
|
|
return 1 unless blessed $_; |
220
|
|
|
|
|
|
|
return 1 if overload::Overloaded($_); |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
return 1 |
223
|
|
|
|
|
|
|
if $_->can('is_comparable') |
224
|
|
|
|
|
|
|
&& $_->is_comparable(); |
225
|
|
|
|
|
|
|
}; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
class_type WhereClause, { class => 'Fey::SQL::Where' }; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
class_type Table, { class => 'Fey::Table' }; |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
class_type Schema, { class => 'Fey::Schema' }; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
class_type FK, { class => 'Fey::FK' }; |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
1; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# ABSTRACT: Types for use in Fey |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
__END__ |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=pod |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 NAME |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Fey::Types::Internal - Types for use in Fey |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 VERSION |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
version 0.43 |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 DESCRIPTION |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
This module defines a whole bunch of types used by the Fey core |
254
|
|
|
|
|
|
|
classes. None of these types are documented for external use at the |
255
|
|
|
|
|
|
|
present, though that could change in the future. |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 BUGS |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
See L<Fey> for details on how to report bugs. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 AUTHOR |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
This software is Copyright (c) 2011 - 2015 by Dave Rolsky. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
This is free software, licensed under: |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=cut |