Sha256: a1208e942140642e4edb18fe13243de42be350e7360444454605b3034d166b65

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

# Copyright (C) 2018-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module Mongo
  module Operation
    class Create

      # A MongoDB create collection operation sent as an op message.
      #
      # @api private
      #
      # @since 2.5.2
      class OpMsg < OpMsgBase
        include ExecutableTransactionLabel

        private

        def selector(connection)
          # Collation is always supported on 3.6+ servers that would use OP_MSG.
          spec[:selector].merge(
            collation: spec[:collation],
            encryptedFields: spec[:encrypted_fields],
          ).compact.tap do |sel|
            # This code MUST be removed as soon as server starts accepting
            # contention as int32.
            if sel[:encryptedFields] && sel[:encryptedFields].key?('fields')
              sel[:encryptedFields]['fields'] = sel[:encryptedFields]['fields'].map do |field|
                if field['queries'] && field['queries'].key?('contention')
                  field['queries']['contention'] = BSON::Int64.new(field['queries']['contention'])
                end
                field
              end
            end
            # End of code to be removed
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo-2.18.0.beta1 lib/mongo/operation/create/op_msg.rb