line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
58
|
|
|
58
|
|
412
|
use strict; |
|
58
|
|
|
|
|
143
|
|
|
58
|
|
|
|
|
1883
|
|
16
|
58
|
|
|
58
|
|
383
|
use warnings; |
|
58
|
|
|
|
|
146
|
|
|
58
|
|
|
|
|
2246
|
|
17
|
|
|
|
|
|
|
package MongoDB::Op::_Delete; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Encapsulate a delete operation; returns a MongoDB::DeleteResult |
20
|
|
|
|
|
|
|
|
21
|
58
|
|
|
58
|
|
360
|
use version; |
|
58
|
|
|
|
|
139
|
|
|
58
|
|
|
|
|
346
|
|
22
|
|
|
|
|
|
|
our $VERSION = 'v2.2.0'; |
23
|
|
|
|
|
|
|
|
24
|
58
|
|
|
58
|
|
4651
|
use Moo; |
|
58
|
|
|
|
|
163
|
|
|
58
|
|
|
|
|
362
|
|
25
|
|
|
|
|
|
|
|
26
|
58
|
|
|
58
|
|
41280
|
use MongoDB::DeleteResult; |
|
58
|
|
|
|
|
188
|
|
|
58
|
|
|
|
|
2079
|
|
27
|
58
|
|
|
58
|
|
463
|
use MongoDB::_Protocol; |
|
58
|
|
|
|
|
138
|
|
|
58
|
|
|
|
|
1526
|
|
28
|
58
|
|
|
|
|
374
|
use MongoDB::_Types qw( |
29
|
|
|
|
|
|
|
Boolish |
30
|
|
|
|
|
|
|
Document |
31
|
58
|
|
|
58
|
|
355
|
); |
|
58
|
|
|
|
|
142
|
|
32
|
58
|
|
|
|
|
436
|
use Types::Standard qw( |
33
|
|
|
|
|
|
|
Maybe |
34
|
58
|
|
|
58
|
|
37164
|
); |
|
58
|
|
|
|
|
149
|
|
35
|
|
|
|
|
|
|
|
36
|
58
|
|
|
58
|
|
40664
|
use namespace::clean; |
|
58
|
|
|
|
|
144
|
|
|
58
|
|
|
|
|
293
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has filter => ( |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
required => 1, |
41
|
|
|
|
|
|
|
isa => Document, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has just_one => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
required => 1, |
47
|
|
|
|
|
|
|
isa => Boolish, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has collation => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
isa => Maybe( [Document] ), |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
with $_ for qw( |
56
|
|
|
|
|
|
|
MongoDB::Role::_PrivateConstructor |
57
|
|
|
|
|
|
|
MongoDB::Role::_CollectionOp |
58
|
|
|
|
|
|
|
MongoDB::Role::_SingleBatchDocWrite |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub execute { |
62
|
0
|
|
|
0
|
0
|
|
my ( $self, $link ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ( defined $self->collation ) { |
65
|
0
|
0
|
|
|
|
|
MongoDB::UsageError->throw( |
66
|
|
|
|
|
|
|
"MongoDB host '" . $link->address . "' doesn't support collation" ) |
67
|
|
|
|
|
|
|
if !$link->supports_collation; |
68
|
0
|
0
|
|
|
|
|
MongoDB::UsageError->throw( |
69
|
|
|
|
|
|
|
"Unacknowledged deletes that specify a collation are not allowed") |
70
|
|
|
|
|
|
|
if ! $self->_should_use_acknowledged_write; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $filter = |
74
|
|
|
|
|
|
|
ref( $self->filter ) eq 'ARRAY' |
75
|
0
|
0
|
|
|
|
|
? { @{ $self->filter } } |
|
0
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
: $self->filter; |
77
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
my $op_doc = { |
|
|
0
|
|
|
|
|
|
79
|
|
|
|
|
|
|
q => $filter, |
80
|
|
|
|
|
|
|
limit => $self->just_one ? 1 : 0, |
81
|
|
|
|
|
|
|
( defined $self->collation ? ( collation => $self->collation ) : () ), |
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return ( |
85
|
|
|
|
|
|
|
! $self->_should_use_acknowledged_write |
86
|
|
|
|
|
|
|
? ( |
87
|
|
|
|
|
|
|
$self->_send_legacy_op_noreply( |
88
|
|
|
|
|
|
|
$link, |
89
|
|
|
|
|
|
|
MongoDB::_Protocol::write_delete( |
90
|
|
|
|
|
|
|
$self->full_name, |
91
|
|
|
|
|
|
|
$self->bson_codec->encode_one( $self->filter ), |
92
|
|
|
|
|
|
|
{ just_one => $self->just_one ? 1 : 0 } |
93
|
|
|
|
|
|
|
), |
94
|
|
|
|
|
|
|
$op_doc, |
95
|
|
|
|
|
|
|
"MongoDB::DeleteResult", |
96
|
|
|
|
|
|
|
"delete", |
97
|
|
|
|
|
|
|
) |
98
|
|
|
|
|
|
|
) |
99
|
|
|
|
|
|
|
: $link->supports_write_commands |
100
|
|
|
|
|
|
|
? ( |
101
|
|
|
|
|
|
|
$self->_send_write_command( |
102
|
|
|
|
|
|
|
$link, |
103
|
|
|
|
|
|
|
[ |
104
|
|
|
|
|
|
|
delete => $self->coll_name, |
105
|
|
|
|
|
|
|
deletes => [$op_doc], |
106
|
0
|
0
|
|
|
|
|
@{ $self->write_concern->as_args }, |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
107
|
|
|
|
|
|
|
], |
108
|
|
|
|
|
|
|
$op_doc, |
109
|
|
|
|
|
|
|
"MongoDB::DeleteResult" |
110
|
|
|
|
|
|
|
)->assert |
111
|
|
|
|
|
|
|
) |
112
|
|
|
|
|
|
|
: ( |
113
|
|
|
|
|
|
|
$self->_send_legacy_op_with_gle( |
114
|
|
|
|
|
|
|
$link, |
115
|
|
|
|
|
|
|
MongoDB::_Protocol::write_delete( |
116
|
|
|
|
|
|
|
$self->full_name, |
117
|
|
|
|
|
|
|
$self->bson_codec->encode_one( $self->filter ), |
118
|
|
|
|
|
|
|
{ just_one => $self->just_one ? 1 : 0 } |
119
|
|
|
|
|
|
|
), |
120
|
|
|
|
|
|
|
$op_doc, |
121
|
|
|
|
|
|
|
"MongoDB::DeleteResult", |
122
|
|
|
|
|
|
|
"delete", |
123
|
|
|
|
|
|
|
)->assert |
124
|
|
|
|
|
|
|
) |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _parse_cmd { |
129
|
0
|
|
|
0
|
|
|
my ( $self, $res ) = @_; |
130
|
0
|
|
0
|
|
|
|
return ( deleted_count => $res->{n} || 0 ); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
BEGIN { |
134
|
58
|
|
|
58
|
|
36737
|
no warnings 'once'; |
|
58
|
|
|
|
|
171
|
|
|
58
|
|
|
|
|
2898
|
|
135
|
58
|
|
|
58
|
|
1941
|
*_parse_gle = \&_parse_cmd; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |