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
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/create/command'
19
18
  require 'mongo/operation/create/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class Create
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/create_index/command'
19
18
  require 'mongo/operation/create_index/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class CreateIndex
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/create_user/command'
19
18
  require 'mongo/operation/create_user/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class CreateUser
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/delete/command'
19
18
  require 'mongo/operation/delete/op_msg'
20
19
  require 'mongo/operation/delete/result'
21
20
  require 'mongo/operation/delete/bulk_result'
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/distinct/command'
19
18
  require 'mongo/operation/distinct/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.5.0
29
28
  class Distinct
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/drop/command'
19
18
  require 'mongo/operation/drop/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.4.0
29
28
  class Drop
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/drop_database/command'
19
18
  require 'mongo/operation/drop_database/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.4.0
29
28
  class DropDatabase
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/drop_index/command'
19
18
  require 'mongo/operation/drop_index/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class DropIndex
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -17,8 +17,6 @@
17
17
 
18
18
  require 'mongo/operation/explain/result'
19
19
  require 'mongo/operation/explain/op_msg'
20
- require 'mongo/operation/explain/command'
21
- require 'mongo/operation/explain/legacy'
22
20
 
23
21
  module Mongo
24
22
  module Operation
@@ -30,7 +28,7 @@ module Mongo
30
28
  # @since 2.5.0
31
29
  class Explain
32
30
  include Specifiable
33
- include OpMsgOrFindCommand
31
+ include OpMsgExecutable
34
32
  end
35
33
  end
36
34
  end
@@ -17,5 +17,4 @@
17
17
 
18
18
  require 'mongo/operation/find/builder/command'
19
19
  require 'mongo/operation/find/builder/flags'
20
- require 'mongo/operation/find/builder/legacy'
21
20
  require 'mongo/operation/find/builder/modifiers'
@@ -15,9 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/find/command'
19
18
  require 'mongo/operation/find/op_msg'
20
- require 'mongo/operation/find/legacy'
21
19
  require 'mongo/operation/find/result'
22
20
  require 'mongo/operation/find/builder'
23
21
 
@@ -31,7 +29,7 @@ module Mongo
31
29
  # @since 2.0.0
32
30
  class Find
33
31
  include Specifiable
34
- include OpMsgOrFindCommand
32
+ include OpMsgExecutable
35
33
  end
36
34
  end
37
35
  end
@@ -16,9 +16,7 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require 'mongo/operation/get_more/command_builder'
19
- require 'mongo/operation/get_more/command'
20
19
  require 'mongo/operation/get_more/op_msg'
21
- require 'mongo/operation/get_more/legacy'
22
20
  require 'mongo/operation/get_more/result'
23
21
 
24
22
  module Mongo
@@ -31,7 +29,7 @@ module Mongo
31
29
  # @since 2.5.0
32
30
  class GetMore
33
31
  include Specifiable
34
- include OpMsgOrFindCommand
32
+ include OpMsgExecutable
35
33
  end
36
34
  end
37
35
  end
@@ -15,9 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/indexes/command'
19
18
  require 'mongo/operation/indexes/op_msg'
20
- require 'mongo/operation/indexes/legacy'
21
19
  require 'mongo/operation/indexes/result'
22
20
 
23
21
  module Mongo
@@ -30,21 +28,7 @@ module Mongo
30
28
  # @since 2.0.0
31
29
  class Indexes
32
30
  include Specifiable
33
- include PolymorphicOperation
34
- include PolymorphicLookup
35
-
36
- private
37
-
38
- def final_operation(connection)
39
- cls = if connection.features.op_msg_enabled?
40
- polymorphic_class(self.class.name, :OpMsg)
41
- elsif connection.features.list_indexes_enabled?
42
- polymorphic_class(self.class.name, :Command)
43
- else
44
- polymorphic_class(self.class.name, :Legacy)
45
- end
46
- cls.new(spec)
47
- end
31
+ include OpMsgExecutable
48
32
  end
49
33
  end
50
34
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/insert/command'
19
18
  require 'mongo/operation/insert/op_msg'
20
19
  require 'mongo/operation/insert/result'
21
20
  require 'mongo/operation/insert/bulk_result'
@@ -16,7 +16,6 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require 'mongo/operation/kill_cursors/command_builder'
19
- require 'mongo/operation/kill_cursors/command'
20
19
  require 'mongo/operation/kill_cursors/op_msg'
21
20
 
22
21
  module Mongo
@@ -29,7 +28,7 @@ module Mongo
29
28
  # @since 2.0.0
30
29
  class KillCursors
31
30
  include Specifiable
32
- include OpMsgOrFindCommand
31
+ include OpMsgExecutable
33
32
  end
34
33
  end
35
34
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/list_collections/command'
19
18
  require 'mongo/operation/list_collections/op_msg'
20
19
  require 'mongo/operation/list_collections/result'
21
20
 
@@ -29,7 +28,7 @@ module Mongo
29
28
  # @since 2.0.0
30
29
  class ListCollections
31
30
  include Specifiable
32
- include OpMsgOrCommand
31
+ include OpMsgExecutable
33
32
  end
34
33
  end
35
34
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/map_reduce/command'
19
18
  require 'mongo/operation/map_reduce/op_msg'
20
19
  require 'mongo/operation/map_reduce/result'
21
20
 
@@ -29,7 +28,7 @@ module Mongo
29
28
  # @since 2.5.0
30
29
  class MapReduce
31
30
  include Specifiable
32
- include OpMsgOrCommand
31
+ include OpMsgExecutable
33
32
  end
34
33
  end
35
34
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/parallel_scan/command'
19
18
  require 'mongo/operation/parallel_scan/op_msg'
20
19
  require 'mongo/operation/parallel_scan/result'
21
20
 
@@ -29,7 +28,7 @@ module Mongo
29
28
  # @since 2.0.0
30
29
  class ParallelScan
31
30
  include Specifiable
32
- include OpMsgOrCommand
31
+ include OpMsgExecutable
33
32
  end
34
33
  end
35
34
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/remove_user/command'
19
18
  require 'mongo/operation/remove_user/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class RemoveUser
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  # encoding: utf-8
3
3
 
4
- # Copyright (C) 2021 MongoDB Inc.
4
+ # Copyright (C) 2018-2020 MongoDB Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -18,11 +18,11 @@
18
18
  module Mongo
19
19
  module Operation
20
20
 
21
- # Shared behavior of implementing an operation differently based on
22
- # the server that will be executing the operation.
21
+ # Shared behavior of executing the operation as an OpMsg.
23
22
  #
24
23
  # @api private
25
- module PolymorphicOperation
24
+ module OpMsgExecutable
25
+ include PolymorphicLookup
26
26
 
27
27
  # Execute the operation.
28
28
  #
@@ -46,8 +46,13 @@ module Mongo
46
46
  #
47
47
  # @return [ Mongo::Operation::Result ] The operation result.
48
48
  def execute_with_connection(connection, context:, options: {})
49
- operation = final_operation(connection)
50
- operation.execute(connection, context: context, options: options)
49
+ final_operation.execute(connection, context: context, options: options)
50
+ end
51
+
52
+ private
53
+
54
+ def final_operation
55
+ polymorphic_class(self.class.name, :OpMsg).new(spec)
51
56
  end
52
57
  end
53
58
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/update/command'
19
18
  require 'mongo/operation/update/op_msg'
20
19
  require 'mongo/operation/update/result'
21
20
  require 'mongo/operation/update/bulk_result'
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/update_user/command'
19
18
  require 'mongo/operation/update_user/op_msg'
20
19
 
21
20
  module Mongo
@@ -28,7 +27,7 @@ module Mongo
28
27
  # @since 2.0.0
29
28
  class UpdateUser
30
29
  include Specifiable
31
- include OpMsgOrCommand
30
+ include OpMsgExecutable
32
31
  end
33
32
  end
34
33
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/users_info/command'
19
18
  require 'mongo/operation/users_info/op_msg'
20
19
  require 'mongo/operation/users_info/result'
21
20
 
@@ -29,7 +28,7 @@ module Mongo
29
28
  # @since 2.0.0
30
29
  class UsersInfo
31
30
  include Specifiable
32
- include OpMsgOrCommand
31
+ include OpMsgExecutable
33
32
  end
34
33
  end
35
34
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'mongo/operation/write_command/command'
19
18
  require 'mongo/operation/write_command/op_msg'
20
19
 
21
20
  module Mongo
@@ -26,7 +25,7 @@ module Mongo
26
25
  # @api private
27
26
  class WriteCommand
28
27
  include Specifiable
29
- include OpMsgOrCommand
28
+ include OpMsgExecutable
30
29
  end
31
30
  end
32
31
  end
@@ -9,7 +9,6 @@ require 'mongo/operation/shared/executable'
9
9
  require 'mongo/operation/shared/executable_no_validate'
10
10
  require 'mongo/operation/shared/executable_transaction_label'
11
11
  require 'mongo/operation/shared/polymorphic_lookup'
12
- require 'mongo/operation/shared/polymorphic_operation'
13
12
  require 'mongo/operation/shared/polymorphic_result'
14
13
  require 'mongo/operation/shared/read_preference_supported'
15
14
  require 'mongo/operation/shared/bypass_document_validation'
@@ -22,8 +21,7 @@ require 'mongo/operation/shared/idable'
22
21
  require 'mongo/operation/shared/specifiable'
23
22
  require 'mongo/operation/shared/validatable'
24
23
  require 'mongo/operation/shared/object_id_generator'
25
- require 'mongo/operation/shared/op_msg_or_command'
26
- require 'mongo/operation/shared/op_msg_or_find_command'
24
+ require 'mongo/operation/shared/op_msg_executable'
27
25
 
28
26
  require 'mongo/operation/op_msg_base'
29
27
  require 'mongo/operation/command'
@@ -39,9 +39,11 @@ module Mongo
39
39
  #
40
40
  # @param buffer [ String ] Buffer to receive the serialized vector
41
41
  # @param value [ Array<Symbol> ] Array of flags to encode
42
+ # @param [ true, false ] validating_keys Whether keys should be validated when serializing.
43
+ # This option is deprecated and will not be used. It will removed in version 3.0.
42
44
  #
43
45
  # @return [ String ] Buffer that received the serialized vector
44
- def serialize(buffer, value, validating_keys = BSON::Config.validating_keys?)
46
+ def serialize(buffer, value, validating_keys = nil)
45
47
  bits = 0
46
48
  value.each { |flag| bits |= (@masks[flag] || 0) }
47
49
  buffer.put_int32(bits)
@@ -38,32 +38,15 @@ module Mongo
38
38
  #
39
39
  # @param [ BSON::ByteBuffer ] buffer The encoded BSON buffer to append to.
40
40
  # @param [ true, false ] validating_keys Whether keys should be validated when serializing.
41
+ # This option is deprecated and will not be used. It will removed in version 3.0.
41
42
  #
42
43
  # @return [ BSON::ByteBuffer ] The buffer with the encoded object.
43
- def to_bson(buffer = BSON::ByteBuffer.new, validating_keys = BSON::Config.validating_keys?)
44
+ def to_bson(buffer = BSON::ByteBuffer.new, validating_keys = nil)
44
45
  if !@bytes
45
- @bytes = @hash.to_bson(BSON::ByteBuffer.new, validating_keys).to_s
46
- elsif needs_validation?(validating_keys)
47
- @validated = true
48
- return @hash.to_bson(buffer, validating_keys)
46
+ @bytes = @hash.to_bson(BSON::ByteBuffer.new).to_s
49
47
  end
50
- @validated ||= validating_keys
51
48
  buffer.put_bytes(@bytes)
52
49
  end
53
-
54
- private
55
-
56
- # Checks the current value for validating keys, and whether or not this
57
- # bson has been validated in the past, and decides if we need to recalculate
58
- # the to_bson to check the validations.
59
- #
60
- # @param [ true, false ] validating_keys Whether keys should be validated when serializing.
61
- #
62
- # @return [ true, false ] Whether or not the bson needs to be recalculated
63
- # with validation.
64
- def needs_validation?(validating_keys)
65
- !@validated && validating_keys
66
- end
67
50
  end
68
51
  end
69
52
  end
@@ -354,16 +354,16 @@ module Mongo
354
354
  if field[:multi]
355
355
  value.each do |item|
356
356
  if field[:type].respond_to?(:size_limited?)
357
- field[:type].serialize(buffer, item, max_bson_size, validating_keys?)
357
+ field[:type].serialize(buffer, item, max_bson_size)
358
358
  else
359
- field[:type].serialize(buffer, item, validating_keys?)
359
+ field[:type].serialize(buffer, item)
360
360
  end
361
361
  end
362
362
  else
363
363
  if field[:type].respond_to?(:size_limited?)
364
- field[:type].serialize(buffer, value, max_bson_size, validating_keys?)
364
+ field[:type].serialize(buffer, value, max_bson_size)
365
365
  else
366
- field[:type].serialize(buffer, value, validating_keys?)
366
+ field[:type].serialize(buffer, value)
367
367
  end
368
368
  end
369
369
  end
@@ -456,10 +456,6 @@ module Mongo
456
456
  field[:type].deserialize(io, options)
457
457
  )
458
458
  end
459
-
460
- def validating_keys?
461
- @options[:validating_keys] if @options
462
- end
463
459
  end
464
460
  end
465
461
  end
@@ -58,6 +58,7 @@ module Mongo
58
58
  # @option options [ true, false ] validating_keys Whether keys should be
59
59
  # validated for being valid document keys (i.e. not begin with $ and
60
60
  # not contain dots).
61
+ # This option is deprecated and will not be used. It will removed in version 3.0.
61
62
  #
62
63
  # @api private
63
64
  #