Module: Mongo::Operation::Validatable Private

Included in:
Delete::OpMsg, Update::OpMsg, WriteCommand::OpMsg
Defined in:
lib/mongo/operation/shared/validatable.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#validate_array_filters(connection, selector_or_item) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

selector_or_item here is either:

  • The selector as used in a findAndModify command, or

  • One of the array elements in the updates array in an update command.

[View source]

58
59
60
61
62
63
64
# File 'lib/mongo/operation/shared/validatable.rb', line 58

def validate_array_filters(connection, selector_or_item)
  if selector_or_item.key?(:arrayFilters) &&
    !connection.features.array_filters_enabled?
  then
    raise Error::UnsupportedArrayFilters
  end
end

#validate_collation(connection, selector_or_item) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

selector_or_item here is either:

  • The selector as used in a findAndModify command, or

  • One of the array elements in the updates array in an update command.

[View source]

69
70
71
72
73
74
75
# File 'lib/mongo/operation/shared/validatable.rb', line 69

def validate_collation(connection, selector_or_item)
  if selector_or_item.key?(:collation) &&
    !connection.features.collation_enabled?
  then
    raise Error::UnsupportedCollation
  end
end

#validate_find_options(connection, selector) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

[View source]

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mongo/operation/shared/validatable.rb', line 24

def validate_find_options(connection, selector)
  if selector.key?(:hint) &&
    !connection.features.find_and_modify_option_validation_enabled?
  then
    raise Error::UnsupportedOption.hint_error
  end

  if selector.key?(:arrayFilters) &&
    !connection.features.array_filters_enabled?
  then
    raise Error::UnsupportedArrayFilters
  end

  if selector.key?(:collation) &&
    !connection.features.collation_enabled?
  then
    raise Error::UnsupportedCollation
  end
end

#validate_hint_on_update(connection, selector_or_item) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

selector_or_item here is either:

  • The selector as used in a findAndModify command, or

  • One of the array elements in the updates array in an update command.

[View source]

47
48
49
50
51
52
53
# File 'lib/mongo/operation/shared/validatable.rb', line 47

def validate_hint_on_update(connection, selector_or_item)
  if selector_or_item.key?(:hint) &&
    !connection.features.update_delete_option_validation_enabled?
  then
    raise Error::UnsupportedOption.hint_error
  end
end

#validate_updates(connection, updates) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

[View source]

77
78
79
80
81
82
83
84
# File 'lib/mongo/operation/shared/validatable.rb', line 77

def validate_updates(connection, updates)
  updates.each do |update|
    validate_array_filters(connection, update)
    validate_collation(connection, update)
    validate_hint_on_update(connection, update)
  end
  updates
end