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