line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
17
|
|
|
17
|
|
284
|
use 5.010; |
|
17
|
|
|
|
|
58
|
|
2
|
17
|
|
|
17
|
|
530
|
use strict; |
|
17
|
|
|
|
|
28
|
|
|
17
|
|
|
|
|
338
|
|
3
|
17
|
|
|
17
|
|
66
|
use warnings; |
|
17
|
|
|
|
|
38
|
|
|
17
|
|
|
|
|
455
|
|
4
|
17
|
|
|
17
|
|
81
|
use utf8; |
|
17
|
|
|
|
|
22
|
|
|
17
|
|
|
|
|
80
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Neo4j::Driver::Record; |
7
|
|
|
|
|
|
|
# ABSTRACT: Container for Cypher result values |
8
|
|
|
|
|
|
|
$Neo4j::Driver::Record::VERSION = '0.40'; |
9
|
|
|
|
|
|
|
|
10
|
17
|
|
|
17
|
|
1148
|
use Carp qw(croak); |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
1114
|
|
11
|
17
|
|
|
17
|
|
7550
|
use JSON::MaybeXS 1.003003 qw(is_bool); |
|
17
|
|
|
|
|
91966
|
|
|
17
|
|
|
|
|
1022
|
|
12
|
|
|
|
|
|
|
|
13
|
17
|
|
|
17
|
|
6403
|
use Neo4j::Driver::ResultSummary; |
|
17
|
|
|
|
|
44
|
|
|
17
|
|
|
|
|
1007
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Based on _looks_like_number() in JSON:PP 4.05, originally by HAARG. |
17
|
|
|
|
|
|
|
# Modified on 2020 OCT 13 to detect only integers (column index). |
18
|
|
|
|
|
|
|
sub _looks_like_int { |
19
|
186
|
|
|
186
|
|
294
|
my $value = shift; |
20
|
|
|
|
|
|
|
# if the utf8 flag is on, it almost certainly started as a string |
21
|
186
|
100
|
|
|
|
457
|
return if utf8::is_utf8($value); |
22
|
|
|
|
|
|
|
# detect numbers |
23
|
|
|
|
|
|
|
# string & "" -> "" |
24
|
|
|
|
|
|
|
# number & "" -> 0 (with warning) |
25
|
|
|
|
|
|
|
# nan and inf can detect as numbers, so check with * 0 |
26
|
17
|
|
|
17
|
|
108
|
no warnings 'numeric'; |
|
17
|
|
|
|
|
28
|
|
|
17
|
|
|
|
|
9958
|
|
27
|
185
|
100
|
|
|
|
740
|
return unless length((my $dummy = "") & $value); |
28
|
78
|
100
|
|
|
|
245
|
return unless $value eq int $value; |
29
|
77
|
100
|
|
|
|
184
|
return unless $value * 0 == 0; |
30
|
76
|
|
|
|
|
165
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get { |
35
|
247
|
|
|
247
|
1
|
49151
|
my ($self, $field) = @_; |
36
|
|
|
|
|
|
|
|
37
|
247
|
100
|
|
|
|
534
|
if ( ! defined $field ) { |
38
|
62
|
100
|
|
|
|
78
|
warnings::warnif ambiguous => "Ambiguous get() on " . __PACKAGE__ . " with multiple fields" if @{$self->{row}} > 1; |
|
62
|
|
|
|
|
183
|
|
39
|
62
|
|
|
|
|
971
|
return $self->{row}->[0]; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
185
|
100
|
|
|
|
361
|
if ( _looks_like_int $field ) { |
43
|
76
|
100
|
100
|
|
|
214
|
croak "Field $field not present in query result" if $field < 0 || $field >= @{$self->{row}}; |
|
75
|
|
|
|
|
280
|
|
44
|
74
|
|
|
|
|
517
|
return $self->{row}->[$field]; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
109
|
|
|
|
|
371
|
my $key = $self->{column_keys}->key($field); |
48
|
109
|
100
|
|
|
|
285
|
croak "Field '$field' not present in query result" if ! defined $key; |
49
|
104
|
|
|
|
|
868
|
return $self->{row}->[$key]; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# The various JSON modules for Perl tend to represent a boolean false value |
54
|
|
|
|
|
|
|
# using a blessed scalar overloaded to evaluate to false in Perl expressions. |
55
|
|
|
|
|
|
|
# This almost always works perfectly fine. However, some tests might not expect |
56
|
|
|
|
|
|
|
# a non-truthy value to be blessed, which can result in wrong interpretation of |
57
|
|
|
|
|
|
|
# query results. The get_bool method was meant to ensure boolean results would |
58
|
|
|
|
|
|
|
# evaluate correctly in such cases. Given that such cases are rare and that no |
59
|
|
|
|
|
|
|
# specific examples for such cases are currently known, this method now seems |
60
|
|
|
|
|
|
|
# superfluous. |
61
|
|
|
|
|
|
|
sub get_bool { |
62
|
|
|
|
|
|
|
# uncoverable pod (see Deprecations.pod) |
63
|
3
|
|
|
3
|
0
|
1253
|
my ($self, $field) = @_; |
64
|
3
|
|
|
|
|
67
|
warnings::warnif deprecated => __PACKAGE__ . "->get_bool is deprecated"; |
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
939
|
my $value = $self->get($field); |
67
|
3
|
100
|
|
|
|
12
|
return $value if ! is_bool $value; |
68
|
2
|
100
|
|
|
|
43
|
return $value if !! $value; |
69
|
1
|
|
|
|
|
10
|
return undef; ##no critic (ProhibitExplicitReturnUndef) |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub data { |
74
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
2
|
my %data = (); |
77
|
1
|
|
|
|
|
2
|
foreach my $key (keys %{ $self->{column_keys} }) { |
|
1
|
|
|
|
|
5
|
|
78
|
3
|
|
|
|
|
7
|
$data{$key} = $self->{row}->[ $self->{column_keys}->key($key) ]; |
79
|
|
|
|
|
|
|
} |
80
|
1
|
|
|
|
|
12
|
return \%data; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub summary { |
85
|
2
|
|
|
2
|
0
|
470
|
my ($self) = @_; |
86
|
|
|
|
|
|
|
|
87
|
2
|
|
66
|
|
|
15
|
$self->{_summary} //= Neo4j::Driver::ResultSummary->new; |
88
|
2
|
|
|
|
|
11
|
return $self->{_summary}->_init; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub stats { |
93
|
|
|
|
|
|
|
# uncoverable pod (see Deprecations.pod) |
94
|
4
|
|
|
4
|
0
|
7
|
my ($self) = @_; |
95
|
4
|
|
|
|
|
69
|
warnings::warnif deprecated => __PACKAGE__ . "->stats is deprecated; use summary instead"; |
96
|
|
|
|
|
|
|
|
97
|
4
|
100
|
|
|
|
1205
|
return $self->{_summary} ? $self->{_summary}->counters : {}; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |