line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: JsonSQL::Param::OrderBy object. Stores an array of JsonSQL::Param::Order objects to use for constructing JsonSQL::Query objects. |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
13
|
use 5.014; |
|
1
|
|
|
|
|
3
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package JsonSQL::Param::OrderBy; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.4'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
355
|
use JsonSQL::Param::Order; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
14
|
1
|
|
|
1
|
|
5
|
use JsonSQL::Error; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
256
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#use Data::Dumper; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
0
|
|
|
0
|
1
|
|
my ( $class, $orderarrayref, $queryObj, $default_table_rules ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $self = []; |
24
|
0
|
|
|
|
|
|
my @orderby_errors; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
for my $orderhashref ( @{ $orderarrayref } ) { |
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $orderByObj = JsonSQL::Param::Order->new($orderhashref, $queryObj, $default_table_rules); |
28
|
0
|
0
|
|
|
|
|
if ( eval { $orderByObj->is_error } ) { |
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
push(@orderby_errors, $orderByObj->{message}); |
30
|
|
|
|
|
|
|
} else { |
31
|
0
|
|
|
|
|
|
push (@{ $self }, $orderByObj); |
|
0
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if ( @orderby_errors ) { |
36
|
0
|
|
|
|
|
|
my $err = "Could not parse all order objects: \n\t"; |
37
|
0
|
|
|
|
|
|
$err .= join("\n\t", @orderby_errors); |
38
|
0
|
|
|
|
|
|
return JsonSQL::Error->new("invalid_orderby", $err); |
39
|
|
|
|
|
|
|
} else { |
40
|
0
|
|
|
|
|
|
bless $self, $class; |
41
|
0
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_ordering { |
47
|
0
|
|
|
0
|
1
|
|
my ( $self, $queryObj ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my @orderingArray = map { $_->get_orderby } @{ $self }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return \@orderingArray; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=pod |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=encoding UTF-8 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
JsonSQL::Param::OrderBy - JsonSQL::Param::OrderBy object. Stores an array of JsonSQL::Param::Order objects to use for constructing JsonSQL::Query objects. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 VERSION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
version 0.4 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SYNOPSIS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This module constructs a Perl object container of L<JsonSQL::Param::Order> objects. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head3 Object properties: |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item Array of L<JsonSQL::Param::Order> objects. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head3 Generated parameters: |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=over |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item $orderingArray => \@arrayref |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=back |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 METHODS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 Constructor new($orderarrayref, $queryObj, $default_table_rules) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Instantiates and returns a new JsonSQL::Param::OrderBy object, which is an array of L<JsonSQL::Param::Order> objects. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$orderarrayref => An arrayref of order hashes used to construct the object. |
100
|
|
|
|
|
|
|
$queryObj => A reference to the JsonSQL::Query object that will own this object. |
101
|
|
|
|
|
|
|
$default_table_rules => The default whitelist table rules to use to validate access when the table params |
102
|
|
|
|
|
|
|
are not provided to the field object. Usually, these are acquired from the table params |
103
|
|
|
|
|
|
|
of another object (ex: the FROM clause of a SELECT statement). |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns a JsonSQL::Error object on failure. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 ObjectMethod get_ordering -> \@orderingArray |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Generates parameters represented by the object for the SQL statement. Returns: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
$orderingArray => Arrayref of ordering parameters to use for the query. Constructed from child L<JsonSQL::Param::Order> objects. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Chris Hoefler <bhoefler@draper.com> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Chris Hoefler. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
122
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |