mongoid 7.2.6 → 7.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +1 -1
- data/Rakefile +16 -0
- data/lib/config/locales/en.yml +2 -15
- data/lib/mongoid/association/accessors.rb +1 -1
- data/lib/mongoid/association/constrainable.rb +1 -1
- data/lib/mongoid/association/depending.rb +4 -4
- data/lib/mongoid/association/embedded/batchable.rb +1 -1
- data/lib/mongoid/association/embedded/embedded_in.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +11 -4
- data/lib/mongoid/association/nested/many.rb +1 -1
- data/lib/mongoid/association/nested/one.rb +4 -2
- data/lib/mongoid/association/proxy.rb +7 -2
- data/lib/mongoid/association/referenced/auto_save.rb +2 -2
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +493 -495
- data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -3
- data/lib/mongoid/association/referenced/has_one/nested_builder.rb +2 -2
- data/lib/mongoid/association/relatable.rb +0 -2
- data/lib/mongoid/attributes/projector.rb +120 -0
- data/lib/mongoid/attributes.rb +24 -13
- data/lib/mongoid/cacheable.rb +2 -2
- data/lib/mongoid/clients/factory.rb +22 -8
- data/lib/mongoid/clients.rb +1 -1
- data/lib/mongoid/config/environment.rb +1 -9
- data/lib/mongoid/config.rb +19 -2
- data/lib/mongoid/contextual/aggregable/mongo.rb +10 -8
- data/lib/mongoid/contextual/atomic.rb +2 -7
- data/lib/mongoid/contextual/none.rb +0 -3
- data/lib/mongoid/copyable.rb +1 -1
- data/lib/mongoid/criteria/findable.rb +1 -1
- data/lib/mongoid/criteria/queryable/expandable.rb +0 -24
- data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions.rb +0 -4
- data/lib/mongoid/criteria/queryable/mergeable.rb +46 -20
- data/lib/mongoid/criteria/queryable/selectable.rb +10 -10
- data/lib/mongoid/criteria/queryable/storable.rb +4 -4
- data/lib/mongoid/criteria.rb +5 -6
- data/lib/mongoid/document.rb +3 -18
- data/lib/mongoid/errors/delete_restriction.rb +8 -9
- data/lib/mongoid/errors/mongoid_error.rb +1 -1
- data/lib/mongoid/errors.rb +0 -2
- data/lib/mongoid/evolvable.rb +1 -1
- data/lib/mongoid/extensions/boolean.rb +1 -2
- data/lib/mongoid/extensions/false_class.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +2 -2
- data/lib/mongoid/extensions/true_class.rb +1 -1
- data/lib/mongoid/fields.rb +43 -5
- data/lib/mongoid/inspectable.rb +1 -1
- data/lib/mongoid/interceptable.rb +1 -1
- data/lib/mongoid/matcher/bits.rb +41 -0
- data/lib/mongoid/matcher/bits_all_clear.rb +20 -0
- data/lib/mongoid/matcher/bits_all_set.rb +20 -0
- data/lib/mongoid/matcher/bits_any_clear.rb +20 -0
- data/lib/mongoid/matcher/bits_any_set.rb +20 -0
- data/lib/mongoid/matcher/expression.rb +4 -0
- data/lib/mongoid/matcher/field_operator.rb +6 -0
- data/lib/mongoid/matcher/mod.rb +17 -0
- data/lib/mongoid/matcher/type.rb +99 -0
- data/lib/mongoid/matcher.rb +7 -0
- data/lib/mongoid/persistable/deletable.rb +1 -2
- data/lib/mongoid/persistable/destroyable.rb +8 -2
- data/lib/mongoid/persistable/updatable.rb +27 -2
- data/lib/mongoid/persistence_context.rb +1 -3
- data/lib/mongoid/query_cache.rb +36 -40
- data/lib/mongoid/selectable.rb +5 -7
- data/lib/mongoid/shardable.rb +21 -5
- data/lib/mongoid/tasks/database.rb +1 -1
- data/lib/mongoid/touchable.rb +23 -4
- data/lib/mongoid/validatable/associated.rb +1 -1
- data/lib/mongoid/validatable/presence.rb +3 -3
- data/lib/mongoid/validatable/uniqueness.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid.rb +0 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +1 -1
- data/spec/integration/app_spec.rb +0 -3
- data/spec/integration/associations/embeds_many_spec.rb +44 -0
- data/spec/integration/associations/has_one_spec.rb +48 -0
- data/spec/integration/criteria/date_field_spec.rb +1 -1
- data/spec/integration/document_spec.rb +9 -0
- data/spec/integration/matcher_operator_data/bits_all_clear.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_all_set.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_any_clear.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_any_set.yml +159 -0
- data/spec/integration/matcher_operator_data/comment.yml +22 -0
- data/spec/integration/matcher_operator_data/in.yml +16 -0
- data/spec/integration/matcher_operator_data/mod.yml +55 -0
- data/spec/integration/matcher_operator_data/type.yml +70 -0
- data/spec/integration/matcher_operator_data/type_array.yml +16 -0
- data/spec/integration/matcher_operator_data/type_binary.yml +18 -0
- data/spec/integration/matcher_operator_data/type_boolean.yml +39 -0
- data/spec/integration/matcher_operator_data/type_code.yml +26 -0
- data/spec/integration/matcher_operator_data/type_code_with_scope.yml +26 -0
- data/spec/integration/matcher_operator_data/type_date.yml +39 -0
- data/spec/integration/matcher_operator_data/type_db_pointer.yml +19 -0
- data/spec/integration/matcher_operator_data/type_decimal.yml +40 -0
- data/spec/integration/matcher_operator_data/type_double.yml +15 -0
- data/spec/integration/matcher_operator_data/type_int32.yml +33 -0
- data/spec/integration/matcher_operator_data/type_int64.yml +33 -0
- data/spec/integration/matcher_operator_data/type_max_key.yml +17 -0
- data/spec/integration/matcher_operator_data/type_min_key.yml +17 -0
- data/spec/integration/matcher_operator_data/type_null.yml +23 -0
- data/spec/integration/matcher_operator_data/type_object.yml +23 -0
- data/spec/integration/matcher_operator_data/type_object_id.yml +25 -0
- data/spec/integration/matcher_operator_data/type_regex.yml +44 -0
- data/spec/integration/matcher_operator_data/type_string.yml +15 -0
- data/spec/integration/matcher_operator_data/type_symbol.yml +32 -0
- data/spec/integration/matcher_operator_data/type_timestamp.yml +25 -0
- data/spec/integration/matcher_operator_data/type_undefined.yml +17 -0
- data/spec/integration/stringified_symbol_field_spec.rb +2 -2
- data/spec/lite_spec_helper.rb +2 -0
- data/spec/mongoid/association/depending_spec.rb +391 -352
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +4 -17
- data/spec/mongoid/association/nested/one_spec.rb +18 -14
- data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +25 -25
- data/spec/mongoid/association/referenced/belongs_to_query_spec.rb +0 -20
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many/binding_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many_models.rb +0 -17
- data/spec/mongoid/association/referenced/has_one_models.rb +8 -0
- data/spec/mongoid/atomic/paths_spec.rb +64 -12
- data/spec/mongoid/attributes/projector_data/embedded.yml +105 -0
- data/spec/mongoid/attributes/projector_data/fields.yml +93 -0
- data/spec/mongoid/attributes/projector_spec.rb +41 -0
- data/spec/mongoid/attributes_spec.rb +98 -6
- data/spec/mongoid/clients/factory_spec.rb +51 -9
- data/spec/mongoid/clients/options_spec.rb +3 -11
- data/spec/mongoid/config/environment_spec.rb +8 -86
- data/spec/mongoid/config_spec.rb +32 -0
- data/spec/mongoid/contextual/atomic_spec.rb +25 -64
- data/spec/mongoid/contextual/geo_near_spec.rb +1 -1
- data/spec/mongoid/contextual/mongo_spec.rb +2 -2
- data/spec/mongoid/criteria/modifiable_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/expandable_spec.rb +0 -73
- data/spec/mongoid/criteria/queryable/extensions/boolean_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/mergeable_spec.rb +105 -7
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +229 -24
- data/spec/mongoid/criteria/queryable/selectable_shared_examples.rb +39 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -565
- data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +590 -0
- data/spec/mongoid/criteria_projection_spec.rb +411 -0
- data/spec/mongoid/criteria_spec.rb +0 -279
- data/spec/mongoid/document_query_spec.rb +0 -51
- data/spec/mongoid/document_spec.rb +14 -34
- data/spec/mongoid/errors/delete_restriction_spec.rb +1 -1
- data/spec/mongoid/errors/mongoid_error_spec.rb +8 -20
- data/spec/mongoid/extensions/false_class_spec.rb +1 -1
- data/spec/mongoid/extensions/string_spec.rb +5 -5
- data/spec/mongoid/extensions/true_class_spec.rb +1 -1
- data/spec/mongoid/fields/localized_spec.rb +4 -4
- data/spec/mongoid/fields_spec.rb +4 -4
- data/spec/mongoid/inspectable_spec.rb +12 -4
- data/spec/mongoid/persistable/deletable_spec.rb +175 -1
- data/spec/mongoid/persistable/destroyable_spec.rb +191 -3
- data/spec/mongoid/persistable/savable_spec.rb +3 -5
- data/spec/mongoid/persistable/updatable_spec.rb +0 -2
- data/spec/mongoid/persistable/upsertable_spec.rb +1 -1
- data/spec/mongoid/persistable_spec.rb +2 -2
- data/spec/mongoid/query_cache_middleware_spec.rb +8 -0
- data/spec/mongoid/query_cache_spec.rb +0 -24
- data/spec/mongoid/reloadable_spec.rb +18 -1
- data/spec/mongoid/shardable_spec.rb +44 -0
- data/spec/mongoid/touchable_spec.rb +104 -16
- data/spec/mongoid/touchable_spec_models.rb +52 -0
- data/spec/mongoid/validatable_spec.rb +1 -1
- data/spec/shared/lib/mrss/cluster_config.rb +3 -8
- data/spec/shared/lib/mrss/constraints.rb +10 -41
- data/spec/shared/lib/mrss/docker_runner.rb +1 -7
- data/spec/shared/lib/mrss/server_version_registry.rb +12 -17
- data/spec/shared/lib/mrss/spec_organizer.rb +1 -18
- data/spec/shared/share/Dockerfile.erb +33 -125
- data/spec/shared/shlib/server.sh +23 -100
- data/spec/shared/shlib/set_env.sh +1 -4
- data/spec/spec_helper.rb +7 -3
- data/spec/support/client_registry.rb +9 -0
- data/spec/support/models/address.rb +0 -4
- data/spec/support/models/bolt.rb +8 -0
- data/spec/support/models/hole.rb +13 -0
- data/spec/support/models/mop.rb +0 -1
- data/spec/support/models/nut.rb +8 -0
- data/spec/support/models/person.rb +6 -9
- data/spec/support/models/sealer.rb +8 -0
- data/spec/support/models/shirt.rb +12 -0
- data/spec/support/models/spacer.rb +8 -0
- data/spec/support/models/threadlocker.rb +8 -0
- data/spec/support/models/washer.rb +8 -0
- data.tar.gz.sig +0 -0
- metadata +609 -545
- metadata.gz.sig +0 -0
- data/lib/mongoid/errors/empty_config_file.rb +0 -26
- data/lib/mongoid/errors/invalid_config_file.rb +0 -26
- data/spec/integration/contextual/empty_spec.rb +0 -142
- data/spec/mongoid/errors/invalid_config_file_spec.rb +0 -32
- data/spec/shared/bin/s3-copy +0 -45
- data/spec/shared/bin/s3-upload +0 -69
- data/spec/shared/lib/mrss/event_subscriber.rb +0 -200
- data/spec/shared/share/haproxy-1.conf +0 -16
- data/spec/shared/share/haproxy-2.conf +0 -17
- data/spec/support/cluster_config.rb +0 -158
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d1e8ba04808e5217cc1622623532caa8c519a412278bfe85d2ed6cfdeda62c7
|
4
|
+
data.tar.gz: 38067c7a3a2a3347b8e564e2069938cbed1d1adb4668573465b088fc01bbe167
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 067d6b81359b6c45c2c877ebeab3382425abe08f3ca5a75bf4dd880e7f082479a63823c38030fba356c061da8e9a7ea7393ca30f58c10c858b2f2d412a0aca0d
|
7
|
+
data.tar.gz: 4cdc9196e41db201ec36ea7024eab9ce9d7f20bf45db005c5c5111bd73756e9c5cf1ff2fc2fbead7c702ac47fabaa44aead2ab6d4db6d008ffb387d2c0c0efdb
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -66,6 +66,22 @@ task :ci do
|
|
66
66
|
spec_organizer.run
|
67
67
|
end
|
68
68
|
|
69
|
+
task :bucket, %i(buckets) do |task, args|
|
70
|
+
buckets = args[:buckets]
|
71
|
+
buckets = if buckets.nil? || buckets.empty?
|
72
|
+
[nil]
|
73
|
+
else
|
74
|
+
buckets.split(':').map do |bucket|
|
75
|
+
if bucket.empty?
|
76
|
+
nil
|
77
|
+
else
|
78
|
+
bucket.to_sym
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
spec_organizer.run_buckets(*buckets)
|
83
|
+
end
|
84
|
+
|
69
85
|
task :default => :spec
|
70
86
|
|
71
87
|
desc "Generate all documentation"
|
data/lib/config/locales/en.yml
CHANGED
@@ -80,12 +80,6 @@ en:
|
|
80
80
|
different collections so a simple id lookup is not sufficient enough."
|
81
81
|
resolution: "Don't attempt to perform this action and have patience,
|
82
82
|
maybe this will be supported in the future."
|
83
|
-
empty_config_file:
|
84
|
-
message: "Empty configuration file: %{path}."
|
85
|
-
summary: "Your mongoid.yml configuration file appears to be empty."
|
86
|
-
resolution: "Ensure your configuration file contains the correct contents.
|
87
|
-
Please consult the following page with respect to Mongoid's configuration:
|
88
|
-
https://docs.mongodb.com/mongoid/current/reference/configuration/"
|
89
83
|
invalid_collection:
|
90
84
|
message: "Access to the collection for %{klass} is not allowed."
|
91
85
|
summary: "%{klass}.collection was called, and %{klass} is an embedded
|
@@ -100,13 +94,6 @@ en:
|
|
100
94
|
A collation option is only supported if the query is executed on a MongoDB server
|
101
95
|
with version >= 3.4."
|
102
96
|
resolution: "Remove the collation option from the query."
|
103
|
-
invalid_config_file:
|
104
|
-
message: "Invalid configuration file: %{path}."
|
105
|
-
summary: "Your mongoid.yml configuration file does not contain the
|
106
|
-
correct file structure."
|
107
|
-
resolution: "Ensure your configuration file contains the correct contents.
|
108
|
-
Please consult the following page with respect to Mongoid's configuration:
|
109
|
-
https://docs.mongodb.com/mongoid/current/reference/configuration/"
|
110
97
|
invalid_config_option:
|
111
98
|
message: "Invalid configuration option: %{name}."
|
112
99
|
summary: "A invalid configuration option was provided in your
|
@@ -591,9 +578,9 @@ en:
|
|
591
578
|
resolution: "Try persisting the document with valid data or remove
|
592
579
|
the validations."
|
593
580
|
delete_restriction:
|
594
|
-
message: "Cannot
|
581
|
+
message: "Cannot destroy %{document} because of dependent '%{relation}'."
|
595
582
|
summary: "When defining '%{relation}' with a :dependent => :restrict_with_error,
|
596
|
-
Mongoid will raise an error when attempting to
|
583
|
+
Mongoid will raise an error when attempting to destroy the
|
597
584
|
%{document} when the child '%{relation}' still has documents in it."
|
598
585
|
resolution: "Don't attempt to delete the parent %{document} when
|
599
586
|
it has children, or change the dependent option on the association."
|
@@ -300,7 +300,7 @@ module Mongoid
|
|
300
300
|
ids_method = "#{association.name.to_s.singularize}_ids"
|
301
301
|
association.inverse_class.tap do |klass|
|
302
302
|
klass.re_define_method(ids_method) do
|
303
|
-
send(association.name).only(:
|
303
|
+
send(association.name).only(:_id).map(&:_id)
|
304
304
|
end
|
305
305
|
end
|
306
306
|
end
|
@@ -78,13 +78,13 @@ module Mongoid
|
|
78
78
|
# the appropriate strategy to perform the operation.
|
79
79
|
#
|
80
80
|
# @example Execute cascades.
|
81
|
-
# document.
|
81
|
+
# document.apply_destroy_dependencies!
|
82
82
|
#
|
83
83
|
# @since 2.0.0.rc.1
|
84
|
-
def
|
84
|
+
def apply_destroy_dependencies!
|
85
85
|
self.class._all_dependents.each do |association|
|
86
|
-
if association.try(:dependent)
|
87
|
-
send("_dependent_#{
|
86
|
+
if dependent = association.try(:dependent)
|
87
|
+
send("_dependent_#{dependent}!", association)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -329,7 +329,7 @@ module Mongoid
|
|
329
329
|
self.path = doc.atomic_path unless path
|
330
330
|
execute_callback :before_remove, doc
|
331
331
|
unless _assigning?
|
332
|
-
doc.
|
332
|
+
doc.apply_destroy_dependencies!
|
333
333
|
doc.run_before_callbacks(:destroy) if method == :destroy
|
334
334
|
end
|
335
335
|
_target.delete_one(doc)
|
@@ -83,8 +83,15 @@ module Mongoid
|
|
83
83
|
|
84
84
|
alias :new :build
|
85
85
|
|
86
|
-
# Clear the association. Will delete the documents from the db
|
87
|
-
# already persisted.
|
86
|
+
# Clear the association. Will delete the documents from the db
|
87
|
+
# if they are already persisted.
|
88
|
+
#
|
89
|
+
# If the host document is not persisted but its _id matches a
|
90
|
+
# persisted document, calling #clear on an association will remove
|
91
|
+
# the association's documents from the database even though the
|
92
|
+
# set of documents in the application (as loaded in the host)
|
93
|
+
# is different from what is in the database, and the host may
|
94
|
+
# not contain any persisted documents in the association either.
|
88
95
|
#
|
89
96
|
# @example Clear the association.
|
90
97
|
# person.addresses.clear
|
@@ -332,7 +339,7 @@ module Mongoid
|
|
332
339
|
private
|
333
340
|
|
334
341
|
def object_already_related?(document)
|
335
|
-
_target.any? { |existing| existing.
|
342
|
+
_target.any? { |existing| existing._id && existing === document }
|
336
343
|
end
|
337
344
|
|
338
345
|
# Appends the document to the target array, updating the index on the
|
@@ -415,7 +422,7 @@ module Mongoid
|
|
415
422
|
# @param [ Proc ] block Optional block to pass.
|
416
423
|
#
|
417
424
|
# @return [ Criteria, Object ] A Criteria or return value from the target.
|
418
|
-
|
425
|
+
def method_missing(name, *args, &block)
|
419
426
|
return super if _target.respond_to?(name)
|
420
427
|
klass.send(:with_scope, criteria) do
|
421
428
|
criteria.public_send(name, *args, &block)
|
@@ -181,7 +181,7 @@ module Mongoid
|
|
181
181
|
first = existing.first
|
182
182
|
converted = first ? convert_id(first.class, id) : id
|
183
183
|
|
184
|
-
if existing.where(
|
184
|
+
if existing.where(_id: converted).exists?
|
185
185
|
# document exists in association
|
186
186
|
doc = existing.find(converted)
|
187
187
|
if destroyable?(attrs)
|
@@ -71,7 +71,8 @@ module Mongoid
|
|
71
71
|
#
|
72
72
|
# @since 2.0.0
|
73
73
|
def acceptable_id?
|
74
|
-
id =
|
74
|
+
id = association.klass.extract_id_field(attributes)
|
75
|
+
id = convert_id(existing.class, id)
|
75
76
|
existing._id == id || id.nil? || (existing._id != id && update_only?)
|
76
77
|
end
|
77
78
|
|
@@ -84,7 +85,8 @@ module Mongoid
|
|
84
85
|
#
|
85
86
|
# @since 2.0.0
|
86
87
|
def delete?
|
87
|
-
|
88
|
+
id = association.klass.extract_id_field(attributes)
|
89
|
+
destroyable? && !id.nil?
|
88
90
|
end
|
89
91
|
|
90
92
|
# Can the existing association potentially be destroyed?
|
@@ -16,7 +16,7 @@ module Mongoid
|
|
16
16
|
# We undefine most methods to get them sent through to the target.
|
17
17
|
instance_methods.each do |method|
|
18
18
|
undef_method(method) unless
|
19
|
-
method =~ /\A(__.*|send|object_id|equal\?|respond_to\?|tap|public_send|extend_proxy|extend_proxies)\z/
|
19
|
+
method =~ /\A(?:__.*|send|object_id|equal\?|respond_to\?|respond_to_missing\?|tap|public_send|extend_proxy|extend_proxies)\z/
|
20
20
|
end
|
21
21
|
|
22
22
|
include Threaded::Lifecycle
|
@@ -133,10 +133,15 @@ module Mongoid
|
|
133
133
|
# @param [ String, Symbol ] name The name of the method.
|
134
134
|
# @param [ Array ] args The arguments passed to the method.
|
135
135
|
#
|
136
|
-
|
136
|
+
def method_missing(name, *args, &block)
|
137
137
|
_target.send(name, *args, &block)
|
138
138
|
end
|
139
139
|
|
140
|
+
# @api private
|
141
|
+
def respond_to_missing?(name, *args)
|
142
|
+
_target.respond_to?(name, *args)
|
143
|
+
end
|
144
|
+
|
140
145
|
# When the base document illegally references an embedded document this
|
141
146
|
# error will get raised.
|
142
147
|
#
|
@@ -63,8 +63,8 @@ module Mongoid
|
|
63
63
|
self.before_callback_halted = false
|
64
64
|
else
|
65
65
|
__autosaving__ do
|
66
|
-
if
|
67
|
-
Array(
|
66
|
+
if assoc_value = ivar(association.name)
|
67
|
+
Array(assoc_value).each do |doc|
|
68
68
|
doc.with(persistence_context) do |d|
|
69
69
|
d.save
|
70
70
|
end
|