MongoDB/Op/_DropIndexes.pm

filter: Statementstmt 72.7% 32 / 44 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 1 totaltotal 58.5% 41 / 70 CC 7 SCAR 32.2
CC
7
Cov
56%
execute
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 25.1
« MongoDB/Role/_DeprecationWarner.pm ↑ Summary MongoDB/IndexView.pm »
1 # Copyright 2016 - 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::_DropIndexes;
18  
19 # Implements index drops; returns a MongoDB::CommandResult
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::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 59 ▶use MongoDB::Op::_Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 59 ▶use Safe::Isa;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 59 ▶use MongoDB::_Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
30 Numish
31 Stringish
32 59 );
33  
34 59 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 59 has index_name => (
37 is => 'ro',
38 required => 1,
39 isa => Stringish,
40 );
41  
42 59 has max_time_ms => (
43 is => 'ro',
44 isa => Numish,
45 );
46  
47 59 with $_ for qw(
48 MongoDB::Role::_PrivateConstructor
49 MongoDB::Role::_CollectionOp
50 MongoDB::Role::_WriteOp
51 );
52  
53 0 ▶sub execute {
Subroutine execute: not called CC=7 SCAR=40.3
Pod undocumented
54 0 my ( $self, $link ) = @_;
55  
56 my $op = MongoDB::Op::_Command->_new(
57 db_name => $self->db_name,
58 query => [
59 dropIndexes => $self->coll_name,
60 index => $self->index_name,
61 0 ▶ ( $link->supports_helper_write_concern ? ( @{ $self->write_concern->as_args } ) : () ),
Branch: 2 branches
BranchTrueFalseTotal
$link->supports_helper_write_concern ? : 0 0 0
defined $self->max_time_ms ? : 0 0 0
62 (defined($self->max_time_ms)
63 ? (maxTimeMS => $self->max_time_ms)
64 : ()
65 ),
66 ],
67 query_flags => {},
68 bson_codec => $self->bson_codec,
69 monitoring_callback => $self->monitoring_callback,
70 );
71  
72 0 my $res;
73 0 eval {
74 0 $res = $op->execute($link);
75 0 $res->assert_no_write_concern_error;
76 };
77 # XXX This logic will be a problem for command monitoring - may need to
78 # move into Op::_Command as an 'error_filter' callback or something.
79 0 ▶ if ( my $err = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $err = $@) 0 0 0
80 0 ▶ if ( $err->$_isa("MongoDB::DatabaseError") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err->$MongoDB::Op::_DropIndexes::_isa("MongoDB::DatabaseError")) 0 0 0
81 # 2.6 and 3.0 don't have the code, so we fallback to string
82 # matching on the error message
83 0 ▶ return $err->result
Branch: 1 branch
BranchTrueFalseTotal
if $err->code == 27 or $err->message =~ /index not found with name/ 0 0 0
Condition0%0/3
$err->code == 27 or $err->message =~ /index not found with name/
l!l&&r!l&&!r
000
MC/DC0%0/2
$err->code == 27 or $err->message =~ /index not found with name/
$err->code == 27 $err->message =~ /index not found with name/
Truth table0%0/3
A or B
A= $err->code == 27B= $err->message =~ /index not found with name/
ABresult
1X1
011
000
84 if $err->code == INDEX_NOT_FOUND() || $err->message =~ /index not found with name/;
85 }
86 0 die $err;
87 }
88  
89 0 return $res;
90 }
91  
92 59 1;
« MongoDB/Role/_DeprecationWarner.pm ↑ Summary MongoDB/IndexView.pm »