MongoDB/Op/_Count.pm

filter: Statementstmt 74.2% 26 / 35 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 60.0% 33 / 55 CC 5 SCAR 25.7
CC
5
Cov
59%
execute
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 13.1
« MongoDB/CommandResult.pm ↑ Summary MongoDB/MongoClient.pm »
1 # Copyright 2015 - 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::Op::_Count;
18  
19 # Encapsulate code path for count commands
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;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 59 ▶use MongoDB::Op::_Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 59 ▶use Types::Standard qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
28 HashRef
29 Maybe
30 59 );
31  
32 59 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 59 has filter => (
35 is => 'ro',
36 required => 1,
37 isa => Maybe[HashRef],
38 );
39  
40 59 has options => (
41 is => 'ro',
42 required => 1,
43 isa => HashRef,
44 );
45  
46 59 with $_ for qw(
47 MongoDB::Role::_PrivateConstructor
48 MongoDB::Role::_CollectionOp
49 MongoDB::Role::_ReadOp
50 );
51  
52 0 ▶sub execute {
Subroutine execute: not called CC=5 SCAR=34.0
Pod undocumented
53 0 my ( $self, $link, $topology ) = @_;
54  
55 0 ▶ if ( defined $self->options->{collation} and !$link->supports_collation ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->options->{"collation"} and not $link->supports_collation) 0 0 0
Condition0%0/3
defined $self->options->{"collation"} and not $link->supports_collation
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->options->{"collation"} and not $link->supports_collation
defined $self->options->{"collation"} not $link->supports_collation
Truth table0%0/3
A and not(B)
A= defined $self->options->{"collation"}B= not $link->supports_collation
ABresult
0X0
100
111
56 0 MongoDB::UsageError->throw(
57 "MongoDB host '" . $link->address . "' doesn't support collation" );
58 }
59  
60 my $command = [
61 count => $self->coll_name,
62 (defined $self->{filter} ? ( query => $self->{filter} ) : () ),
63 ($link->supports_read_concern ?
64 0 @{ $self->read_concern->as_args( $self->session ) } : () ),
65 0 ▶ %{ $self->options },
Branch: 2 branches
BranchTrueFalseTotal
defined $self->{'filter'} ? : 0 0 0
$link->supports_read_concern ? : 0 0 0
66 ];
67  
68 0 my $op = MongoDB::Op::_Command->_new(
69 db_name => $self->db_name,
70 query => $command,
71 query_flags => {},
72 bson_codec => $self->bson_codec,
73 read_preference => $self->read_preference,
74 session => $self->session,
75 monitoring_callback => $self->monitoring_callback,
76 );
77  
78 0 my $res = $op->execute( $link, $topology );
79 0 return $res->output;
80 }
81  
82 59 1;
« MongoDB/CommandResult.pm ↑ Summary MongoDB/MongoClient.pm »