line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rethinkdb::Response; |
2
|
15
|
|
|
15
|
|
59
|
use Rethinkdb::Base -base; |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
117
|
|
3
|
|
|
|
|
|
|
|
4
|
15
|
|
|
15
|
|
68
|
use JSON::PP; |
|
15
|
|
|
|
|
16
|
|
|
15
|
|
|
|
|
961
|
|
5
|
15
|
|
|
15
|
|
54
|
use Rethinkdb::Protocol; |
|
15
|
|
|
|
|
17
|
|
|
15
|
|
|
|
|
67
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has [qw{ type type_description response token error_type backtrace profile }]; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _init { |
10
|
0
|
|
|
0
|
|
|
my $class = shift; |
11
|
0
|
|
|
|
|
|
my $data = shift; |
12
|
0
|
|
0
|
|
|
|
my $optargs = shift || {}; |
13
|
0
|
|
|
|
|
|
my $args = { type => $data->{t}, token => $data->{token}, }; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $types = { |
16
|
|
|
|
|
|
|
1 => 'success_atom', |
17
|
|
|
|
|
|
|
2 => 'success_sequence', |
18
|
|
|
|
|
|
|
3 => 'success_partial', |
19
|
|
|
|
|
|
|
4 => 'wait_complete', |
20
|
|
|
|
|
|
|
16 => 'client_error', |
21
|
|
|
|
|
|
|
17 => 'compile_error', |
22
|
|
|
|
|
|
|
18 => 'runtime_error', |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$args->{type_description} = $types->{ $data->{t} }; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $response = []; |
28
|
0
|
0
|
|
|
|
|
if ( $data->{r} ) { |
29
|
0
|
|
|
|
|
|
foreach ( @{ $data->{r} } ) { |
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
push @{$response}, $_; |
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# not sure about this: |
35
|
0
|
0
|
|
|
|
|
if ( $data->{t} == 1 ) { |
36
|
0
|
|
|
|
|
|
$response = $response->[0]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# group the data into a hash |
40
|
0
|
0
|
0
|
|
|
|
if ( !($optargs->{group_format} && $optargs->{group_format} eq 'raw') ) { |
41
|
0
|
0
|
0
|
|
|
|
if ( ref $response eq 'HASH' |
|
|
|
0
|
|
|
|
|
42
|
|
|
|
|
|
|
&& $response->{'$reql_type$'} |
43
|
|
|
|
|
|
|
&& $response->{'$reql_type$'} eq 'GROUPED_DATA' ) |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
|
|
|
my $group = {}; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
foreach ( @{ $response->{data} } ) { |
|
0
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$group->{ $_->[0] } = $_->[1]; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$response = $group; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$args->{response} = $response; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if ( $data->{b} ) { |
58
|
0
|
|
|
|
|
|
$args->{backtrace} = $data->{b}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if ( $data->{p} ) { |
62
|
0
|
|
|
|
|
|
$args->{profile} = $data->{p}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
if ( $data->{e} ) { |
66
|
0
|
|
|
|
|
|
$args->{error_type} = $data->{e}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $class->new($args); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding utf8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Rethinkdb::Response - RethinkDB Response |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SYNOPSIS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package MyApp; |
83
|
|
|
|
|
|
|
use Rethinkdb; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $res = r->table('marvel')->run; |
86
|
|
|
|
|
|
|
say $res->type; |
87
|
|
|
|
|
|
|
say $res->type_description; |
88
|
|
|
|
|
|
|
say $res->response; |
89
|
|
|
|
|
|
|
say $res->token; |
90
|
|
|
|
|
|
|
say $res->error_type; |
91
|
|
|
|
|
|
|
say $res->profile; |
92
|
|
|
|
|
|
|
say $res->backtrace; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
All responses from the driver come as an instance of this class. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L implements the following attributes. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 type |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $res = r->table('marvel')->run; |
105
|
|
|
|
|
|
|
say $res->type; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The response type code. The current response types are: |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
'success_atom' => 1 |
110
|
|
|
|
|
|
|
'success_sequence' => 2 |
111
|
|
|
|
|
|
|
'success_partial' => 3 |
112
|
|
|
|
|
|
|
'success_feed' => 5 |
113
|
|
|
|
|
|
|
'wait_complete' => 4 |
114
|
|
|
|
|
|
|
'client_error' => 16 |
115
|
|
|
|
|
|
|
'compile_error' => 17 |
116
|
|
|
|
|
|
|
'runtime_error' => 18 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 type_description |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $res = r->table('marvel')->run; |
121
|
|
|
|
|
|
|
say $res->type_description; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
The response type description (e.g. C, C). |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 response |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
use Data::Dumper; |
128
|
|
|
|
|
|
|
my $res = r->table('marvel')->run; |
129
|
|
|
|
|
|
|
say Dumper $res->response; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
The actual response value from the database. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 token |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $res = r->table('marvel')->run; |
136
|
|
|
|
|
|
|
say Dumper $res->token; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Each request made to the database must have a unique token. The response from |
139
|
|
|
|
|
|
|
the database includes that token incase further actions are required. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 error_type |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my $res = r->table('marvel')->run; |
144
|
|
|
|
|
|
|
say $res->error_type; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
If the request cause an error, this attribute will contain the error message |
147
|
|
|
|
|
|
|
from the database. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 backtrace |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
my $res = r->table('marvel')->run; |
152
|
|
|
|
|
|
|
say $res->backtrace; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
If the request cause an error, this attribute will contain a backtrace for the |
155
|
|
|
|
|
|
|
error. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 profile |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $res = r->table('marvel')->run; |
160
|
|
|
|
|
|
|
say $res->profile; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
If profiling information was requested as a global argument for a query, then |
163
|
|
|
|
|
|
|
this attribute will contain that profiling data. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 SEE ALSO |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L, L |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |