MongoDB/Op/_ListIndexes.pm

filter: Statementstmt 74.6% 47 / 63 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 82.3% 14 / 17 Podpod 0.0% 0 / 1 totaltotal 59.8% 61 / 102 CC 8 SCAR 24.9
CC
8
Cov
59%
_command_list_indexes
42.0
execute
6.0
_legacy_list_indexes
6.0
CRAP 12.1
« MongoDB/Role/_WriteResult.pm ↑ Summary MongoDB/_TransactionOptions.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  
18 package MongoDB::Op::_ListIndexes;
19  
20 # Encapsulate index list operation; returns array ref of index documents
21  
22 59 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 59 our $VERSION = 'v2.2.2';
24  
25 59 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 59 ▶use MongoDB::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 59 ▶use MongoDB::Op::_Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 59 ▶use MongoDB::Op::_Query;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 59 ▶use MongoDB::ReadConcern;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 59 ▶use MongoDB::ReadPreference;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 59 ▶use Types::Standard qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
33 InstanceOf
34 59 );
35 59 ▶use Tie::IxHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 59 ▶use Safe::Isa;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 59 ▶use MongoDB::_Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
38 ReadPreference
39 59 );
40  
41 59 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 59 has client => (
44 is => 'ro',
45 required => 1,
46 isa => InstanceOf ['MongoDB::MongoClient'],
47 );
48  
49 59 has read_preference => (
50 is => 'rw', # rw for Op::_Query which can be modified by Cursor
51 required => 1,
52 isa => ReadPreference,
53 );
54  
55 59 with $_ for qw(
56 MongoDB::Role::_PrivateConstructor
57 MongoDB::Role::_CollectionOp
58 MongoDB::Role::_CommandCursorOp
59 );
60  
61 0 ▶sub execute {
Subroutine execute: not called CC=2 SCAR=17.9
Pod undocumented
62 0 my ( $self, $link, $topology ) = @_;
63  
64 0 ▶ my $res =
Branch: 1 branch
BranchTrueFalseTotal
$link->supports_list_commands ? : 0 0 0
65 $link->supports_list_commands
66 ? $self->_command_list_indexes( $link, $topology )
67 : $self->_legacy_list_indexes( $link, $topology );
68  
69 0 return $res;
70 }
71  
72 0 ▶sub _command_list_indexes {
Subroutine _command_list_indexes: not called CC=6 SCAR=37.4
73 0 my ( $self, $link, $topology ) = @_;
74  
75 0 my $op = MongoDB::Op::_Command->_new(
76 db_name => $self->db_name,
77 query => Tie::IxHash->new( listIndexes => $self->coll_name, cursor => {} ),
78 query_flags => {},
79 bson_codec => $self->bson_codec,
80 monitoring_callback => $self->monitoring_callback,
81 read_preference => $self->read_preference,
82 session => $self->session,
83 );
84  
85 my $res = eval {
86 0 $op->execute( $link, $topology );
87 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
my $res = eval { do { $op->execute($link, $topology) } } or do { my $error = $@ || "Unknown error"; unless ($error->$MongoDB::Op::_ListIndexes::_isa("MongoDB::DatabaseError") and $error->code == 26) { die $error; } ; undef } 0 0 0
88 0 ▶ my $error = $@ || "Unknown error";
Condition0%0/2
$@ || 'Unknown error'
l!l
00
MC/DC0%0/1
$@ || 'Unknown error'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
89 0 ▶ unless ( $error->$_isa("MongoDB::DatabaseError") and $error->code == NAMESPACE_NOT_FOUND()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error->$MongoDB::Op::_ListIndexes::_isa("MongoDB::DatabaseError") and $error->code == 26) 0 0 0
Condition0%0/3
$error->$MongoDB::Op::_ListIndexes::_isa("MongoDB::DatabaseError") and $error->code == 26
!ll&&!rl&&r
000
MC/DC0%0/2
$error->$MongoDB::Op::_ListIndexes::_isa("MongoDB::DatabaseError") and $error->code == 26
$error->$MongoDB::Op::_ListIndexes::_isa("MongoDB::DatabaseError") $error->code == 26
Truth table0%0/3
A and B
A= $error->$MongoDB::Op::_ListIndexes::_isa("MongoDB::DatabaseError")B= $error->code == 26
ABresult
0X0
100
111
90 0 die $error;
91 }
92 0 undef;
93 };
94  
95 0 ▶ return $res
Branch: 1 branch
BranchTrueFalseTotal
$res ? : 0 0 0
96 ? $self->_build_result_from_cursor($res)
97 : $self->_empty_query_result($link);
98 }
99  
100 0 ▶sub _legacy_list_indexes {
Subroutine _legacy_list_indexes: not called CC=2 SCAR=17.9
101 0 my ( $self, $link, $topology ) = @_;
102  
103 0 my $ns = $self->db_name . "." . $self->coll_name;
104 0 ▶ my $op = MongoDB::Op::_Query->_new(
Condition0%0/3
$self->read_preference || 'MongoDB::ReadPreference'->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->read_preference || 'MongoDB::ReadPreference'->new
$self->read_preference 'MongoDB::ReadPreference'->new
Truth table0%0/3
A || B
A= $self->read_preferenceB= 'MongoDB::ReadPreference'->new
ABresult
1X1
011
000
105 filter => Tie::IxHash->new( ns => $ns ),
106 options => MongoDB::Op::_Query->precondition_options({}),
107 bson_codec => $self->bson_codec,
108 client => $self->client,
109 coll_name => 'system.indexes',
110 db_name => $self->db_name,
111 full_name => $self->db_name . '.system.indexes',
112 read_concern => MongoDB::ReadConcern->new,
113 read_preference => $self->read_preference || MongoDB::ReadPreference->new,
114 monitoring_callback => $self->monitoring_callback,
115 );
116  
117 0 return $op->execute( $link, $topology );
118 }
119  
120 59 1;
« MongoDB/Role/_WriteResult.pm ↑ Summary MongoDB/_TransactionOptions.pm »