mongoid 9.0.5 → 9.0.6
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de63ddee828740cd1ba5832d931cd2c9731f19c1435076527533fb7856b48f8c
|
4
|
+
data.tar.gz: 4cfa7d1e9f00ec0fe57c7709c7147f9b214375de3e402d5a468e03cf6e61af40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4542042a79b3a3162acd38d28898cd0755128b0a209d33e3ecf18b98d12e7ab1d220045156164ec235672cff337fc2d2a53a5779b37b601e9d903481e2793236
|
7
|
+
data.tar.gz: 5bd06c74d154e09f12120d81813e6e2a1380d141cd3613350355e30e0ded7fc9774dd7dfb1ca335e00a7ad0c512e4a019e0df51bec7cb06e334cead745dd098c
|
@@ -419,11 +419,28 @@ module Mongoid
|
|
419
419
|
#
|
420
420
|
# @return [ Integer ] The size of the enumerable.
|
421
421
|
def size
|
422
|
-
|
423
|
-
|
424
|
-
|
422
|
+
# If _unloaded is present, then it will match the set of documents
|
423
|
+
# that belong to this association, which have already been persisted
|
424
|
+
# to the database. This set of documents must be considered when
|
425
|
+
# computing the size of the association, along with anything that has
|
426
|
+
# since been added.
|
427
|
+
if _unloaded
|
428
|
+
if _added.any?
|
429
|
+
# Note that _added may include records that _unloaded already
|
430
|
+
# matches. This is the case if the association is assigned an array
|
431
|
+
# of items and some of them were already elements of the association.
|
432
|
+
#
|
433
|
+
# we need to thus make sure _unloaded.count excludes any elements
|
434
|
+
# that already exist in _added.
|
435
|
+
|
436
|
+
count = _unloaded.not(:_id.in => _added.values.map(&:id)).count
|
437
|
+
count + _added.values.count
|
438
|
+
else
|
439
|
+
_unloaded.count
|
440
|
+
end
|
441
|
+
|
425
442
|
else
|
426
|
-
count + _added.
|
443
|
+
_loaded.count + _added.count
|
427
444
|
end
|
428
445
|
end
|
429
446
|
|
data/lib/mongoid/version.rb
CHANGED
@@ -26,6 +26,10 @@ describe 'Mongoid application tests' do
|
|
26
26
|
skip 'Set APP_TESTS=1 in environment to run application tests'
|
27
27
|
end
|
28
28
|
|
29
|
+
if SpecConfig.instance.rails_version < '7.1'
|
30
|
+
skip 'App tests require Rails > 7.0 (see https://stackoverflow.com/questions/79360526)'
|
31
|
+
end
|
32
|
+
|
29
33
|
require 'fileutils'
|
30
34
|
require 'mrss/child_process_helper'
|
31
35
|
require 'open-uri'
|
@@ -1756,43 +1756,6 @@ describe Mongoid::Association::Referenced::HasAndBelongsToMany::Proxy do
|
|
1756
1756
|
end
|
1757
1757
|
end
|
1758
1758
|
|
1759
|
-
describe "#any?" do
|
1760
|
-
|
1761
|
-
let(:person) do
|
1762
|
-
Person.create!
|
1763
|
-
end
|
1764
|
-
|
1765
|
-
context "when nothing exists on the relation" do
|
1766
|
-
|
1767
|
-
context "when no document is added" do
|
1768
|
-
|
1769
|
-
let!(:sandwich) do
|
1770
|
-
Sandwich.create!
|
1771
|
-
end
|
1772
|
-
|
1773
|
-
it "returns false" do
|
1774
|
-
expect(sandwich.meats.any?).to be false
|
1775
|
-
end
|
1776
|
-
end
|
1777
|
-
|
1778
|
-
context "when the document is destroyed" do
|
1779
|
-
|
1780
|
-
before do
|
1781
|
-
Meat.create!
|
1782
|
-
end
|
1783
|
-
|
1784
|
-
let!(:sandwich) do
|
1785
|
-
Sandwich.create!
|
1786
|
-
end
|
1787
|
-
|
1788
|
-
it "returns false" do
|
1789
|
-
sandwich.destroy
|
1790
|
-
expect(sandwich.meats.any?).to be false
|
1791
|
-
end
|
1792
|
-
end
|
1793
|
-
end
|
1794
|
-
end
|
1795
|
-
|
1796
1759
|
context "when documents have been persisted" do
|
1797
1760
|
|
1798
1761
|
let!(:preference) do
|
@@ -3041,6 +3004,34 @@ describe Mongoid::Association::Referenced::HasAndBelongsToMany::Proxy do
|
|
3041
3004
|
end
|
3042
3005
|
end
|
3043
3006
|
|
3007
|
+
# MONGOID-5844
|
3008
|
+
#
|
3009
|
+
# Specifically, this tests the case where the association is
|
3010
|
+
# initialized with a single element (so that Proxy#push does not take
|
3011
|
+
# the `concat` route), which causes `reset_unloaded` to be called, which
|
3012
|
+
# sets the `_unloaded` Criteria object to match only the specific element
|
3013
|
+
# that was given.
|
3014
|
+
#
|
3015
|
+
# The issue now is that when the events list is updated to be both events,
|
3016
|
+
# _unloaded matches one of them already, and the other has previously been
|
3017
|
+
# persisted so `new_record?` won't match it. We need to make sure the
|
3018
|
+
# `#size` logic properly accounts for this case.
|
3019
|
+
context 'when documents have been previously persisted' do
|
3020
|
+
let(:person1) { Person.create! }
|
3021
|
+
let(:person2) { Person.create! }
|
3022
|
+
let(:event1) { Event.create!(administrators: [ person1 ]) }
|
3023
|
+
let(:event2) { Event.create!(administrators: [ person2 ]) }
|
3024
|
+
|
3025
|
+
before do
|
3026
|
+
person1.administrated_events = [ event1, event2 ]
|
3027
|
+
end
|
3028
|
+
|
3029
|
+
it 'returns the number of associated documents [MONGOID-5844]' do
|
3030
|
+
expect(person1.administrated_events.to_a.size).to eq(2)
|
3031
|
+
expect(person1.administrated_events.size).to eq(2)
|
3032
|
+
end
|
3033
|
+
end
|
3034
|
+
|
3044
3035
|
context "when documents have not been persisted" do
|
3045
3036
|
|
3046
3037
|
before do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The MongoDB Ruby Team
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activemodel
|
@@ -1202,7 +1202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1202
1202
|
- !ruby/object:Gem::Version
|
1203
1203
|
version: 1.3.6
|
1204
1204
|
requirements: []
|
1205
|
-
rubygems_version: 3.6.
|
1205
|
+
rubygems_version: 3.6.5
|
1206
1206
|
specification_version: 4
|
1207
1207
|
summary: Elegant Persistence in Ruby for MongoDB.
|
1208
1208
|
test_files:
|