mongoid 7.6.1 → 7.6.2

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/config/locales/en.yml +26 -0
  3. data/lib/mongoid/association/depending.rb +8 -4
  4. data/lib/mongoid/association/nested/many.rb +38 -3
  5. data/lib/mongoid/association/nested/nested_buildable.rb +14 -0
  6. data/lib/mongoid/association/referenced/has_many/proxy.rb +102 -3
  7. data/lib/mongoid/config.rb +62 -0
  8. data/lib/mongoid/contextual/aggregable/memory.rb +8 -2
  9. data/lib/mongoid/contextual/memory.rb +19 -8
  10. data/lib/mongoid/criteria/queryable/mergeable.rb +12 -0
  11. data/lib/mongoid/criteria/queryable/selectable.rb +109 -0
  12. data/lib/mongoid/errors/in_memory_regexp_timeout.rb +26 -0
  13. data/lib/mongoid/errors.rb +1 -0
  14. data/lib/mongoid/field_readable.rb +70 -0
  15. data/lib/mongoid/matchable.rb +6 -1
  16. data/lib/mongoid/matcher/eq_impl_with_regexp.rb +3 -5
  17. data/lib/mongoid/matcher/regex.rb +8 -9
  18. data/lib/mongoid/matcher/regexp_budget.rb +389 -0
  19. data/lib/mongoid/matcher.rb +1 -0
  20. data/lib/mongoid/threaded.rb +3 -0
  21. data/lib/mongoid/version.rb +1 -1
  22. data/lib/mongoid/warnings.rb +1 -0
  23. data/spec/integration/app_spec.rb +8 -0
  24. data/spec/integration/matcher_operator_data/regex.yml +21 -0
  25. data/spec/integration/matcher_regexp_timeout_spec.rb +215 -0
  26. data/spec/integration/query_operator_guard_spec.rb +89 -0
  27. data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +48 -0
  28. data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +145 -0
  29. data/spec/mongoid/attributes/nested_spec.rb +202 -8
  30. data/spec/mongoid/contextual/aggregable/memory_spec.rb +98 -0
  31. data/spec/mongoid/contextual/memory_spec.rb +196 -0
  32. data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +2 -0
  33. data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +200 -0
  34. data/spec/mongoid/criteria_spec.rb +2 -0
  35. data/spec/mongoid/matcher/regexp_budget_spec.rb +570 -0
  36. data/spec/shared/lib/mrss/cluster_config.rb +5 -40
  37. data/spec/shared/lib/mrss/constraints.rb +7 -46
  38. data/spec/shared/lib/mrss/docker_runner.rb +10 -21
  39. data/spec/shared/lib/mrss/eg_config_utils.rb +0 -31
  40. data/spec/shared/lib/mrss/release/candidate.rb +18 -12
  41. data/spec/shared/lib/mrss/server_version_registry.rb +1 -5
  42. data/spec/shared/share/Dockerfile.erb +6 -8
  43. data/spec/shared/shlib/server.sh +0 -50
  44. data/spec/shared/shlib/set_env.sh +4 -10
  45. metadata +11 -2
@@ -69,22 +69,15 @@ module Mrss
69
69
  before(:all) do
70
70
  case ClusterConfig.instance.topology
71
71
  when :single
72
- skip 'Transactions tests require a replica set (4.0+) or a sharded cluster (4.2+)'
73
- when :replica_set
74
- unless ClusterConfig.instance.server_version >= '4.0'
75
- skip 'Transactions tests in a replica set topology require server 4.0+'
76
- end
77
- when :sharded, :load_balanced
78
- unless ClusterConfig.instance.server_version >= '4.2'
79
- skip 'Transactions tests in a sharded cluster topology require server 4.2+'
80
- end
72
+ skip 'Transactions tests require a replica set or a sharded cluster'
73
+ when :replica_set, :sharded, :load_balanced
81
74
  else
82
- raise NotImplementedError
75
+ raise NotImplementedError, "Unknown topology #{ClusterConfig.instance.topology}"
83
76
  end
84
77
  end
85
78
  end
86
79
 
87
- # Fail command fail point was added to mongod in 4.0 and to mongos in 4.2.
80
+ # Fail command fail point requires transactions to be supported
88
81
  def require_fail_command
89
82
  require_transaction_support
90
83
  end
@@ -239,13 +232,11 @@ module Mrss
239
232
  end
240
233
 
241
234
  # Can the driver specify a write concern that won't be overridden?
242
- # (mongos 4.0+ overrides the write concern)
235
+ # (mongos overrides the write concern)
243
236
  def require_set_write_concern
244
237
  before(:all) do
245
- if %i(sharded load_balanced).include?(ClusterConfig.instance.topology) &&
246
- ClusterConfig.instance.short_server_version >= '4.0'
247
- then
248
- skip "mongos 4.0+ overrides write concern"
238
+ if %i(sharded load_balanced).include?(ClusterConfig.instance.topology)
239
+ skip "mongos overrides write concern"
249
240
  end
250
241
  end
251
242
  end
@@ -283,36 +274,6 @@ module Mrss
283
274
 
284
275
  alias :require_no_multi_shard :require_no_multi_mongos
285
276
 
286
- def require_wired_tiger
287
- before(:all) do
288
- # Storage detection fails for serverless instances. However, it is safe to
289
- # assume that a serverless instance uses WiredTiger Storage Engine.
290
- if !SpecConfig.instance.serverless? && ClusterConfig.instance.storage_engine != :wired_tiger
291
- skip 'Test requires WiredTiger storage engine'
292
- end
293
- end
294
- end
295
-
296
- def require_wired_tiger_on_36
297
- before(:all) do
298
- if ClusterConfig.instance.short_server_version >= '3.6'
299
- # Storage detection fails for serverless instances. However, it is safe to
300
- # assume that a serverless instance uses WiredTiger Storage Engine.
301
- if !SpecConfig.instance.serverless? && ClusterConfig.instance.storage_engine != :wired_tiger
302
- skip 'Test requires WiredTiger storage engine on 3.6+ servers'
303
- end
304
- end
305
- end
306
- end
307
-
308
- def require_mmapv1
309
- before(:all) do
310
- if SpecConfig.instance.serverless? || ClusterConfig.instance.storage_engine != :mmapv1
311
- skip 'Test requires MMAPv1 storage engine'
312
- end
313
- end
314
- end
315
-
316
277
  def require_enterprise
317
278
  before(:all) do
318
279
  unless ClusterConfig.instance.enterprise?
@@ -84,12 +84,12 @@ module Mrss
84
84
  arg.split('=', 2)
85
85
  end]
86
86
 
87
- @env['RVM_RUBY'] ||= 'ruby-2.7'
87
+ @env['RVM_RUBY'] ||= 'ruby-3.2'
88
88
  unless ruby =~ /^j?ruby-/
89
89
  raise "RVM_RUBY option is not in expected format: #{ruby}"
90
90
  end
91
91
 
92
- @env['MONGODB_VERSION'] ||= '4.4'
92
+ @env['MONGODB_VERSION'] ||= '8.0'
93
93
  end
94
94
 
95
95
  def create_dockerfile
@@ -178,12 +178,10 @@ module Mrss
178
178
 
179
179
  def distro
180
180
  @options[:distro] || if app_tests?
181
- 'ubuntu2004'
181
+ 'ubuntu2004'
182
182
  else
183
183
  case server_version
184
- when '3.6'
185
- 'debian9'
186
- when '4.0', '4.2'
184
+ when '4.2'
187
185
  'ubuntu1804'
188
186
  else
189
187
  'ubuntu2004'
@@ -192,18 +190,11 @@ module Mrss
192
190
  end
193
191
 
194
192
  BASE_IMAGES = {
195
- 'debian81' => 'debian:jessie',
196
- 'debian92' => 'debian:stretch',
197
- 'debian10' => 'debian:buster',
198
193
  'debian11' => 'debian:bullseye',
199
- 'ubuntu1404' => 'ubuntu:trusty',
200
- 'ubuntu1604' => 'ubuntu:xenial',
201
194
  'ubuntu1804' => 'ubuntu:bionic',
202
195
  'ubuntu2004' => 'ubuntu:focal',
203
196
  'ubuntu2204' => 'ubuntu:jammy',
204
- 'rhel62' => 'centos:6',
205
- 'rhel70' => 'centos:7',
206
- 'rhel80' => 'rockylinux:8',
197
+ 'ubuntu2404' => 'ubuntu:noble',
207
198
  }.freeze
208
199
 
209
200
  def base_image
@@ -256,14 +247,12 @@ module Mrss
256
247
 
257
248
  def libmongocrypt_path
258
249
  case distro
259
- when /ubuntu1604/
260
- "./ubuntu1604/nocrypto/lib64/libmongocrypt.so"
261
- when /ubuntu1804/
262
- "./ubuntu1804-64/nocrypto/lib64/libmongocrypt.so"
263
- when /debian92/
264
- "./debian92/nocrypto/lib64/libmongocrypt.so"
250
+ when /ubuntu..04/
251
+ "./#{distro}-64/nocrypto/lib64/libmongocrypt.so"
252
+ when /debian../
253
+ "./#{distro}/nocrypto/lib64/libmongocrypt.so"
265
254
  else
266
- raise "This script does not support running FLE tests on #{distro}. Use ubuntu1604, ubuntu1804 or debian92 instead"
255
+ raise "This script does not support running FLE tests on #{distro}."
267
256
  end
268
257
  end
269
258
 
@@ -5,37 +5,6 @@ require 'tilt'
5
5
 
6
6
  module Mrss
7
7
  module EgConfigUtils
8
-
9
- DEBIAN_FOR_RUBY = {
10
- 'ruby-2.3' => 'debian92',
11
- 'ruby-2.4' => 'debian92',
12
- 'ruby-2.5' => 'debian10',
13
- 'ruby-2.6' => 'debian10',
14
- 'ruby-2.7' => 'debian10',
15
- 'ruby-3.0' => 'debian10',
16
- }
17
-
18
- def standard_debian_rubies(rubies, key: nil, &block)
19
- rubies.flatten!
20
- text = block.call
21
- contents = YAML.load(text)
22
- out = rubies.map do |ruby|
23
- contents.merge(
24
- 'matrix_name' => "#{contents['matrix_name']} - #{ruby}",
25
- 'matrix_spec' => contents['matrix_spec'].merge(
26
- 'ruby' => ruby,
27
- key || 'os' => DEBIAN_FOR_RUBY.fetch(ruby),
28
- ),
29
- )
30
- end.to_yaml
31
- text =~ /\A\n?(\s+)/
32
- unless text
33
- raise "Couldn't figure out indentation level"
34
- end
35
- indent = ' ' * ($1.length - 2)
36
- "\n" + out.sub(/\A---.*\n/, indent).gsub("\n", "\n#{indent}")
37
- end
38
-
39
8
  def transform_config(template_path, context)
40
9
  Tilt.new(template_path, engine_class: Erubi::CaptureEndEngine).render(context)
41
10
  end
@@ -184,21 +184,27 @@ module Mrss
184
184
  def extract_summary(pr)
185
185
  summary = []
186
186
  accumulating = false
187
+ in_code_block = false
187
188
  level = nil
188
189
 
189
190
  pr['body'].lines.each do |line|
190
- # a header of any level titled "summary" will begin the summary
191
- if !accumulating && line =~ /^(\#+)\s+summary\s+$/i
192
- accumulating = true
193
- level = $1.length
194
-
195
- # a header of any level less than or equal to the summary header's
196
- # level will end the summary
197
- elsif accumulating && line =~ /^\#{1,#{level}}\s+/
198
- break
199
-
200
- # otherwise, the line is part of the summary
201
- elsif accumulating
191
+ if !accumulating
192
+ # a header of any level titled "summary" will begin the summary
193
+ if line =~ /^(\#+)\s+summary\s+$/i
194
+ accumulating = true
195
+ level = $1.length
196
+ end
197
+ else
198
+ # if we encounter a code block, we don't let its contents affect our
199
+ # header-level counting (i.e. we don't want to accidentally end the
200
+ # summary just because there's a comment in a code block)
201
+ in_code_block = !in_code_block if line =~ /^```/
202
+
203
+ # a header of any level less than or equal to the summary header's
204
+ # level will end the summary
205
+ break if !in_code_block && line =~ /^\#{1,#{level}}\s+/
206
+
207
+ # otherwise, the line is part of the summary
202
208
  summary << line
203
209
  end
204
210
  end
@@ -67,11 +67,7 @@ module Mrss
67
67
  private
68
68
 
69
69
  def uri_open(*args)
70
- if RUBY_VERSION < '2.5'
71
- open(*args)
72
- else
73
- URI.open(*args)
74
- end
70
+ URI.open(*args)
75
71
  end
76
72
 
77
73
  def detect_version(catalog)
@@ -163,14 +163,12 @@ ENV DOCKER=1
163
163
  RUN python3 -mpip install asn1crypto oscrypto flask --upgrade --ignore-installed
164
164
  <% end %>
165
165
 
166
- # FLE is tested against 4.0+ servers.
167
- <% if @env.fetch('MONGODB_VERSION') >= '4.0' %>
168
- # Requirements in drivers-evergreen-tools:
169
- # boto3~=1.19 cryptography~=3.4.8 pykmip~=0.10.0
170
- # cryptography does not install due to lacking setuptools_rust
171
- # (either that version or anything that isn't part of system packages)
172
- RUN python3 -mpip install boto3~=1.19 cryptography pykmip~=0.10.0 'sqlalchemy<2.0.0'
173
- <% end %>
166
+ # FLE requirements
167
+ # Requirements in drivers-evergreen-tools:
168
+ # boto3~=1.19 cryptography~=3.4.8 pykmip~=0.10.0
169
+ # cryptography does not install due to lacking setuptools_rust
170
+ # (either that version or anything that isn't part of system packages)
171
+ RUN python3 -mpip install boto3~=1.19 cryptography pykmip~=0.10.0 'sqlalchemy<2.0.0'
174
172
 
175
173
  <% unless ruby_head? || system_ruby? %>
176
174
 
@@ -250,10 +250,6 @@ calculate_server_args() {
250
250
  echo "Unknown topology: $TOPOLOGY" 1>&2
251
251
  exit 1
252
252
  fi
253
- if test -n "$MMAPV1"; then
254
- args="$args --storageEngine mmapv1 --smallfiles --noprealloc"
255
- uri_options="$uri_options&retryReads=false&retryWrites=false"
256
- fi
257
253
  if test "$AUTH" = auth; then
258
254
  args="$args --auth --username bob --password pwd123"
259
255
  elif test "$AUTH" = x509; then
@@ -316,7 +312,6 @@ calculate_server_args() {
316
312
  args="$args --bind_ip_all"
317
313
  fi
318
314
 
319
- # MongoDB servers pre-4.2 do not enable zlib compression by default
320
315
  if test "$COMPRESSOR" = snappy; then
321
316
  args="$args --networkMessageCompressors snappy"
322
317
  elif test "$COMPRESSOR" = zlib; then
@@ -367,51 +362,6 @@ launch_server() {
367
362
  local dbdir="$1"
368
363
  python3 -m mtools.mlaunch.mlaunch --dir "$dbdir" --binarypath "$BINDIR" $SERVER_ARGS
369
364
 
370
- if test "$TOPOLOGY" = sharded-cluster && test $MONGODB_VERSION = 3.6; then
371
- # On 3.6 server the sessions collection is not immediately available,
372
- # so we run the refreshLogicalSessionCacheNow command on the config server
373
- # and again on each mongos in order for the mongoses
374
- # to correctly report logicalSessionTimeoutMinutes.
375
- mongos_regex="\s*mongos\s+([0-9]+)\s+running\s+[0-9]+"
376
- config_server_regex="\s*config\sserver\s+([0-9]+)\s+running\s+[0-9]+"
377
- config_server=""
378
- mongoses=()
379
- if test "$AUTH" = auth
380
- then
381
- base_url="mongodb://bob:pwd123@localhost"
382
- else
383
- base_url="mongodb://localhost"
384
- fi
385
- if test "$SSL" = "ssl"
386
- then
387
- mongo_command="${BINDIR}/mongo --ssl --sslPEMKeyFile $server_cert_path --sslCAFile $server_ca_path"
388
- else
389
- mongo_command="${BINDIR}/mongo"
390
- fi
391
-
392
- while read -r line
393
- do
394
- if [[ $line =~ $config_server_regex ]]
395
- then
396
- port="${BASH_REMATCH[1]}"
397
- config_server="${base_url}:${port}"
398
- fi
399
- if [[ $line =~ $mongos_regex ]]
400
- then
401
- port="${BASH_REMATCH[1]}"
402
- mongoses+=("${base_url}:${port}")
403
- fi
404
- done < <(python2 -m mtools.mlaunch.mlaunch list --dir "$dbdir" --binarypath "$BINDIR")
405
-
406
- if [ -n "$config_server" ]; then
407
- ${mongo_command} "$config_server" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
408
- for mongos in ${mongoses[*]}
409
- do
410
- ${mongo_command} "$mongos" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
411
- done
412
- fi
413
- fi
414
-
415
365
  if test "$TOPOLOGY" = load-balanced; then
416
366
  if test -z "$haproxy_config"; then
417
367
  echo haproxy_config should have been set 1>&2
@@ -70,16 +70,10 @@ set_env_ruby() {
70
70
  set_env_java
71
71
 
72
72
  if [ "$RVM_RUBY" == "ruby-head" ]; then
73
- # When we use ruby-head, we do not install the Ruby toolchain.
74
- # But we still need Python 3.6+ to run mlaunch.
75
- # Since the ruby-head tests are run on ubuntu1604, we can use the
76
- # globally installed Python toolchain.
77
- #export PATH=/opt/python/3.7/bin:$PATH
78
-
79
- # 12.04, 14.04 and 16.04 are good
80
- curl --retry 3 -fL http://rubies.travis-ci.org/ubuntu/`lsb_release -rs`/x86_64/ruby-head.tar.bz2 |tar xfj -
81
- # TODO adjust gem path?
82
- export PATH=`pwd`/ruby-head/bin:`pwd`/ruby-head/lib/ruby/gems/2.6.0/bin:$PATH
73
+ # we could find a way to build ruby via rbenv here, perhaps?
74
+ echo 'ruby-head is not current supported'
75
+ exit 2
76
+
83
77
  ruby --version
84
78
  ruby --version |grep dev
85
79
  elif test "$SYSTEM_RUBY" = 1; then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.6.1
4
+ version: 7.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The MongoDB Ruby Team
@@ -257,6 +257,7 @@ files:
257
257
  - lib/mongoid/errors/eager_load.rb
258
258
  - lib/mongoid/errors/empty_config_file.rb
259
259
  - lib/mongoid/errors/in_memory_collation_not_supported.rb
260
+ - lib/mongoid/errors/in_memory_regexp_timeout.rb
260
261
  - lib/mongoid/errors/invalid_collection.rb
261
262
  - lib/mongoid/errors/invalid_config_file.rb
262
263
  - lib/mongoid/errors/invalid_config_option.rb
@@ -332,6 +333,7 @@ files:
332
333
  - lib/mongoid/extensions/time_with_zone.rb
333
334
  - lib/mongoid/extensions/true_class.rb
334
335
  - lib/mongoid/factory.rb
336
+ - lib/mongoid/field_readable.rb
335
337
  - lib/mongoid/fields.rb
336
338
  - lib/mongoid/fields/foreign_key.rb
337
339
  - lib/mongoid/fields/localized.rb
@@ -376,6 +378,7 @@ files:
376
378
  - lib/mongoid/matcher/not.rb
377
379
  - lib/mongoid/matcher/or.rb
378
380
  - lib/mongoid/matcher/regex.rb
381
+ - lib/mongoid/matcher/regexp_budget.rb
379
382
  - lib/mongoid/matcher/size.rb
380
383
  - lib/mongoid/matcher/type.rb
381
384
  - lib/mongoid/persistable.rb
@@ -528,7 +531,9 @@ files:
528
531
  - spec/integration/matcher_operator_data/type_timestamp.yml
529
532
  - spec/integration/matcher_operator_data/type_undefined.yml
530
533
  - spec/integration/matcher_operator_spec.rb
534
+ - spec/integration/matcher_regexp_timeout_spec.rb
531
535
  - spec/integration/matcher_spec.rb
536
+ - spec/integration/query_operator_guard_spec.rb
532
537
  - spec/integration/server_query_spec.rb
533
538
  - spec/integration/shardable_spec.rb
534
539
  - spec/integration/stringified_symbol_field_spec.rb
@@ -764,6 +769,7 @@ files:
764
769
  - spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
765
770
  - spec/mongoid/matcher/extract_attribute_data/traversal.yml
766
771
  - spec/mongoid/matcher/extract_attribute_spec.rb
772
+ - spec/mongoid/matcher/regexp_budget_spec.rb
767
773
  - spec/mongoid/persistable/creatable_spec.rb
768
774
  - spec/mongoid/persistable/deletable_spec.rb
769
775
  - spec/mongoid/persistable/destroyable_spec.rb
@@ -1130,7 +1136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1130
1136
  - !ruby/object:Gem::Version
1131
1137
  version: 1.3.6
1132
1138
  requirements: []
1133
- rubygems_version: 4.0.4
1139
+ rubygems_version: 4.0.21
1134
1140
  specification_version: 4
1135
1141
  summary: Elegant Persistence in Ruby for MongoDB.
1136
1142
  test_files:
@@ -1226,7 +1232,9 @@ test_files:
1226
1232
  - spec/integration/matcher_operator_data/type_timestamp.yml
1227
1233
  - spec/integration/matcher_operator_data/type_undefined.yml
1228
1234
  - spec/integration/matcher_operator_spec.rb
1235
+ - spec/integration/matcher_regexp_timeout_spec.rb
1229
1236
  - spec/integration/matcher_spec.rb
1237
+ - spec/integration/query_operator_guard_spec.rb
1230
1238
  - spec/integration/server_query_spec.rb
1231
1239
  - spec/integration/shardable_spec.rb
1232
1240
  - spec/integration/stringified_symbol_field_spec.rb
@@ -1462,6 +1470,7 @@ test_files:
1462
1470
  - spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
1463
1471
  - spec/mongoid/matcher/extract_attribute_data/traversal.yml
1464
1472
  - spec/mongoid/matcher/extract_attribute_spec.rb
1473
+ - spec/mongoid/matcher/regexp_budget_spec.rb
1465
1474
  - spec/mongoid/persistable/creatable_spec.rb
1466
1475
  - spec/mongoid/persistable/deletable_spec.rb
1467
1476
  - spec/mongoid/persistable/destroyable_spec.rb