mongoid 7.2.5 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +1 -1
  4. data/Rakefile +16 -0
  5. data/lib/config/locales/en.yml +2 -2
  6. data/lib/mongoid/association/accessors.rb +1 -1
  7. data/lib/mongoid/association/constrainable.rb +1 -1
  8. data/lib/mongoid/association/depending.rb +4 -4
  9. data/lib/mongoid/association/embedded/batchable.rb +1 -1
  10. data/lib/mongoid/association/embedded/embedded_in.rb +1 -1
  11. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +11 -4
  12. data/lib/mongoid/association/nested/many.rb +1 -1
  13. data/lib/mongoid/association/nested/one.rb +4 -2
  14. data/lib/mongoid/association/proxy.rb +7 -2
  15. data/lib/mongoid/association/referenced/auto_save.rb +2 -2
  16. data/lib/mongoid/association/referenced/has_many/enumerable.rb +493 -495
  17. data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -3
  18. data/lib/mongoid/association/referenced/has_one/nested_builder.rb +2 -2
  19. data/lib/mongoid/attributes/projector.rb +120 -0
  20. data/lib/mongoid/attributes.rb +24 -13
  21. data/lib/mongoid/cacheable.rb +2 -2
  22. data/lib/mongoid/clients/factory.rb +22 -8
  23. data/lib/mongoid/clients.rb +1 -1
  24. data/lib/mongoid/config.rb +19 -2
  25. data/lib/mongoid/contextual/aggregable/mongo.rb +10 -8
  26. data/lib/mongoid/copyable.rb +1 -1
  27. data/lib/mongoid/criteria/findable.rb +1 -1
  28. data/lib/mongoid/criteria/queryable/expandable.rb +0 -24
  29. data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
  30. data/lib/mongoid/criteria/queryable/extensions.rb +0 -4
  31. data/lib/mongoid/criteria/queryable/mergeable.rb +46 -20
  32. data/lib/mongoid/criteria/queryable/selectable.rb +8 -8
  33. data/lib/mongoid/criteria.rb +5 -6
  34. data/lib/mongoid/document.rb +1 -15
  35. data/lib/mongoid/errors/delete_restriction.rb +8 -9
  36. data/lib/mongoid/errors/mongoid_error.rb +1 -1
  37. data/lib/mongoid/evolvable.rb +1 -1
  38. data/lib/mongoid/extensions/boolean.rb +1 -2
  39. data/lib/mongoid/extensions/false_class.rb +1 -1
  40. data/lib/mongoid/extensions/hash.rb +2 -2
  41. data/lib/mongoid/extensions/true_class.rb +1 -1
  42. data/lib/mongoid/fields.rb +43 -5
  43. data/lib/mongoid/inspectable.rb +1 -1
  44. data/lib/mongoid/interceptable.rb +1 -1
  45. data/lib/mongoid/matcher/bits.rb +41 -0
  46. data/lib/mongoid/matcher/bits_all_clear.rb +20 -0
  47. data/lib/mongoid/matcher/bits_all_set.rb +20 -0
  48. data/lib/mongoid/matcher/bits_any_clear.rb +20 -0
  49. data/lib/mongoid/matcher/bits_any_set.rb +20 -0
  50. data/lib/mongoid/matcher/expression.rb +4 -0
  51. data/lib/mongoid/matcher/field_operator.rb +6 -0
  52. data/lib/mongoid/matcher/mod.rb +17 -0
  53. data/lib/mongoid/matcher/type.rb +99 -0
  54. data/lib/mongoid/matcher.rb +7 -0
  55. data/lib/mongoid/persistable/deletable.rb +1 -2
  56. data/lib/mongoid/persistable/destroyable.rb +8 -2
  57. data/lib/mongoid/persistable/updatable.rb +27 -2
  58. data/lib/mongoid/query_cache.rb +35 -29
  59. data/lib/mongoid/selectable.rb +5 -7
  60. data/lib/mongoid/shardable.rb +21 -5
  61. data/lib/mongoid/touchable.rb +23 -4
  62. data/lib/mongoid/validatable/associated.rb +1 -1
  63. data/lib/mongoid/validatable/presence.rb +3 -3
  64. data/lib/mongoid/validatable/uniqueness.rb +1 -1
  65. data/lib/mongoid/version.rb +1 -1
  66. data/lib/mongoid.rb +0 -1
  67. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +1 -1
  68. data/spec/integration/app_spec.rb +0 -3
  69. data/spec/integration/associations/embeds_many_spec.rb +44 -0
  70. data/spec/integration/associations/has_one_spec.rb +48 -0
  71. data/spec/integration/criteria/date_field_spec.rb +1 -1
  72. data/spec/integration/document_spec.rb +9 -0
  73. data/spec/integration/matcher_operator_data/bits_all_clear.yml +159 -0
  74. data/spec/integration/matcher_operator_data/bits_all_set.yml +159 -0
  75. data/spec/integration/matcher_operator_data/bits_any_clear.yml +159 -0
  76. data/spec/integration/matcher_operator_data/bits_any_set.yml +159 -0
  77. data/spec/integration/matcher_operator_data/comment.yml +22 -0
  78. data/spec/integration/matcher_operator_data/in.yml +16 -0
  79. data/spec/integration/matcher_operator_data/mod.yml +55 -0
  80. data/spec/integration/matcher_operator_data/type.yml +70 -0
  81. data/spec/integration/matcher_operator_data/type_array.yml +16 -0
  82. data/spec/integration/matcher_operator_data/type_binary.yml +18 -0
  83. data/spec/integration/matcher_operator_data/type_boolean.yml +39 -0
  84. data/spec/integration/matcher_operator_data/type_code.yml +26 -0
  85. data/spec/integration/matcher_operator_data/type_code_with_scope.yml +26 -0
  86. data/spec/integration/matcher_operator_data/type_date.yml +39 -0
  87. data/spec/integration/matcher_operator_data/type_db_pointer.yml +19 -0
  88. data/spec/integration/matcher_operator_data/type_decimal.yml +40 -0
  89. data/spec/integration/matcher_operator_data/type_double.yml +15 -0
  90. data/spec/integration/matcher_operator_data/type_int32.yml +33 -0
  91. data/spec/integration/matcher_operator_data/type_int64.yml +33 -0
  92. data/spec/integration/matcher_operator_data/type_max_key.yml +17 -0
  93. data/spec/integration/matcher_operator_data/type_min_key.yml +17 -0
  94. data/spec/integration/matcher_operator_data/type_null.yml +23 -0
  95. data/spec/integration/matcher_operator_data/type_object.yml +23 -0
  96. data/spec/integration/matcher_operator_data/type_object_id.yml +25 -0
  97. data/spec/integration/matcher_operator_data/type_regex.yml +44 -0
  98. data/spec/integration/matcher_operator_data/type_string.yml +15 -0
  99. data/spec/integration/matcher_operator_data/type_symbol.yml +32 -0
  100. data/spec/integration/matcher_operator_data/type_timestamp.yml +25 -0
  101. data/spec/integration/matcher_operator_data/type_undefined.yml +17 -0
  102. data/spec/lite_spec_helper.rb +2 -0
  103. data/spec/mongoid/association/depending_spec.rb +391 -352
  104. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +4 -17
  105. data/spec/mongoid/association/nested/one_spec.rb +18 -14
  106. data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +25 -25
  107. data/spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb +1 -1
  108. data/spec/mongoid/association/referenced/has_many/binding_spec.rb +1 -1
  109. data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +1 -1
  110. data/spec/mongoid/association/referenced/has_one_models.rb +8 -0
  111. data/spec/mongoid/atomic/paths_spec.rb +64 -12
  112. data/spec/mongoid/attributes/projector_data/embedded.yml +105 -0
  113. data/spec/mongoid/attributes/projector_data/fields.yml +93 -0
  114. data/spec/mongoid/attributes/projector_spec.rb +41 -0
  115. data/spec/mongoid/attributes_spec.rb +98 -6
  116. data/spec/mongoid/clients/factory_spec.rb +48 -0
  117. data/spec/mongoid/clients/options_spec.rb +0 -2
  118. data/spec/mongoid/config_spec.rb +32 -0
  119. data/spec/mongoid/contextual/mongo_spec.rb +2 -2
  120. data/spec/mongoid/criteria/modifiable_spec.rb +1 -1
  121. data/spec/mongoid/criteria/queryable/expandable_spec.rb +0 -73
  122. data/spec/mongoid/criteria/queryable/extensions/boolean_spec.rb +1 -1
  123. data/spec/mongoid/criteria/queryable/mergeable_spec.rb +105 -7
  124. data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +229 -24
  125. data/spec/mongoid/criteria/queryable/selectable_shared_examples.rb +39 -0
  126. data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -565
  127. data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +590 -0
  128. data/spec/mongoid/criteria_projection_spec.rb +411 -0
  129. data/spec/mongoid/criteria_spec.rb +0 -279
  130. data/spec/mongoid/document_query_spec.rb +0 -51
  131. data/spec/mongoid/document_spec.rb +13 -13
  132. data/spec/mongoid/errors/delete_restriction_spec.rb +1 -1
  133. data/spec/mongoid/errors/mongoid_error_spec.rb +8 -20
  134. data/spec/mongoid/extensions/false_class_spec.rb +1 -1
  135. data/spec/mongoid/extensions/string_spec.rb +5 -5
  136. data/spec/mongoid/extensions/true_class_spec.rb +1 -1
  137. data/spec/mongoid/fields/localized_spec.rb +4 -4
  138. data/spec/mongoid/fields_spec.rb +4 -4
  139. data/spec/mongoid/inspectable_spec.rb +12 -4
  140. data/spec/mongoid/persistable/deletable_spec.rb +175 -1
  141. data/spec/mongoid/persistable/destroyable_spec.rb +191 -3
  142. data/spec/mongoid/persistable/savable_spec.rb +3 -5
  143. data/spec/mongoid/persistable/upsertable_spec.rb +1 -1
  144. data/spec/mongoid/persistable_spec.rb +2 -2
  145. data/spec/mongoid/query_cache_middleware_spec.rb +8 -0
  146. data/spec/mongoid/reloadable_spec.rb +18 -1
  147. data/spec/mongoid/shardable_spec.rb +44 -0
  148. data/spec/mongoid/touchable_spec.rb +104 -16
  149. data/spec/mongoid/touchable_spec_models.rb +52 -0
  150. data/spec/mongoid/validatable_spec.rb +1 -1
  151. data/spec/shared/lib/mrss/cluster_config.rb +3 -8
  152. data/spec/shared/lib/mrss/constraints.rb +6 -20
  153. data/spec/shared/lib/mrss/docker_runner.rb +1 -7
  154. data/spec/shared/lib/mrss/spec_organizer.rb +1 -18
  155. data/spec/shared/share/Dockerfile.erb +30 -121
  156. data/spec/shared/shlib/server.sh +4 -31
  157. data/spec/shared/shlib/set_env.sh +1 -4
  158. data/spec/spec_helper.rb +7 -3
  159. data/spec/support/client_registry.rb +9 -0
  160. data/spec/support/models/address.rb +0 -4
  161. data/spec/support/models/bolt.rb +8 -0
  162. data/spec/support/models/hole.rb +13 -0
  163. data/spec/support/models/mop.rb +0 -1
  164. data/spec/support/models/nut.rb +8 -0
  165. data/spec/support/models/person.rb +6 -9
  166. data/spec/support/models/sealer.rb +8 -0
  167. data/spec/support/models/shirt.rb +12 -0
  168. data/spec/support/models/spacer.rb +8 -0
  169. data/spec/support/models/threadlocker.rb +8 -0
  170. data/spec/support/models/washer.rb +8 -0
  171. data.tar.gz.sig +0 -0
  172. metadata +616 -544
  173. metadata.gz.sig +0 -0
  174. data/spec/shared/bin/s3-copy +0 -45
  175. data/spec/shared/bin/s3-upload +0 -69
  176. data/spec/shared/share/haproxy-1.conf +0 -16
  177. data/spec/shared/share/haproxy-2.conf +0 -17
  178. data/spec/support/cluster_config.rb +0 -158
@@ -52,15 +52,31 @@ module Mongoid
52
52
  self.class.shard_key_fields
53
53
  end
54
54
 
55
- # Get the document selector with the defined shard keys.
56
- #
57
- # @example Get the selector for the shard keys.
58
- # person.shard_key_selector
55
+ # Returns the selector that would match the current version of this
56
+ # document.
59
57
  #
60
58
  # @return [ Hash ] The shard key selector.
61
59
  #
62
- # @since 2.0.0
60
+ # @api private
63
61
  def shard_key_selector
62
+ selector = {}
63
+ shard_key_fields.each do |field|
64
+ selector[field.to_s] = send(field)
65
+ end
66
+ selector
67
+ end
68
+
69
+ # Returns the selector that would match the existing version of this
70
+ # document in the database.
71
+ #
72
+ # If the document is not persisted, this method uses the current values
73
+ # of the shard key fields. If the document is persisted, this method
74
+ # uses the values retrieved from the database.
75
+ #
76
+ # @return [ Hash ] The shard key selector.
77
+ #
78
+ # @api private
79
+ def shard_key_selector_in_db
64
80
  selector = {}
65
81
  shard_key_fields.each do |field|
66
82
  selector[field.to_s] = new_record? ? send(field) : attribute_was(field)
@@ -30,11 +30,30 @@ module Mongoid
30
30
  write_attribute(:updated_at, current) if respond_to?("updated_at=")
31
31
  write_attribute(field, current) if field
32
32
 
33
- touches = touch_atomic_updates(field)
34
- unless touches["$set"].blank?
35
- selector = atomic_selector
36
- _root.collection.find(selector).update_one(positionally(selector, touches), session: _session)
33
+ # If the document being touched is embedded, touch its parents
34
+ # all the way through the composition hierarchy to the root object,
35
+ # because when an embedded document is changed the write is actually
36
+ # performed by the composition root. See MONGOID-3468.
37
+ if _parent
38
+ # This will persist updated_at on this document as well as parents.
39
+ # TODO support passing the field name to the parent's touch method;
40
+ # I believe it should be read out of
41
+ # _association.inverse_association.options but inverse_association
42
+ # seems to not always/ever be set here. See MONGOID-5014.
43
+ _parent.touch
44
+ else
45
+ # If the current document is not embedded, it is composition root
46
+ # and we need to persist the write here.
47
+ touches = touch_atomic_updates(field)
48
+ unless touches["$set"].blank?
49
+ selector = atomic_selector
50
+ _root.collection.find(selector).update_one(positionally(selector, touches), session: _session)
51
+ end
37
52
  end
53
+
54
+ # Callbacks are invoked on the composition root first and on the
55
+ # leaf-most embedded document last.
56
+ # TODO add tests, see MONGOID-5015.
38
57
  run_callbacks(:touch)
39
58
  true
40
59
  end
@@ -43,7 +43,7 @@ module Mongoid
43
43
  ensure
44
44
  document.exit_validate
45
45
  end
46
- document.errors.add(attribute, :invalid, **options) unless valid
46
+ document.errors.add(attribute, :invalid, options) unless valid
47
47
  end
48
48
  end
49
49
  end
@@ -34,15 +34,15 @@ module Mongoid
34
34
  document.errors.add(
35
35
  attribute,
36
36
  :blank_in_locale,
37
- **options.merge(location: _locale)
37
+ options.merge(location: _locale)
38
38
  ) if not_present?(_value)
39
39
  end
40
40
  elsif document.relations.has_key?(attribute.to_s)
41
41
  if relation_or_fk_missing?(document, attribute, value)
42
- document.errors.add(attribute, :blank, **options)
42
+ document.errors.add(attribute, :blank, options)
43
43
  end
44
44
  else
45
- document.errors.add(attribute, :blank, **options) if not_present?(value)
45
+ document.errors.add(attribute, :blank, options) if not_present?(value)
46
46
  end
47
47
  end
48
48
 
@@ -68,7 +68,7 @@ module Mongoid
68
68
  # @since 2.4.10
69
69
  def add_error(document, attribute, value)
70
70
  document.errors.add(
71
- attribute, :taken, **options.except(:case_sensitive, :scope).merge(value: value)
71
+ attribute, :taken, options.except(:case_sensitive, :scope).merge(value: value)
72
72
  )
73
73
  end
74
74
 
@@ -2,5 +2,5 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  module Mongoid
5
- VERSION = "7.2.5"
5
+ VERSION = "7.3.0"
6
6
  end
data/lib/mongoid.rb CHANGED
@@ -6,7 +6,6 @@ require "support/ruby_version"
6
6
  require "forwardable"
7
7
  require "time"
8
8
  require "set"
9
- require "ruby2_keywords"
10
9
 
11
10
  require "active_support"
12
11
  require "active_support/core_ext"
@@ -57,7 +57,7 @@ development:
57
57
  # connect: :direct
58
58
 
59
59
  # Changes the default time in seconds the server monitors refresh their status
60
- # via hello commands. (default: 10)
60
+ # via ismaster commands. (default: 10)
61
61
  # heartbeat_frequency: 10
62
62
 
63
63
  # The time in seconds for selecting servers for a near read preference. (default: 0.015)
@@ -297,9 +297,6 @@ describe 'Mongoid application tests' do
297
297
  end
298
298
 
299
299
  def remove_bundler_req
300
- return unless File.file?('Gemfile.lock')
301
- # TODO: Remove this method completely when we get rid of .lock files in
302
- # mongoid-demo apps.
303
300
  lock_lines = IO.readlines('Gemfile.lock')
304
301
  # Get rid of the bundled with line so that whatever bundler is installed
305
302
  # on the system is usable with the application.
@@ -21,4 +21,48 @@ describe 'embeds_many associations' do
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ context 'clearing association when parent is not saved' do
26
+ let!(:parent) { Canvas.create!(shapes: [Shape.new]) }
27
+
28
+ let(:unsaved_parent) { Canvas.new(id: parent.id, shapes: [Shape.new]) }
29
+
30
+ context "using #clear" do
31
+ it 'deletes the target from the database' do
32
+ unsaved_parent.shapes.clear
33
+
34
+ unsaved_parent.shapes.should be_empty
35
+
36
+ unsaved_parent.new_record?.should be true
37
+ parent.reload
38
+ parent.shapes.should be_empty
39
+ end
40
+ end
41
+
42
+ shared_examples 'does not delete the target from the database' do
43
+ it 'does not delete the target from the database' do
44
+ unsaved_parent.shapes.should be_empty
45
+
46
+ unsaved_parent.new_record?.should be true
47
+ parent.reload
48
+ parent.shapes.length.should == 1
49
+ end
50
+ end
51
+
52
+ context "using #delete_all" do
53
+ before do
54
+ unsaved_parent.shapes.delete_all
55
+ end
56
+
57
+ include_examples 'does not delete the target from the database'
58
+ end
59
+
60
+ context "using #destroy_all" do
61
+ before do
62
+ unsaved_parent.shapes.destroy_all
63
+ end
64
+
65
+ include_examples 'does not delete the target from the database'
66
+ end
67
+ end
24
68
  end
@@ -67,6 +67,54 @@ describe 'has_one associations' do
67
67
  end
68
68
  end
69
69
 
70
+ context 'when calling methods on target' do
71
+ let(:parent) do
72
+ HomCollege.create!.tap do |college|
73
+ HomAccreditation.create!(college: college)
74
+ end
75
+ end
76
+
77
+ shared_examples 'delegates to the field' do |reloaded: false|
78
+ context 'non-conflicting field name' do
79
+ it 'delegates to the field' do
80
+ parent.accreditation.price.should == 42
81
+ end
82
+
83
+ context 'using send' do
84
+ it 'delegates to the field' do
85
+ parent.accreditation.send(:price).should == 42
86
+ end
87
+ end
88
+ end
89
+
90
+ context 'field name that conflicts with Kernel' do
91
+ it 'delegates to the field' do
92
+ parent.accreditation.format.should == 'fmt'
93
+ end
94
+
95
+ context 'using send' do
96
+ it 'delegates to the field' do
97
+ if reloaded
98
+ pending 'MONGOID-4018'
99
+ end
100
+
101
+ parent.accreditation.send(:format).should == 'fmt'
102
+ end
103
+ end
104
+ end
105
+ end
106
+
107
+ include_examples 'delegates to the field'
108
+
109
+ context 'after reloading parent' do
110
+ before do
111
+ parent.reload
112
+ end
113
+
114
+ include_examples 'delegates to the field', reloaded: true
115
+ end
116
+ end
117
+
70
118
  context 'when child does not have parent association' do
71
119
  context 'Child.new' do
72
120
  it 'creates a child instance' do
@@ -12,7 +12,7 @@ describe 'Queries on Date fields' do
12
12
 
13
13
  shared_examples 'converts to beginning of day in UTC' do
14
14
  it 'converts to beginning of day in UTC' do
15
- selector['founded'].should == arg.dup.beginning_of_day.utc.beginning_of_day
15
+ selector['founded'].should == Time.utc(arg.year, arg.month, arg.day)
16
16
  end
17
17
  end
18
18
 
@@ -20,6 +20,15 @@ describe Mongoid::Document do
20
20
  end
21
21
  end
22
22
 
23
+ context 'when id is unaliased' do
24
+ it 'persists separate id and _id values' do
25
+ shirt = Shirt.create!(id: 'hello', _id: 'foo')
26
+ shirt = Shirt.find(shirt._id)
27
+ shirt.id.should == 'hello'
28
+ shirt._id.should == 'foo'
29
+ end
30
+ end
31
+
23
32
  describe '#reload' do
24
33
  context 'when changing shard key value' do
25
34
  require_topology :sharded
@@ -0,0 +1,159 @@
1
+ - name: existing field - matches with int
2
+ document:
3
+ a: 20
4
+ binaryValueofA: "00010100"
5
+ query:
6
+ a:
7
+ $bitsAllClear: 35
8
+ matches: true
9
+ min_server_version: 3.2
10
+
11
+ - name: existing field - does not match with int
12
+ document:
13
+ a: 20
14
+ binaryValueofA: "00010100"
15
+ query:
16
+ a:
17
+ $bitsAllClear: 24
18
+ matches: false
19
+ min_server_version: 3.2
20
+
21
+ - name: existing field - matches with binData
22
+ document:
23
+ a: 20
24
+ binaryValueofA: "00010100"
25
+ query:
26
+ a:
27
+ $bitsAllClear: !ruby/object:BSON::Binary
28
+ data: !binary |-
29
+ IW==
30
+ type: :generic
31
+ matches: true
32
+ min_server_version: 3.2
33
+
34
+ - name: existing field - does not match with binData
35
+ document:
36
+ a: 21
37
+ binaryValueofA: "00010101"
38
+ query:
39
+ a:
40
+ $bitsAllClear: !ruby/object:BSON::Binary
41
+ data: !binary |-
42
+ IW==
43
+ type: :generic
44
+ matches: false
45
+ min_server_version: 3.2
46
+
47
+ - name: existing binData field matches
48
+ document:
49
+ a: !ruby/object:BSON::Binary
50
+ data: !binary |-
51
+ IW==
52
+ type: :generic
53
+ query:
54
+ a:
55
+ $bitsAllClear: 20
56
+ matches: true
57
+ min_server_version: 3.2
58
+
59
+ - name: existing binData field does not match
60
+ document:
61
+ a: !ruby/object:BSON::Binary
62
+ data: !binary |-
63
+ IW==
64
+ type: :generic
65
+ query:
66
+ a:
67
+ $bitsAllClear: 15
68
+ matches: false
69
+ min_server_version: 3.2
70
+
71
+ - name: existing field - matches with array
72
+ document:
73
+ a: 20
74
+ binaryValueofA: "00010100"
75
+ query:
76
+ a:
77
+ $bitsAllClear: [0, 3]
78
+ matches: true
79
+ min_server_version: 3.2
80
+
81
+ - name: existing field - does not match with array
82
+ document:
83
+ a: 20
84
+ binaryValueofA: "00010100"
85
+ query:
86
+ a:
87
+ $bitsAllClear: [0, 2]
88
+ matches: false
89
+ min_server_version: 3.2
90
+
91
+ - name: float condition representable as an integer
92
+ document:
93
+ a: 20
94
+ binaryValueofA: "00010100"
95
+ query:
96
+ a:
97
+ $bitsAllClear: 35.0
98
+ matches: true
99
+ min_server_version: 3.2
100
+
101
+ - name: float condition not representable as an integer
102
+ document:
103
+ a: 20
104
+ binaryValueofA: "00010100"
105
+ query:
106
+ a:
107
+ $bitsAllClear: 35.1
108
+ error: true
109
+ min_server_version: 3.2
110
+
111
+ - name: string condition
112
+ document:
113
+ a: 54
114
+ binaryValueofA: "00110110"
115
+ query:
116
+ a:
117
+ $bitsAllClear: hello
118
+ error: true
119
+ min_server_version: 3.2
120
+
121
+ - name: empty array condition
122
+ document:
123
+ a: 20
124
+ binaryValueofA: "00010100"
125
+ query:
126
+ a:
127
+ $bitsAllClear: []
128
+ matches: true
129
+ min_server_version: 3.2
130
+
131
+ - name: integer 0 condition
132
+ document:
133
+ a: 20
134
+ binaryValueofA: "00010100"
135
+ query:
136
+ a:
137
+ $bitsAllClear: 0
138
+ matches: true
139
+ min_server_version: 3.2
140
+
141
+ - name: negative integer condition
142
+ document:
143
+ a: 54
144
+ binaryValueofA: "00110110"
145
+ query:
146
+ a:
147
+ $bitsAllClear: -1
148
+ error: true
149
+ min_server_version: 3.2
150
+
151
+ - name: negative float condition
152
+ document:
153
+ a: 54
154
+ binaryValueofA: "00110110"
155
+ query:
156
+ a:
157
+ $bitsAllClear: -1.0
158
+ error: true
159
+ min_server_version: 3.2
@@ -0,0 +1,159 @@
1
+ - name: existing field - matches with int
2
+ document:
3
+ a: 54
4
+ binaryValueofA: "00110110"
5
+ query:
6
+ a:
7
+ $bitsAllSet: 50
8
+ matches: true
9
+ min_server_version: 3.2
10
+
11
+ - name: existing field - does not match with int
12
+ document:
13
+ a: 52
14
+ binaryValueofA: "00110100"
15
+ query:
16
+ a:
17
+ $bitsAllSet: 50
18
+ matches: false
19
+ min_server_version: 3.2
20
+
21
+ - name: existing field - matches with binData
22
+ document:
23
+ a: 54
24
+ binaryValueofA: "00110110"
25
+ query:
26
+ a:
27
+ $bitsAllSet: !ruby/object:BSON::Binary
28
+ data: !binary |-
29
+ Ng==
30
+ type: :generic
31
+ matches: true
32
+ min_server_version: 3.2
33
+
34
+ - name: existing field - does not match with binData
35
+ document:
36
+ a: 21
37
+ binaryValueofA: "00010101"
38
+ query:
39
+ a:
40
+ $bitsAllSet: !ruby/object:BSON::Binary
41
+ data: !binary |-
42
+ MC==
43
+ type: :generic
44
+ matches: false
45
+ min_server_version: 3.2
46
+
47
+ - name: existing binData field matches
48
+ document:
49
+ a: !ruby/object:BSON::Binary
50
+ data: !binary |-
51
+ Ng==
52
+ type: :generic
53
+ query:
54
+ a:
55
+ $bitsAllSet: 48
56
+ matches: true
57
+ min_server_version: 3.2
58
+
59
+ - name: existing binData field does not match
60
+ document:
61
+ a: !ruby/object:BSON::Binary
62
+ data: !binary |-
63
+ MC==
64
+ type: :generic
65
+ query:
66
+ a:
67
+ $bitsAllSet: 54
68
+ matches: false
69
+ min_server_version: 3.2
70
+
71
+ - name: existing field - matches with array
72
+ document:
73
+ a: 20
74
+ binaryValueofA: "00010100"
75
+ query:
76
+ a:
77
+ $bitsAllSet: [2, 4]
78
+ matches: true
79
+ min_server_version: 3.2
80
+
81
+ - name: existing field - does not match with array
82
+ document:
83
+ a: 20
84
+ binaryValueofA: "00010100"
85
+ query:
86
+ a:
87
+ $bitsAllSet: [0, 3]
88
+ matches: false
89
+ min_server_version: 3.2
90
+
91
+ - name: float condition representable as an integer
92
+ document:
93
+ a: 54
94
+ binaryValueofA: "00110110"
95
+ query:
96
+ a:
97
+ $bitsAllSet: 50.0
98
+ matches: true
99
+ min_server_version: 3.2
100
+
101
+ - name: float condition not representable as an integer
102
+ document:
103
+ a: 54
104
+ binaryValueofA: "00110110"
105
+ query:
106
+ a:
107
+ $bitsAllSet: 50.1
108
+ error: true
109
+ min_server_version: 3.2
110
+
111
+ - name: string condition
112
+ document:
113
+ a: 54
114
+ binaryValueofA: "00110110"
115
+ query:
116
+ a:
117
+ $bitsAllSet: hello
118
+ error: true
119
+ min_server_version: 3.2
120
+
121
+ - name: empty array condition
122
+ document:
123
+ a: 54
124
+ binaryValueofA: "00110110"
125
+ query:
126
+ a:
127
+ $bitsAllSet: []
128
+ matches: true
129
+ min_server_version: 3.2
130
+
131
+ - name: integer 0 condition
132
+ document:
133
+ a: 54
134
+ binaryValueofA: "00110110"
135
+ query:
136
+ a:
137
+ $bitsAllSet: 0
138
+ matches: true
139
+ min_server_version: 3.2
140
+
141
+ - name: negative integer condition
142
+ document:
143
+ a: 54
144
+ binaryValueofA: "00110110"
145
+ query:
146
+ a:
147
+ $bitsAllSet: -1
148
+ error: true
149
+ min_server_version: 3.2
150
+
151
+ - name: negative float condition
152
+ document:
153
+ a: 54
154
+ binaryValueofA: "00110110"
155
+ query:
156
+ a:
157
+ $bitsAllSet: -1.0
158
+ error: true
159
+ min_server_version: 3.2