module ActiveRecord::Encryption::ExtendedDeterministicQueries::EncryptedQuery

def additional_values_for(value, type)

def additional_values_for(value, type)
  type.previous_types.collect do |additional_type|
    AdditionalValue.new(value, additional_type)
  end
end

def process_arguments(owner, args, check_for_additional_values)

def process_arguments(owner, args, check_for_additional_values)
  owner = owner.model if owner.is_a?(Relation)
  return args if owner.deterministic_encrypted_attributes&.empty?
  if args.is_a?(Array) && (options = args.first).is_a?(Hash)
    options = options.transform_keys do |key|
      if key.is_a?(Array)
        key.map(&:to_s)
      else
        key.to_s
      end
    end
    args[0] = options
    owner.deterministic_encrypted_attributes&.each do |attribute_name|
      attribute_name = attribute_name.to_s
      type = owner.type_for_attribute(attribute_name)
      if !type.previous_types.empty? && value = options[attribute_name]
        options[attribute_name] = process_encrypted_query_argument(value, check_for_additional_values, type)
      end
    end
  end
  args
end

def process_encrypted_query_argument(value, check_for_additional_values, type)

def process_encrypted_query_argument(value, check_for_additional_values, type)
  return value if check_for_additional_values && value.is_a?(Array) && value.last.is_a?(AdditionalValue)
  case value
  when String, Array
    list = Array(value)
    list + list.flat_map do |each_value|
      if check_for_additional_values && each_value.is_a?(AdditionalValue)
        each_value
      else
        additional_values_for(each_value, type)
      end
    end
  else
    value
  end
end