MongoDB/Role/_CommandCursorOp.pm

filter: Statementstmt 64.8% 24 / 37 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod n/a totaltotal 44.2% 31 / 70 CC 10 SCAR 41.2
CC
10
Cov
42%
_build_result_from_cursor
110.0
_empty_query_result
2.0
BEGIN
1.0
CRAP 61.6
« MongoDB/_Link.pm ↑ Summary MongoDB/Op/_Delete.pm »
1 # Copyright 2014 - present MongoDB, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 59 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 package MongoDB::Role::_CommandCursorOp;
18  
19 # MongoDB interface for database commands with cursors
20  
21 59 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 59 our $VERSION = 'v2.2.2';
23  
24 59 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 59 ▶use MongoDB::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 59 ▶use MongoDB::QueryResult;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 59 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 59 requires qw/session client bson_codec/;
32  
33 0 ▶sub _build_result_from_cursor {
Subroutine _build_result_from_cursor: not called CC=10 SCAR=47.0
34 0 my ( $self, $res ) = @_;
35  
36 my $c = $res->output->{cursor}
37 0 ▶ or MongoDB::DatabaseError->throw(
Branch: 1 branch
BranchTrueFalseTotal
my $c = $res->output->{"cursor"} or "MongoDB::DatabaseError"->throw("message", "no cursor found in command response", "result", $res) 0 0 0
38 message => "no cursor found in command response",
39 result => $res,
40 );
41  
42 0 my $max_time_ms = 0;
43 0 ▶ if ($self->isa('MongoDB::Op::_Query') &&
Branch: 2 branches
BranchTrueFalseTotal
if ($self->isa('MongoDB::Op::_Query') and $self->options->{'cursorType'} eq 'tailable_await') { } 0 0 0
elsif ($self->isa('MongoDB::Op::_Aggregate') or $self->isa('MongoDB::Op::_ChangeStream')) { } 0 0 0
Condition0%0/3
$self->isa("MongoDB::Op::_Query") and $self->options->{"cursorType"} eq "tailable_await"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->isa("MongoDB::Op::_Query") and $self->options->{"cursorType"} eq "tailable_await"
$self->isa("MongoDB::Op::_Query") $self->options->{"cursorType"} eq "tailable_await"
Truth table0%0/3
A and B
A= $self->isa("MongoDB::Op::_Query")B= $self->options->{"cursorType"} eq "tailable_await"
ABresult
0X0
100
111
44 $self->options->{cursorType} eq 'tailable_await') {
45 0 ▶ $max_time_ms = $self->options->{maxAwaitTimeMS} if $self->options->{maxAwaitTimeMS};
Branch: 1 branch
BranchTrueFalseTotal
if $self->options->{"maxAwaitTimeMS"} 0 0 0
46 }
47 ▶ elsif (
Condition0%0/3
$self->isa("MongoDB::Op::_Aggregate") or $self->isa("MongoDB::Op::_ChangeStream")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->isa("MongoDB::Op::_Aggregate") or $self->isa("MongoDB::Op::_ChangeStream")
$self->isa("MongoDB::Op::_Aggregate") $self->isa("MongoDB::Op::_ChangeStream")
Truth table0%0/3
A or B
A= $self->isa("MongoDB::Op::_Aggregate")B= $self->isa("MongoDB::Op::_ChangeStream")
ABresult
1X1
011
000
48 $self->isa('MongoDB::Op::_Aggregate') ||
49 $self->isa('MongoDB::Op::_ChangeStream')
50 ) {
51 0 ▶ $max_time_ms = $self->maxAwaitTimeMS if $self->maxAwaitTimeMS;
Branch: 1 branch
BranchTrueFalseTotal
if $self->maxAwaitTimeMS 0 0 0
52 }
53  
54 0 my $limit = 0;
55 0 ▶ if ($self->isa('MongoDB::Op::_Query')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa("MongoDB::Op::_Query")) 0 0 0
56 0 ▶ $limit = $self->options->{limit} if $self->options->{limit};
Branch: 1 branch
BranchTrueFalseTotal
if $self->options->{"limit"} 0 0 0
57 }
58  
59 0 my $batch = $c->{firstBatch};
60 my $qr = MongoDB::QueryResult->_new(
61 _client => $self->client,
62 _address => $res->address,
63 _full_name => $c->{ns},
64 _bson_codec => $self->bson_codec,
65 _batch_size => scalar @$batch,
66 _cursor_at => 0,
67 _limit => $limit,
68 _cursor_id => $c->{id},
69 _cursor_start => 0,
70 _cursor_flags => {},
71 _cursor_num => scalar @$batch,
72 _docs => $batch,
73 _max_time_ms => $max_time_ms,
74 _session => $self->session,
75 _post_batch_resume_token => $c->{postBatchResumeToken},
76 0 );
77 }
78  
79 0 ▶sub _empty_query_result {
Subroutine _empty_query_result: not called CC=1 SCAR=6.9
80 0 my ( $self, $link ) = @_;
81  
82 0 my $qr = MongoDB::QueryResult->_new(
83 _client => $self->client,
84 _address => $link->address,
85 _full_name => '',
86 _bson_codec => $self->bson_codec,
87 _batch_size => 1,
88 _cursor_at => 0,
89 _limit => 0,
90 _cursor_id => 0,
91 _cursor_start => 0,
92 _cursor_flags => {},
93 _cursor_num => 0,
94 _docs => [],
95 );
96 }
97  
98 59 1;
« MongoDB/_Link.pm ↑ Summary MongoDB/Op/_Delete.pm »