mongo 2.18.1 → 2.18.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +1 -1
  4. data/lib/mongo/bulk_write.rb +6 -4
  5. data/lib/mongo/client.rb +1 -1
  6. data/lib/mongo/collection/view/iterable.rb +15 -0
  7. data/lib/mongo/collection/view/writable.rb +0 -2
  8. data/lib/mongo/collection/view.rb +1 -0
  9. data/lib/mongo/collection.rb +150 -45
  10. data/lib/mongo/crypt/auto_encrypter.rb +1 -0
  11. data/lib/mongo/crypt/explicit_encrypter.rb +1 -0
  12. data/lib/mongo/crypt/kms.rb +0 -1
  13. data/lib/mongo/crypt.rb +11 -0
  14. data/lib/mongo/error/invalid_read_option.rb +1 -1
  15. data/lib/mongo/grid/file/chunk.rb +2 -1
  16. data/lib/mongo/grid/file/info.rb +2 -1
  17. data/lib/mongo/operation/aggregate.rb +1 -2
  18. data/lib/mongo/operation/collections_info.rb +3 -15
  19. data/lib/mongo/operation/command.rb +1 -2
  20. data/lib/mongo/operation/count.rb +1 -2
  21. data/lib/mongo/operation/create.rb +1 -2
  22. data/lib/mongo/operation/create_index.rb +1 -2
  23. data/lib/mongo/operation/create_user.rb +1 -2
  24. data/lib/mongo/operation/delete.rb +0 -1
  25. data/lib/mongo/operation/distinct.rb +1 -2
  26. data/lib/mongo/operation/drop.rb +1 -2
  27. data/lib/mongo/operation/drop_database.rb +1 -2
  28. data/lib/mongo/operation/drop_index.rb +1 -2
  29. data/lib/mongo/operation/explain.rb +1 -3
  30. data/lib/mongo/operation/find/builder.rb +0 -1
  31. data/lib/mongo/operation/find.rb +1 -3
  32. data/lib/mongo/operation/get_more.rb +1 -3
  33. data/lib/mongo/operation/indexes.rb +1 -17
  34. data/lib/mongo/operation/insert.rb +0 -1
  35. data/lib/mongo/operation/kill_cursors.rb +1 -2
  36. data/lib/mongo/operation/list_collections.rb +1 -2
  37. data/lib/mongo/operation/map_reduce.rb +1 -2
  38. data/lib/mongo/operation/parallel_scan.rb +1 -2
  39. data/lib/mongo/operation/remove_user.rb +1 -2
  40. data/lib/mongo/operation/shared/{polymorphic_operation.rb → op_msg_executable.rb} +11 -6
  41. data/lib/mongo/operation/update.rb +0 -1
  42. data/lib/mongo/operation/update_user.rb +1 -2
  43. data/lib/mongo/operation/users_info.rb +1 -2
  44. data/lib/mongo/operation/write_command.rb +1 -2
  45. data/lib/mongo/operation.rb +1 -3
  46. data/lib/mongo/protocol/bit_vector.rb +3 -1
  47. data/lib/mongo/protocol/caching_hash.rb +3 -20
  48. data/lib/mongo/protocol/message.rb +4 -8
  49. data/lib/mongo/protocol/msg.rb +1 -0
  50. data/lib/mongo/protocol/serializers.rb +24 -17
  51. data/lib/mongo/protocol.rb +0 -3
  52. data/lib/mongo/query_cache.rb +20 -20
  53. data/lib/mongo/server/app_metadata/environment.rb +255 -0
  54. data/lib/mongo/server/app_metadata/truncator.rb +142 -0
  55. data/lib/mongo/server/app_metadata.rb +29 -42
  56. data/lib/mongo/session.rb +1 -1
  57. data/lib/mongo/version.rb +1 -1
  58. data/spec/integration/command_spec.rb +1 -23
  59. data/spec/integration/connection/faas_env_spec.rb +63 -0
  60. data/spec/integration/find_options_spec.rb +227 -0
  61. data/spec/integration/ocsp_verifier_spec.rb +1 -1
  62. data/spec/lite_spec_helper.rb +9 -0
  63. data/spec/mongo/address_spec.rb +1 -1
  64. data/spec/mongo/client_construction_spec.rb +7 -7
  65. data/spec/mongo/client_spec.rb +1 -9
  66. data/spec/mongo/cluster_spec.rb +2 -2
  67. data/spec/mongo/collection_crud_spec.rb +56 -0
  68. data/spec/mongo/collection_spec.rb +11 -1
  69. data/spec/mongo/crypt/kms_spec.rb +12 -9
  70. data/spec/mongo/crypt_spec.rb +21 -0
  71. data/spec/mongo/index/view_spec.rb +1 -0
  72. data/spec/mongo/protocol/caching_hash_spec.rb +0 -45
  73. data/spec/mongo/protocol/msg_spec.rb +2 -4
  74. data/spec/mongo/server/app_metadata/environment_spec.rb +193 -0
  75. data/spec/mongo/server/app_metadata/truncator_spec.rb +158 -0
  76. data/spec/mongo/server/app_metadata_spec.rb +33 -47
  77. data/spec/mongo/socket/ssl_spec.rb +2 -8
  78. data/spec/runners/crud/requirement.rb +2 -2
  79. data/spec/shared/lib/mrss/docker_runner.rb +4 -0
  80. data/spec/shared/lib/mrss/lite_constraints.rb +8 -0
  81. data/spec/shared/lib/mrss/server_version_registry.rb +16 -23
  82. data/spec/shared/share/Dockerfile.erb +24 -19
  83. data/spec/shared/shlib/server.sh +31 -7
  84. data/spec/shared/shlib/set_env.sh +4 -4
  85. data/spec/solo/clean_exit_spec.rb +3 -10
  86. data/spec/spec_tests/data/change_streams_unified/change-streams-showExpandedEvents.yml +15 -6
  87. data/spec/spec_tests/data/command_monitoring_unified/redacted-commands.yml +8 -0
  88. data/spec/support/aws_utils.rb +3 -3
  89. data/spec/support/certificates/atlas-ocsp-ca.crt +67 -67
  90. data/spec/support/certificates/atlas-ocsp.crt +103 -103
  91. data/spec/support/shared/app_metadata.rb +14 -2
  92. data.tar.gz.sig +0 -0
  93. metadata +1203 -1239
  94. metadata.gz.sig +0 -0
  95. data/lib/mongo/operation/aggregate/command.rb +0 -55
  96. data/lib/mongo/operation/collections_info/command.rb +0 -48
  97. data/lib/mongo/operation/command/command.rb +0 -41
  98. data/lib/mongo/operation/count/command.rb +0 -47
  99. data/lib/mongo/operation/create/command.rb +0 -47
  100. data/lib/mongo/operation/create_index/command.rb +0 -61
  101. data/lib/mongo/operation/create_user/command.rb +0 -46
  102. data/lib/mongo/operation/delete/command.rb +0 -52
  103. data/lib/mongo/operation/distinct/command.rb +0 -47
  104. data/lib/mongo/operation/drop/command.rb +0 -41
  105. data/lib/mongo/operation/drop_database/command.rb +0 -41
  106. data/lib/mongo/operation/drop_index/command.rb +0 -45
  107. data/lib/mongo/operation/explain/command.rb +0 -58
  108. data/lib/mongo/operation/explain/legacy.rb +0 -52
  109. data/lib/mongo/operation/find/builder/legacy.rb +0 -123
  110. data/lib/mongo/operation/find/command.rb +0 -51
  111. data/lib/mongo/operation/find/legacy/result.rb +0 -46
  112. data/lib/mongo/operation/find/legacy.rb +0 -52
  113. data/lib/mongo/operation/get_more/command.rb +0 -43
  114. data/lib/mongo/operation/get_more/legacy.rb +0 -39
  115. data/lib/mongo/operation/indexes/command.rb +0 -42
  116. data/lib/mongo/operation/indexes/legacy.rb +0 -48
  117. data/lib/mongo/operation/insert/command.rb +0 -55
  118. data/lib/mongo/operation/kill_cursors/command.rb +0 -48
  119. data/lib/mongo/operation/list_collections/command.rb +0 -46
  120. data/lib/mongo/operation/map_reduce/command.rb +0 -51
  121. data/lib/mongo/operation/parallel_scan/command.rb +0 -57
  122. data/lib/mongo/operation/remove_user/command.rb +0 -46
  123. data/lib/mongo/operation/shared/op_msg_or_command.rb +0 -41
  124. data/lib/mongo/operation/shared/op_msg_or_find_command.rb +0 -44
  125. data/lib/mongo/operation/update/command.rb +0 -53
  126. data/lib/mongo/operation/update_user/command.rb +0 -45
  127. data/lib/mongo/operation/users_info/command.rb +0 -46
  128. data/lib/mongo/operation/write_command/command.rb +0 -51
  129. data/lib/mongo/protocol/delete.rb +0 -172
  130. data/lib/mongo/protocol/insert.rb +0 -181
  131. data/lib/mongo/protocol/update.rb +0 -214
  132. data/spec/mongo/operation/delete/command_spec.rb +0 -115
  133. data/spec/mongo/operation/find/legacy_spec.rb +0 -131
  134. data/spec/mongo/operation/get_more_spec.rb +0 -63
  135. data/spec/mongo/operation/insert/command_spec.rb +0 -118
  136. data/spec/mongo/operation/update/command_spec.rb +0 -122
  137. data/spec/mongo/protocol/delete_spec.rb +0 -185
  138. data/spec/mongo/protocol/insert_spec.rb +0 -179
  139. data/spec/mongo/protocol/update_spec.rb +0 -204
@@ -1,123 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2015-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class Find
21
- module Builder
22
-
23
- # Builds a legacy OP_QUERY specification from options.
24
- #
25
- # @api private
26
- module Legacy
27
-
28
- # Mappings from driver options to legacy server values.
29
- #
30
- # @since 2.2.0
31
- DRIVER_MAPPINGS = {
32
- comment: '$comment',
33
- explain: '$explain',
34
- hint: '$hint',
35
- max_scan: '$maxScan',
36
- max_time_ms: '$maxTimeMS',
37
- max_value: '$max',
38
- min_value: '$min',
39
- show_disk_loc: '$showDiskLoc',
40
- snapshot: '$snapshot',
41
- sort: '$orderby',
42
- return_key: '$returnKey',
43
- }.freeze
44
-
45
- module_function def selector(spec, connection)
46
- if Lint.enabled?
47
- if spec.keys.any? { |k| String === k }
48
- raise Error::LintError, "The spec must contain symbol keys only"
49
- end
50
- end
51
-
52
- # Server versions that do not have the find command feature
53
- # (versions older than 3.2) do not support the allow_disk_use option
54
- # but perform no validation and will not raise an error if it is
55
- # specified. If the allow_disk_use option is specified, raise an error
56
- # to alert the user.
57
- unless spec[:allow_disk_use].nil?
58
- raise Error::UnsupportedOption.allow_disk_use_error
59
- end
60
-
61
- if spec[:collation] && !connection.features.collation_enabled?
62
- raise Error::UnsupportedCollation
63
- end
64
-
65
- modifiers = {}
66
- DRIVER_MAPPINGS.each do |k, server_k|
67
- unless (value = spec[k]).nil?
68
- modifiers[server_k] = value
69
- end
70
- end
71
-
72
- selector = spec[:filter] || BSON::Document.new
73
- # Write nil into rp if not talking to mongos, rather than false
74
- rp = if connection.description.mongos?
75
- read_pref_formatted(spec)
76
- end
77
- if modifiers.any? || rp
78
- selector = {'$query' => selector}.update(modifiers)
79
-
80
- if rp
81
- selector['$readPreference'] = rp
82
- end
83
- end
84
-
85
- selector
86
- end
87
-
88
- module_function def query_options(spec, connection)
89
- query_options = {
90
- project: spec[:projection],
91
- skip: spec[:skip],
92
- limit: spec[:limit],
93
- # batch_size is converted to batchSize by Mongo::Protocol::Query.
94
- batch_size: spec[:batch_size],
95
- }
96
-
97
- unless (flags = Builder::Flags.map_flags(spec)).empty?
98
- query_options[:flags] = ((query_options[:flags] || []) + flags).uniq
99
- end
100
-
101
- query_options
102
- end
103
-
104
- private
105
-
106
- module_function def read_pref_formatted(spec)
107
- if spec[:read_preference]
108
- raise ArgumentError, "Spec cannot include :read_preference here, use :read"
109
- end
110
-
111
- if read = spec[:read]
112
- read_pref = ServerSelector.get(read).to_mongos
113
- Mongo::Lint.validate_camel_case_read_preference(read_pref)
114
- read_pref
115
- else
116
- nil
117
- end
118
- end
119
- end
120
- end
121
- end
122
- end
123
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class Find
21
-
22
- # A MongoDB find operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include ReadPreferenceSupported
32
- include PolymorphicResult
33
-
34
- private
35
-
36
- def selector(connection)
37
- # The mappings are BSON::Documents and as such store keys as
38
- # strings, the spec here has symbol keys
39
- spec = BSON::Document.new(self.spec)
40
- {
41
- find: coll_name,
42
- }.update(Find::Builder::Command.selector(spec, connection))
43
- end
44
-
45
- def message(connection)
46
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2014-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class Find
21
- class Legacy
22
-
23
- # Defines custom behavior of results for a query.
24
- #
25
- # @since 2.1.0
26
- # @api semiprivate
27
- class Result < Operation::Result
28
- include Operation::Result::UseLegacyErrorParser
29
-
30
- # Determine if the query was a success.
31
- #
32
- # @example Was the query successful?
33
- # result.successful?
34
- #
35
- # @return [ true, false ] If the query was successful.
36
- #
37
- # @since 2.0.0
38
- # @api public
39
- def successful?
40
- !query_failure?
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- require 'mongo/operation/find/legacy/result'
19
-
20
- module Mongo
21
- module Operation
22
- class Find
23
-
24
- # A MongoDB find operation sent as a legacy wire protocol message.
25
- #
26
- # @api private
27
- #
28
- # @since 2.5.2
29
- class Legacy
30
- include Specifiable
31
- include Executable
32
- include ReadPreferenceSupported
33
- include PolymorphicResult
34
-
35
- private
36
-
37
- def message(connection)
38
- selector = Find::Builder::Legacy.selector(spec, connection)
39
- options = options(connection).update(
40
- Find::Builder::Legacy.query_options(spec, connection),
41
- )
42
- Protocol::Query.new(
43
- db_name,
44
- coll_name,
45
- selector,
46
- options,
47
- )
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class GetMore
21
-
22
- # A MongoDB getMore operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include ReadPreferenceSupported
32
- include PolymorphicResult
33
- include CommandBuilder
34
-
35
- private
36
-
37
- def message(connection)
38
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class GetMore
21
-
22
- # A MongoDB getMore operation sent as a legacy wire protocol message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Legacy
28
- include Specifiable
29
- include Executable
30
-
31
- private
32
-
33
- def message(connection)
34
- Protocol::GetMore.new(db_name, coll_name, to_return, cursor_id)
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class Indexes
21
-
22
- # A MongoDB indexes operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include ReadPreferenceSupported
32
- include PolymorphicResult
33
-
34
- private
35
-
36
- def message(connection)
37
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2014-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class Indexes
21
-
22
- # A MongoDB indexes operation sent as a legacy wire protocol message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Legacy
28
- include Specifiable
29
- include Executable
30
- include ReadPreferenceSupported
31
-
32
- private
33
-
34
- def selector(connection)
35
- { ns: namespace }
36
- end
37
-
38
- def message(connection)
39
- Protocol::Query.new(db_name, Index::COLLECTION, command(connection), options(connection))
40
- end
41
-
42
- def result_class
43
- Operation::Result
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class Insert
21
-
22
- # A MongoDB insert operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include ExecutableNoValidate
31
- include Idable
32
- include Limited
33
- include WriteConcernSupported
34
- include BypassDocumentValidation
35
-
36
- private
37
-
38
- def get_result(connection, context, options = {})
39
- # This is a Mongo::Operation::Insert::Result
40
- Result.new(*dispatch_message(connection, context), @ids)
41
- end
42
-
43
- def selector(connection)
44
- { insert: coll_name,
45
- documents: send(IDENTIFIER),
46
- ordered: ordered? }
47
- end
48
-
49
- def message(connection)
50
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class KillCursors
21
-
22
- # A MongoDB killcursors operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include CommandBuilder
32
-
33
- private
34
-
35
- def selector(connection)
36
- {
37
- killCursors: coll_name,
38
- cursors: int64_cursor_ids,
39
- }
40
- end
41
-
42
- def message(connection)
43
- Protocol::Query.new(db_name, Database::COMMAND, selector(connection), options(connection))
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class ListCollections
21
-
22
- # A MongoDB listcollections operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include ReadPreferenceSupported
32
- include PolymorphicResult
33
-
34
- private
35
-
36
- def selector(connection)
37
- (spec[SELECTOR] || {}).merge(listCollections: 1)
38
- end
39
-
40
- def message(connection)
41
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- # Copyright (C) 2018-2020 MongoDB Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- module Mongo
19
- module Operation
20
- class MapReduce
21
-
22
- # A MongoDB mapreduce operation sent as a command message.
23
- #
24
- # @api private
25
- #
26
- # @since 2.5.2
27
- class Command
28
- include Specifiable
29
- include Executable
30
- include Limited
31
- include ReadPreferenceSupported
32
- include WriteConcernSupported
33
- include PolymorphicResult
34
-
35
- private
36
-
37
- def selector(connection)
38
- super.tap do |selector|
39
- if selector[:collation] && !connection.features.collation_enabled?
40
- raise Error::UnsupportedCollation
41
- end
42
- end
43
- end
44
-
45
- def message(connection)
46
- Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
47
- end
48
- end
49
- end
50
- end
51
- end