mongoid 2.4.7 → 2.4.8
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.
- data/CHANGELOG.md +26 -0
- data/lib/mongoid.rb +1 -0
- data/lib/mongoid/callbacks.rb +1 -1
- data/lib/mongoid/collections/retry.rb +1 -0
- data/lib/mongoid/config.rb +3 -1
- data/lib/mongoid/contexts/mongo.rb +10 -10
- data/lib/mongoid/criterion/inclusion.rb +1 -1
- data/lib/mongoid/fields.rb +4 -2
- data/lib/mongoid/named_scope.rb +2 -1
- data/lib/mongoid/nested_attributes.rb +1 -1
- data/lib/mongoid/relations/embedded/many.rb +5 -3
- data/lib/mongoid/relations/referenced/many.rb +1 -0
- data/lib/mongoid/relations/referenced/many_to_many.rb +1 -0
- data/lib/mongoid/state.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,32 @@
|
|
3
3
|
For instructions on upgrading to newer versions, visit
|
4
4
|
[mongoid.org](http://mongoid.org/docs/upgrading.html).
|
5
5
|
|
6
|
+
## 2.4.8
|
7
|
+
|
8
|
+
### Resolved Issues
|
9
|
+
|
10
|
+
* \#1892 When getting not master operation error, Mongoid should reconnect
|
11
|
+
before retrying the operation.
|
12
|
+
|
13
|
+
* \#1887 Don't cascade callbacks to children that don't have the callback
|
14
|
+
defined.
|
15
|
+
|
16
|
+
* \#1882 Don't expand duplicate id criterion into an $and with duplicate
|
17
|
+
selections.
|
18
|
+
|
19
|
+
* \#1878 Fixed default application values not to apply in certain `only`
|
20
|
+
or `without` selection on iteration, not just `first` and `last`.
|
21
|
+
|
22
|
+
* \#1874 Fixed the reject all blank proc constant to handle values
|
23
|
+
properly with a destroy non blank value. (Stefan Daschek)
|
24
|
+
|
25
|
+
* \#1869/\#1868 Delayed atomic sets now uses the atomic path instead of
|
26
|
+
the metadata name to fix multiple level embedding issues.
|
27
|
+
(Chris Micacchi provided specs)
|
28
|
+
|
29
|
+
* \#1866 Post processed defaults (procs) should be applied post binding
|
30
|
+
of the child in a relation.build.
|
31
|
+
|
6
32
|
## 2.4.7
|
7
33
|
|
8
34
|
### Resolved Issues
|
data/lib/mongoid.rb
CHANGED
data/lib/mongoid/callbacks.rb
CHANGED
@@ -105,7 +105,7 @@ module Mongoid #:nodoc:
|
|
105
105
|
#
|
106
106
|
# @since 2.3.0
|
107
107
|
def cascadable_child?(kind, child)
|
108
|
-
return false if kind == :initialize
|
108
|
+
return false if kind == :initialize || !child.respond_to?("_#{kind}_callbacks")
|
109
109
|
[ :create, :destroy ].include?(kind) || child.changed? || child.new_record?
|
110
110
|
end
|
111
111
|
|
data/lib/mongoid/config.rb
CHANGED
@@ -54,7 +54,9 @@ module Mongoid #:nodoc
|
|
54
54
|
end
|
55
55
|
|
56
56
|
# keys to remove from self to not pass through to Mongo::Connection
|
57
|
-
PRIVATE_OPTIONS =
|
57
|
+
PRIVATE_OPTIONS =
|
58
|
+
%w(uri host hosts port database databases username
|
59
|
+
password logger use_activesupport_time_zone)
|
58
60
|
|
59
61
|
# Get the blacklisted options from passing through to the driver.
|
60
62
|
#
|
@@ -166,14 +166,12 @@ module Mongoid #:nodoc:
|
|
166
166
|
# @return [ Cursor ] An enumerable +Cursor+ of results.
|
167
167
|
def execute
|
168
168
|
collection, options = klass.collection, process_options
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
eager_load(docs)
|
173
|
-
end
|
174
|
-
else
|
175
|
-
collection.find(selector, options)
|
169
|
+
if criteria.inclusions.any?
|
170
|
+
collection.find(selector, options).entries.tap do |docs|
|
171
|
+
eager_load(docs)
|
176
172
|
end
|
173
|
+
else
|
174
|
+
collection.find(selector, options)
|
177
175
|
end
|
178
176
|
end
|
179
177
|
|
@@ -256,9 +254,11 @@ module Mongoid #:nodoc:
|
|
256
254
|
# @example Iterate over the results.
|
257
255
|
# context.iterate { |doc| p doc }
|
258
256
|
def iterate(&block)
|
259
|
-
|
260
|
-
|
261
|
-
|
257
|
+
selecting do
|
258
|
+
return caching(&block) if cached?
|
259
|
+
if block_given?
|
260
|
+
execute.each { |doc| yield doc }
|
261
|
+
end
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
@@ -268,7 +268,7 @@ module Mongoid #:nodoc:
|
|
268
268
|
if key.mongoid_id?
|
269
269
|
if crit.selector.has_key?("$and")
|
270
270
|
crit.selector["$and"] << { key => value }
|
271
|
-
|
271
|
+
elsif crit.selector[key] != value
|
272
272
|
crit.selector["$and"] = [{ key => crit.selector.delete(key) }, { key => value }]
|
273
273
|
end
|
274
274
|
elsif crit.selector[key].respond_to?(:merge) && value.respond_to?(:merge)
|
data/lib/mongoid/fields.rb
CHANGED
@@ -92,8 +92,10 @@ module Mongoid #:nodoc
|
|
92
92
|
unless attributes.has_key?(name)
|
93
93
|
if field = fields[name]
|
94
94
|
default = field.eval_default(self)
|
95
|
-
|
96
|
-
|
95
|
+
unless default.nil?
|
96
|
+
attribute_will_change!(name)
|
97
|
+
attributes[name] = default
|
98
|
+
end
|
97
99
|
end
|
98
100
|
end
|
99
101
|
end
|
data/lib/mongoid/named_scope.rb
CHANGED
@@ -56,7 +56,8 @@ module Mongoid #:nodoc:
|
|
56
56
|
(class << self; self; end).class_eval <<-EOT
|
57
57
|
def #{name}(*args)
|
58
58
|
scope = scopes[:#{name}]
|
59
|
-
scope.
|
59
|
+
conditions = scope.conditions.as_conditions(*args)
|
60
|
+
scope.extend(criteria.fuse(conditions))
|
60
61
|
end
|
61
62
|
EOT
|
62
63
|
end
|
@@ -12,7 +12,7 @@ module Mongoid #:nodoc:
|
|
12
12
|
|
13
13
|
module ClassMethods #:nodoc:
|
14
14
|
|
15
|
-
REJECT_ALL_BLANK_PROC = proc { |attributes| attributes.all? { |
|
15
|
+
REJECT_ALL_BLANK_PROC = proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } }
|
16
16
|
|
17
17
|
# Used when needing to update related models from a parent relation. Can
|
18
18
|
# be used on embedded or referenced relations.
|
@@ -94,6 +94,7 @@ module Mongoid # :nodoc:
|
|
94
94
|
Factory.build(type || metadata.klass, attributes, options).tap do |doc|
|
95
95
|
doc.identify
|
96
96
|
append(doc)
|
97
|
+
doc.apply_proc_defaults
|
97
98
|
yield(doc) if block_given?
|
98
99
|
doc.run_callbacks(:build) { doc }
|
99
100
|
end
|
@@ -311,14 +312,15 @@ module Mongoid # :nodoc:
|
|
311
312
|
docs = replacement.compact
|
312
313
|
proxy.target = docs
|
313
314
|
self._unscoped = docs.dup
|
314
|
-
if _assigning?
|
315
|
-
base.delayed_atomic_sets[metadata.name.to_s] = proxy.as_document
|
316
|
-
end
|
317
315
|
proxy.target.each_with_index do |doc, index|
|
318
316
|
integrate(doc)
|
319
317
|
doc._index = index
|
320
318
|
doc.save if base.persisted? && !_assigning?
|
321
319
|
end
|
320
|
+
if _assigning?
|
321
|
+
name = proxy.first.atomic_path
|
322
|
+
base.delayed_atomic_sets[name] = proxy.as_document
|
323
|
+
end
|
322
324
|
end
|
323
325
|
end
|
324
326
|
end
|
@@ -75,6 +75,7 @@ module Mongoid # :nodoc:
|
|
75
75
|
Factory.build(type || klass, attributes, options).tap do |doc|
|
76
76
|
base.send(metadata.foreign_key).push(doc.id)
|
77
77
|
append(doc)
|
78
|
+
doc.apply_proc_defaults
|
78
79
|
doc.synced[metadata.inverse_foreign_key] = false
|
79
80
|
yield(doc) if block_given?
|
80
81
|
end
|
data/lib/mongoid/state.rb
CHANGED
data/lib/mongoid/version.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: 2.4.
|
4
|
+
version: 2.4.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -459,7 +459,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
459
459
|
version: '0'
|
460
460
|
segments:
|
461
461
|
- 0
|
462
|
-
hash:
|
462
|
+
hash: 2935457969941610047
|
463
463
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
464
464
|
none: false
|
465
465
|
requirements:
|