mongoid 9.0.7 → 9.0.9
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.
- checksums.yaml +4 -4
- data/lib/mongoid/association/embedded/batchable.rb +11 -10
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +64 -29
- data/lib/mongoid/association/nested/many.rb +2 -0
- data/lib/mongoid/association/nested/one.rb +1 -1
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +0 -6
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +40 -0
- data/lib/mongoid/association/referenced/has_many/proxy.rb +17 -5
- data/lib/mongoid/attributes.rb +19 -1
- data/lib/mongoid/changeable.rb +10 -1
- data/lib/mongoid/clients/sessions.rb +3 -4
- data/lib/mongoid/config.rb +1 -1
- data/lib/mongoid/contextual/aggregable/mongo.rb +6 -1
- data/lib/mongoid/contextual/mongo.rb +8 -89
- data/lib/mongoid/pluckable.rb +132 -0
- data/lib/mongoid/railties/bson_object_id_serializer.rb +7 -0
- data/lib/mongoid/reloadable.rb +6 -0
- data/lib/mongoid/traversable.rb +0 -2
- data/lib/mongoid/version.rb +1 -1
- data/spec/integration/associations/embeds_many_spec.rb +110 -0
- data/spec/integration/associations/has_and_belongs_to_many_spec.rb +81 -0
- data/spec/integration/associations/has_many_spec.rb +56 -0
- data/spec/integration/associations/has_one_spec.rb +55 -3
- data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +394 -0
- data/spec/mongoid/association/referenced/has_many_models.rb +24 -0
- data/spec/mongoid/association/referenced/has_one_models.rb +10 -2
- data/spec/mongoid/attributes_spec.rb +13 -0
- data/spec/mongoid/clients/transactions_spec.rb +162 -1
- data/spec/mongoid/clients/transactions_spec_models.rb +93 -0
- data/spec/mongoid/contextual/aggregable/mongo_spec.rb +33 -0
- data/spec/mongoid/reloadable_spec.rb +24 -0
- data/spec/shared/CANDIDATE.md +28 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +32 -3
- data/spec/shared/shlib/server.sh +1 -1
- data/spec/support/models/company.rb +2 -0
- data/spec/support/models/passport.rb +1 -0
- data/spec/support/models/product.rb +2 -0
- data/spec/support/models/seo.rb +2 -0
- metadata +7 -4
|
@@ -33,6 +33,38 @@ module TransactionsSpecCountable
|
|
|
33
33
|
def after_rollback_counter=(new_counter)
|
|
34
34
|
@after_rollback_counter = new_counter
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
def after_save_commit_counter
|
|
38
|
+
@after_save_commit_counter ||= TransactionsSpecCounter.new
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def after_save_commit_counter=(new_counter)
|
|
42
|
+
@after_save_commit_counter = new_counter
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def after_create_commit_counter
|
|
46
|
+
@after_create_commit_counter ||= TransactionsSpecCounter.new
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def after_create_commit_counter=(new_counter)
|
|
50
|
+
@after_create_commit_counter = new_counter
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def after_update_commit_counter
|
|
54
|
+
@after_update_commit_counter ||= TransactionsSpecCounter.new
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def after_update_commit_counter=(new_counter)
|
|
58
|
+
@after_update_commit_counter = new_counter
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def after_destroy_commit_counter
|
|
62
|
+
@after_destroy_commit_counter ||= TransactionsSpecCounter.new
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def after_destroy_commit_counter=(new_counter)
|
|
66
|
+
@after_destroy_commit_counter = new_counter
|
|
67
|
+
end
|
|
36
68
|
end
|
|
37
69
|
|
|
38
70
|
class TransactionsSpecPerson
|
|
@@ -65,6 +97,21 @@ class TransactionsSpecPersonWithOnCreate
|
|
|
65
97
|
end
|
|
66
98
|
end
|
|
67
99
|
|
|
100
|
+
class TransactionsSpecPersonWithAfterCreateCommit
|
|
101
|
+
include Mongoid::Document
|
|
102
|
+
include TransactionsSpecCountable
|
|
103
|
+
|
|
104
|
+
field :name, type: String
|
|
105
|
+
|
|
106
|
+
after_create_commit do
|
|
107
|
+
after_commit_counter.inc
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
after_rollback on: :create do
|
|
111
|
+
after_rollback_counter.inc
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
68
115
|
class TransactionsSpecPersonWithOnUpdate
|
|
69
116
|
include Mongoid::Document
|
|
70
117
|
include TransactionsSpecCountable
|
|
@@ -80,6 +127,36 @@ class TransactionsSpecPersonWithOnUpdate
|
|
|
80
127
|
end
|
|
81
128
|
end
|
|
82
129
|
|
|
130
|
+
class TransactionsSpecPersonWithAfterUpdateCommit
|
|
131
|
+
include Mongoid::Document
|
|
132
|
+
include TransactionsSpecCountable
|
|
133
|
+
|
|
134
|
+
field :name, type: String
|
|
135
|
+
|
|
136
|
+
after_update_commit do
|
|
137
|
+
after_commit_counter.inc
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
after_rollback on: :create do
|
|
141
|
+
after_rollback_counter.inc
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
class TransactionsSpecPersonWithAfterSaveCommit
|
|
146
|
+
include Mongoid::Document
|
|
147
|
+
include TransactionsSpecCountable
|
|
148
|
+
|
|
149
|
+
field :name, type: String
|
|
150
|
+
|
|
151
|
+
after_save_commit do
|
|
152
|
+
after_commit_counter.inc
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
after_rollback on: :create do
|
|
156
|
+
after_rollback_counter.inc
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
83
160
|
class TransactionsSpecPersonWithOnDestroy
|
|
84
161
|
include Mongoid::Document
|
|
85
162
|
include TransactionsSpecCountable
|
|
@@ -94,6 +171,22 @@ class TransactionsSpecPersonWithOnDestroy
|
|
|
94
171
|
after_rollback_counter.inc
|
|
95
172
|
end
|
|
96
173
|
end
|
|
174
|
+
|
|
175
|
+
class TransactionsSpecPersonWithAfterDestroyCommit
|
|
176
|
+
include Mongoid::Document
|
|
177
|
+
include TransactionsSpecCountable
|
|
178
|
+
|
|
179
|
+
field :name, type: String
|
|
180
|
+
|
|
181
|
+
after_destroy_commit do
|
|
182
|
+
after_commit_counter.inc
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
after_rollback on: :create do
|
|
186
|
+
after_rollback_counter.inc
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
97
190
|
class TransactionSpecRaisesBeforeSave
|
|
98
191
|
include Mongoid::Document
|
|
99
192
|
include TransactionsSpecCountable
|
|
@@ -244,6 +244,39 @@ describe Mongoid::Contextual::Aggregable::Mongo do
|
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
end
|
|
247
|
+
|
|
248
|
+
context 'regarding hints' do
|
|
249
|
+
let(:client) { Person.collection.client }
|
|
250
|
+
let(:subscriber) { Mrss::EventSubscriber.new }
|
|
251
|
+
|
|
252
|
+
before do
|
|
253
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
|
254
|
+
maybe_hint.aggregates(:age)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
after do
|
|
258
|
+
client.unsubscribe(Mongo::Monitoring::COMMAND, subscriber)
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
let(:event) { subscriber.single_command_started_event('aggregate') }
|
|
262
|
+
let(:command) { event.command }
|
|
263
|
+
|
|
264
|
+
context 'when no hint is provided' do
|
|
265
|
+
let(:maybe_hint) { Person }
|
|
266
|
+
|
|
267
|
+
it 'does not include the hint in the command' do
|
|
268
|
+
expect(command['hint']).to be_nil
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
context 'when a hint is provided' do
|
|
273
|
+
let(:maybe_hint) { Person.hint(age: 1) }
|
|
274
|
+
|
|
275
|
+
it 'includes the hint with the command' do
|
|
276
|
+
expect(command['hint']).to eq({ 'age' => 1 })
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
end
|
|
247
280
|
end
|
|
248
281
|
|
|
249
282
|
describe "#avg" do
|
|
@@ -134,6 +134,16 @@ describe Mongoid::Reloadable do
|
|
|
134
134
|
|
|
135
135
|
agent.title.should == '007'
|
|
136
136
|
end
|
|
137
|
+
|
|
138
|
+
it 'sets new_record to false' do
|
|
139
|
+
expect(agent.new_record?).to be true
|
|
140
|
+
|
|
141
|
+
lambda do
|
|
142
|
+
agent.reload
|
|
143
|
+
end.should_not raise_error
|
|
144
|
+
|
|
145
|
+
expect(agent.new_record?).to be false
|
|
146
|
+
end
|
|
137
147
|
end
|
|
138
148
|
end
|
|
139
149
|
|
|
@@ -596,6 +606,20 @@ describe Mongoid::Reloadable do
|
|
|
596
606
|
band.id.should_not == original_id
|
|
597
607
|
end
|
|
598
608
|
end
|
|
609
|
+
|
|
610
|
+
context 'when there is no document matching our id' do
|
|
611
|
+
let(:agent) { Agent.new(id: BSON::ObjectId.new) }
|
|
612
|
+
|
|
613
|
+
it 'does not set new_record to false' do
|
|
614
|
+
expect(agent.new_record?).to be true
|
|
615
|
+
|
|
616
|
+
lambda do
|
|
617
|
+
agent.reload
|
|
618
|
+
end.should_not raise_error
|
|
619
|
+
|
|
620
|
+
expect(agent.new_record?).to be true
|
|
621
|
+
end
|
|
622
|
+
end
|
|
599
623
|
end
|
|
600
624
|
|
|
601
625
|
context 'when document has referenced associations' do
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Candidate Tasks
|
|
2
|
+
|
|
3
|
+
When using the `candidate` rake tasks, you must make sure:
|
|
4
|
+
|
|
5
|
+
1. You are using at least `git` version 2.49.0.
|
|
6
|
+
2. You have the `gh` CLI tool installed.
|
|
7
|
+
3. You are logged into `gh` with an account that has collaborator access to the repository.
|
|
8
|
+
4. You have run `gh repo set-default` from the root of your local checkout to set the default repository to the canonical MongoDB repo.
|
|
9
|
+
5. The `origin` remote for your local checkout is set to your own fork.
|
|
10
|
+
6. The `upstream` remote for your local checkout is set to the canonical
|
|
11
|
+
MongoDB repo.
|
|
12
|
+
|
|
13
|
+
Once configured, you can use the following commands:
|
|
14
|
+
|
|
15
|
+
1. `rake candidate:prs` - This will list all pull requests that will be included in the next release. Any with `[?]` are unlabelled (or are not labelled with a recognized label). Otherwise, `[b]` means `bug`, `[f]` means `feature`, and `[x]` means `bcbreak`.
|
|
16
|
+
2. `rake candidate:preview` - This will generate and display the release notes for the next release, based on the associated pull requests.
|
|
17
|
+
3. `rake candidate:create` - This will create a new PR against the default repository, using the generated release notes as the description. The new PR will be given the `release-candidate` label.
|
|
18
|
+
|
|
19
|
+
Then, after the release candidate PR is approved and merged, the release process will automatically bundle, sign, and release the new version.
|
|
20
|
+
|
|
21
|
+
Once you've merged the PR, you can switch to the "Actions" tab for the repository on GitHub and look for the "Release" workflow (might be named differently), which should have triggered automatically. You can monitor the progress of the release there. If there are any problems, the workflow is generally safe to re-run after you've addressed them.
|
|
22
|
+
|
|
23
|
+
Things to do after the release succeeds:
|
|
24
|
+
|
|
25
|
+
1. Copy the release notes from the PR and create a new release announcement on the forums (https://www.mongodb.com/community/forums/c/announcements/driver-releases/110).
|
|
26
|
+
2. If the release was not automatically announced in #ruby, copy a link to the GitHub release or MongoDB forum post there.
|
|
27
|
+
3. Close the release in Jira.
|
|
28
|
+
|
|
@@ -25,19 +25,19 @@ module Mrss
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def initialize(root: nil, classifiers:, priority_order:,
|
|
28
|
-
spec_root: nil, rspec_json_path: nil, rspec_all_json_path: nil,
|
|
29
|
-
randomize: false
|
|
28
|
+
spec_root: nil, rspec_json_path: nil, rspec_all_json_path: nil, rspec_xml_path: nil, randomize: false
|
|
30
29
|
)
|
|
31
30
|
@spec_root = spec_root || File.join(root, 'spec')
|
|
32
31
|
@classifiers = classifiers
|
|
33
32
|
@priority_order = priority_order
|
|
34
33
|
@rspec_json_path = rspec_json_path || File.join(root, 'tmp/rspec.json')
|
|
35
34
|
@rspec_all_json_path = rspec_all_json_path || File.join(root, 'tmp/rspec-all.json')
|
|
35
|
+
@rspec_xml_path = rspec_xml_path || File.join(root, 'tmp/rspec.xml')
|
|
36
36
|
@randomize = !!randomize
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
attr_reader :spec_root, :classifiers, :priority_order
|
|
40
|
-
attr_reader :rspec_json_path, :rspec_all_json_path
|
|
40
|
+
attr_reader :rspec_json_path, :rspec_all_json_path, :rspec_xml_path
|
|
41
41
|
|
|
42
42
|
def randomize?
|
|
43
43
|
@randomize
|
|
@@ -47,6 +47,25 @@ module Mrss
|
|
|
47
47
|
@seed ||= (rand * 100_000).to_i
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
# Remove all XML files from tmp directory before running tests
|
|
51
|
+
def cleanup_xml_files
|
|
52
|
+
xml_pattern = File.join(File.dirname(rspec_xml_path), '*.xml')
|
|
53
|
+
Dir.glob(xml_pattern).each do |xml_file|
|
|
54
|
+
FileUtils.rm_f(xml_file)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Move the XML file to a timestamped version for evergreen upload
|
|
59
|
+
def archive_xml_file(category)
|
|
60
|
+
return unless File.exist?(rspec_xml_path)
|
|
61
|
+
|
|
62
|
+
timestamp = Time.now.strftime('%Y%m%d_%H%M%S_%3N')
|
|
63
|
+
archived_path = rspec_xml_path.sub(/\.xml$/, "-#{category}-#{timestamp}.xml")
|
|
64
|
+
|
|
65
|
+
FileUtils.mv(rspec_xml_path, archived_path)
|
|
66
|
+
puts "Archived XML results to #{archived_path}"
|
|
67
|
+
end
|
|
68
|
+
|
|
50
69
|
def buckets
|
|
51
70
|
@buckets ||= {}.tap do |buckets|
|
|
52
71
|
Find.find(spec_root) do |path|
|
|
@@ -96,6 +115,8 @@ module Mrss
|
|
|
96
115
|
|
|
97
116
|
def run_buckets(*buckets)
|
|
98
117
|
FileUtils.rm_f(rspec_all_json_path)
|
|
118
|
+
# Clean up all XML files before starting test runs
|
|
119
|
+
cleanup_xml_files
|
|
99
120
|
|
|
100
121
|
buckets.each do |bucket|
|
|
101
122
|
if bucket && !self.buckets[bucket]
|
|
@@ -131,7 +152,12 @@ module Mrss
|
|
|
131
152
|
def run_files(category, paths)
|
|
132
153
|
puts "Running #{category.to_s.gsub('_', ' ')} tests"
|
|
133
154
|
FileUtils.rm_f(rspec_json_path)
|
|
155
|
+
FileUtils.rm_f(rspec_xml_path) # Clean up XML file before running this bucket
|
|
156
|
+
|
|
134
157
|
cmd = %w(rspec) + paths
|
|
158
|
+
# Add junit formatter for XML output
|
|
159
|
+
cmd += ['--format', 'Rfc::Riff', '--format', 'RspecJunitFormatter', '--out', rspec_xml_path]
|
|
160
|
+
|
|
135
161
|
if randomize?
|
|
136
162
|
cmd += %W(--order rand:#{seed})
|
|
137
163
|
end
|
|
@@ -147,6 +173,9 @@ module Mrss
|
|
|
147
173
|
FileUtils.cp(rspec_json_path, rspec_all_json_path)
|
|
148
174
|
end
|
|
149
175
|
end
|
|
176
|
+
|
|
177
|
+
# Archive XML file after running this bucket
|
|
178
|
+
archive_xml_file(category)
|
|
150
179
|
end
|
|
151
180
|
|
|
152
181
|
true
|
data/spec/shared/shlib/server.sh
CHANGED
|
@@ -78,7 +78,7 @@ install_mlaunch_venv() {
|
|
|
78
78
|
# Debian11/Ubuntu2204 have venv installed, but it is nonfunctional unless
|
|
79
79
|
# the python3-venv package is also installed (it lacks the ensurepip
|
|
80
80
|
# module).
|
|
81
|
-
sudo apt-get install --yes python3-venv
|
|
81
|
+
sudo apt-get update && sudo apt-get install --yes python3-venv
|
|
82
82
|
fi
|
|
83
83
|
if test "$USE_SYSTEM_PYTHON_PACKAGES" = 1 &&
|
|
84
84
|
python3 -m pip list |grep mtools
|
data/spec/support/models/seo.rb
CHANGED
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: 9.0.
|
|
4
|
+
version: 9.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- The MongoDB Ruby Team
|
|
@@ -18,7 +18,7 @@ dependencies:
|
|
|
18
18
|
version: '5.1'
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: '8.
|
|
21
|
+
version: '8.2'
|
|
22
22
|
- - "!="
|
|
23
23
|
- !ruby/object:Gem::Version
|
|
24
24
|
version: 7.0.0
|
|
@@ -31,7 +31,7 @@ dependencies:
|
|
|
31
31
|
version: '5.1'
|
|
32
32
|
- - "<"
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '8.
|
|
34
|
+
version: '8.2'
|
|
35
35
|
- - "!="
|
|
36
36
|
- !ruby/object:Gem::Version
|
|
37
37
|
version: 7.0.0
|
|
@@ -437,6 +437,7 @@ files:
|
|
|
437
437
|
- lib/mongoid/persistable/updatable.rb
|
|
438
438
|
- lib/mongoid/persistable/upsertable.rb
|
|
439
439
|
- lib/mongoid/persistence_context.rb
|
|
440
|
+
- lib/mongoid/pluckable.rb
|
|
440
441
|
- lib/mongoid/positional.rb
|
|
441
442
|
- lib/mongoid/railtie.rb
|
|
442
443
|
- lib/mongoid/railties/bson_object_id_serializer.rb
|
|
@@ -895,6 +896,7 @@ files:
|
|
|
895
896
|
- spec/mongoid_spec.rb
|
|
896
897
|
- spec/rails/controller_extension/controller_runtime_spec.rb
|
|
897
898
|
- spec/rails/mongoid_spec.rb
|
|
899
|
+
- spec/shared/CANDIDATE.md
|
|
898
900
|
- spec/shared/LICENSE
|
|
899
901
|
- spec/shared/bin/get-mongodb-download-url
|
|
900
902
|
- spec/shared/bin/s3-copy
|
|
@@ -1229,7 +1231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1229
1231
|
- !ruby/object:Gem::Version
|
|
1230
1232
|
version: 1.3.6
|
|
1231
1233
|
requirements: []
|
|
1232
|
-
rubygems_version:
|
|
1234
|
+
rubygems_version: 4.0.2
|
|
1233
1235
|
specification_version: 4
|
|
1234
1236
|
summary: Elegant Persistence in Ruby for MongoDB.
|
|
1235
1237
|
test_files:
|
|
@@ -1642,6 +1644,7 @@ test_files:
|
|
|
1642
1644
|
- spec/mongoid_spec.rb
|
|
1643
1645
|
- spec/rails/controller_extension/controller_runtime_spec.rb
|
|
1644
1646
|
- spec/rails/mongoid_spec.rb
|
|
1647
|
+
- spec/shared/CANDIDATE.md
|
|
1645
1648
|
- spec/shared/LICENSE
|
|
1646
1649
|
- spec/shared/bin/get-mongodb-download-url
|
|
1647
1650
|
- spec/shared/bin/s3-copy
|