mongoid 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +135 -1
- data/lib/mongoid/atomic.rb +13 -0
- data/lib/mongoid/dirty.rb +1 -1
- data/lib/mongoid/extensions/object_id/conversions.rb +2 -4
- data/lib/mongoid/relations/embedded/many.rb +3 -0
- data/lib/mongoid/relations/metadata.rb +1 -4
- data/lib/mongoid/state.rb +4 -1
- data/lib/mongoid/version.rb +1 -1
- metadata +19 -19
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,140 @@
|
|
1
1
|
# Overview
|
2
2
|
|
3
|
-
For instructions on upgrading to newer versions, visit
|
3
|
+
For instructions on upgrading to newer versions, visit
|
4
|
+
[mongoid.org](http://mongoid.org/docs/upgrading.html).
|
5
|
+
|
6
|
+
## 2.4.0 \[ In Development \] \[ Branch: master \]
|
7
|
+
|
8
|
+
* Ranges can now be passed to #where criteria to create a $gte/$lte query under the
|
9
|
+
covers. `Person.where(dob: start_date...end_date)`
|
10
|
+
|
11
|
+
## 2.3.1 \[ In Development \] \[ Branch: 2.3.0-stable \]
|
12
|
+
|
13
|
+
### Resolved Issues
|
14
|
+
|
15
|
+
* \#1321 HABTM no longer allows duplicate entries or keys, instead of the previous
|
16
|
+
inconsistencies.
|
17
|
+
|
18
|
+
* \#1320 Fixed errors in perf benchmark.
|
19
|
+
|
20
|
+
* \#1316 Added a separate Rake task "db:mongoid:drop" so Mongoid and AR can coexist.
|
21
|
+
(Daniel Vartanov)
|
22
|
+
|
23
|
+
* \#1311 Fix issue with custom field serialization inheriting from hash.
|
24
|
+
|
25
|
+
* \#1295 Fixed having multiple includes only execute the eager loading of the first.
|
26
|
+
|
27
|
+
* \#1287 Fixed max versions limitation with versioning.
|
28
|
+
|
29
|
+
* \#1277 attribute_will_change! properly flags the attribute even if no change occured.
|
30
|
+
|
31
|
+
* \#920 Allow relations to be named target.
|
32
|
+
|
33
|
+
* \#861 accepts_nested_attributes_for is no longer needed to set embedded documents
|
34
|
+
via a hash or array of hashes directly.
|
35
|
+
|
36
|
+
* \#768 Fixed class_attribute definitions module wide.
|
37
|
+
|
38
|
+
* \#408 Embedded documents can now be soft deleted via `Mongoid::Paranoia`.
|
39
|
+
|
40
|
+
## 2.3.0
|
41
|
+
|
42
|
+
### New Features
|
43
|
+
|
44
|
+
* Mongoid now supports basic localized fields, storing them under the covers as a
|
45
|
+
hash of locale => value pairs. `field :name, localize: true`
|
46
|
+
|
47
|
+
* \#1275 For applications that default safe mode to true, you can now tell a
|
48
|
+
single operation to persist without safe mode via #unsafely:
|
49
|
+
`person.unsafely.save`, `Person.unsafely.create`. (Matt Sanders)
|
50
|
+
|
51
|
+
* \#1256 Mongoid now can create indexes for models in Rails engines. (Caio Filipini)
|
52
|
+
|
53
|
+
* \#1228 Allow pre formatting of compsoite keys by passing a block to #key.
|
54
|
+
(Ben Hundley)
|
55
|
+
|
56
|
+
* \#1222 Scoped mass assignment is now supported. (Andrew Shaydurov)
|
57
|
+
|
58
|
+
* \#1196 Timestamps can now be turned off on a call-by-call basis via the use
|
59
|
+
of #timeless: `person.timeless.save`, `Person.timeless.create(:title => "Sir")`.
|
60
|
+
|
61
|
+
* \#1103 Allow developers to create their own custom complex criteria. (Ryan Ong)
|
62
|
+
|
63
|
+
* Mongoid now includes all defined fields in `serializable_hash` and `to_json`
|
64
|
+
results even if the fields have no values to make serialized documents easier
|
65
|
+
to use by ActiveResource clients.
|
66
|
+
|
67
|
+
* Support for MongoDB's $and operator is now available in the form of:
|
68
|
+
`Criteria#all_of(*args)` where args is multiple hash expressions.
|
69
|
+
|
70
|
+
* \#1250, \#1058 Embedded documents now can have their callbacks fired on a parent
|
71
|
+
save by setting `:cascade_callbacks => true` on the relation.
|
72
|
+
(pyromanic, Paul Rosania, Jak Charlton)
|
73
|
+
|
74
|
+
### Major Changes
|
75
|
+
|
76
|
+
* Mongoid now depends on Active Model 3.1 and higher.
|
77
|
+
|
78
|
+
* Mongoid now depends on the Mongo Ruby Driver 1.4 and higher.
|
79
|
+
|
80
|
+
* Mongoid requires MongoDB 2.0.0 and higher.
|
81
|
+
|
82
|
+
### Resolved Issues
|
83
|
+
|
84
|
+
* \#1308 Fixed scoping of HABTM finds.
|
85
|
+
|
86
|
+
* \#1300 Namespaced models should handle recursive embedding properly.
|
87
|
+
|
88
|
+
* \#1299 Self referenced documents with versioning no longer fail when inverse_of
|
89
|
+
is not defined on all relations.
|
90
|
+
|
91
|
+
* \#1296 Renamed internal building method to _building.
|
92
|
+
|
93
|
+
* \#1288, \#1289 _id and updated_at should not be part of versioned attributes.
|
94
|
+
|
95
|
+
* \#1273 Mongoid.preload_models now checks if preload configuration option is set,
|
96
|
+
where Mongoid.load_models always loads everything. (Ryan McGeary)
|
97
|
+
|
98
|
+
* \#1244 Has one relations now adhere to default dependant behaviour.
|
99
|
+
|
100
|
+
* \#1225 Fixed delayed persistence of embedded documents via $set.
|
101
|
+
|
102
|
+
* \#1166 Don't load config in Railtie if no env variables defined. (Terence Lee)
|
103
|
+
|
104
|
+
* \#1052 `alias_attribute` now works again as expected.
|
105
|
+
|
106
|
+
* \#939 Apply default attributes when upcasting via #becomes. (Christos Pappas)
|
107
|
+
|
108
|
+
* \#932 Fixed casting of integer fields with leading zeros.
|
109
|
+
|
110
|
+
* \#948 Reset version number on clone if versions existed.
|
111
|
+
|
112
|
+
* \#763 Don't merge $in criteria arrays when chaining named scopes.
|
113
|
+
|
114
|
+
* \#730 Existing models that have relations added post persistence of originals
|
115
|
+
can now have new relations added with no migrations.
|
116
|
+
|
117
|
+
* \#726 Embedded documents with compound keys not validate uniqueness correctly.
|
118
|
+
|
119
|
+
* \#582 Cyclic non embedded relations now validate uniqueness correctly.
|
120
|
+
|
121
|
+
* \#484 Validates uniqueness with multiple scopes of all types now work properly.
|
122
|
+
|
123
|
+
* Deleting versions created with `Mongoid::Versioning` no longer fires off
|
124
|
+
dependent cascading on relations.
|
125
|
+
|
126
|
+
## 2.2.3
|
127
|
+
|
128
|
+
* \#1295 Fixed having multiple includes only execute the eager loading of the first.
|
129
|
+
|
130
|
+
* \#1225 Fixed delayed persistence of embedded documents via $set.
|
131
|
+
|
132
|
+
* \#1002 Fix BSON object id conversion to check if legal first.
|
133
|
+
|
134
|
+
## 2.2.2
|
135
|
+
|
136
|
+
* This release removes the restriction of a dependency on 1.3.x of the mongo
|
137
|
+
ruby driver. Users may now use 1.3.x through 1.4.x.
|
4
138
|
|
5
139
|
## 2.2.1
|
6
140
|
|
data/lib/mongoid/atomic.rb
CHANGED
@@ -163,6 +163,18 @@ module Mongoid #:nodoc:
|
|
163
163
|
@atomic_unsets ||= []
|
164
164
|
end
|
165
165
|
|
166
|
+
# Get all the atomic sets that have had their saves delayed.
|
167
|
+
#
|
168
|
+
# @example Get the delayed atomic sets.
|
169
|
+
# person.delayed_atomic_sets
|
170
|
+
#
|
171
|
+
# @return [ Hash ] The delayed $sets.
|
172
|
+
#
|
173
|
+
# @since 2.3.0
|
174
|
+
def delayed_atomic_sets
|
175
|
+
@delayed_atomic_sets ||= {}
|
176
|
+
end
|
177
|
+
|
166
178
|
private
|
167
179
|
|
168
180
|
# Get the atomic paths utility for this document.
|
@@ -190,6 +202,7 @@ module Mongoid #:nodoc:
|
|
190
202
|
mods.unset(doc.atomic_unsets)
|
191
203
|
mods.pull(doc.atomic_pulls)
|
192
204
|
mods.set(doc.atomic_sets)
|
205
|
+
mods.set(doc.delayed_atomic_sets)
|
193
206
|
mods.push(doc.atomic_pushes)
|
194
207
|
end
|
195
208
|
end
|
data/lib/mongoid/dirty.rb
CHANGED
@@ -38,7 +38,7 @@ module Mongoid #:nodoc:
|
|
38
38
|
if args.unconvertable_to_bson?
|
39
39
|
args
|
40
40
|
else
|
41
|
-
BSON::ObjectId.from_string(args)
|
41
|
+
BSON::ObjectId.legal?(args) ? BSON::ObjectId.from_string(args) : args
|
42
42
|
end
|
43
43
|
when ::Array
|
44
44
|
args.delete_if { |arg| arg.blank? } if reject_blank
|
@@ -47,9 +47,7 @@ module Mongoid #:nodoc:
|
|
47
47
|
args.tap do |hash|
|
48
48
|
hash.each_pair do |key, value|
|
49
49
|
next unless klass.object_id_field?(key)
|
50
|
-
|
51
|
-
hash[key] = convert(klass, value, reject_blank)
|
52
|
-
rescue BSON::InvalidObjectId; end
|
50
|
+
hash[key] = convert(klass, value, reject_blank)
|
53
51
|
end
|
54
52
|
end
|
55
53
|
else
|
@@ -242,6 +242,9 @@ module Mongoid # :nodoc:
|
|
242
242
|
replacement = Many.builder(metadata, replacement).build
|
243
243
|
end
|
244
244
|
proxy.target = replacement.compact
|
245
|
+
if assigning?
|
246
|
+
base.delayed_atomic_sets[metadata.name.to_s] = proxy.as_document
|
247
|
+
end
|
245
248
|
proxy.target.each_with_index do |doc, index|
|
246
249
|
integrate(doc)
|
247
250
|
doc._index = index
|
@@ -189,10 +189,7 @@ module Mongoid # :nodoc:
|
|
189
189
|
#
|
190
190
|
# @since 2.2.0
|
191
191
|
def eager_load(criteria)
|
192
|
-
relation.eager_load(
|
193
|
-
self,
|
194
|
-
criteria.clone.tap { |crit| crit.inclusions.clear }
|
195
|
-
)
|
192
|
+
relation.eager_load(self, criteria.clone)
|
196
193
|
end
|
197
194
|
|
198
195
|
# Will determine if the relation is an embedded one or not. Currently
|
data/lib/mongoid/state.rb
CHANGED
@@ -71,7 +71,10 @@ module Mongoid #:nodoc:
|
|
71
71
|
#
|
72
72
|
# @return [ true, false ] Is the document new and embedded?
|
73
73
|
def pushable?
|
74
|
-
new? &&
|
74
|
+
new? &&
|
75
|
+
embedded_many? &&
|
76
|
+
_parent.persisted? &&
|
77
|
+
!_parent.delayed_atomic_sets[atomic_path]
|
75
78
|
end
|
76
79
|
|
77
80
|
# Determine if the document can be set.
|
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.2.
|
4
|
+
version: 2.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
|
-
requirement: &
|
16
|
+
requirement: &70191203667940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70191203667940
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tzinfo
|
27
|
-
requirement: &
|
27
|
+
requirement: &70191203666840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.3.22
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70191203666840
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mongo
|
38
|
-
requirement: &
|
38
|
+
requirement: &70191203665380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.3'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70191203665380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &70191203663940 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 3.5.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70191203663940
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bson_ext
|
60
|
-
requirement: &
|
60
|
+
requirement: &70191203662020 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.3'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70191203662020
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
|
-
requirement: &
|
71
|
+
requirement: &70191203660340 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.9.12
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70191203660340
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70191203659100 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '2.6'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70191203659100
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: watchr
|
93
|
-
requirement: &
|
93
|
+
requirement: &70191203658200 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0.6'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70191203658200
|
102
102
|
description: Mongoid is an ODM (Object Document Mapper) Framework for MongoDB, written
|
103
103
|
in Ruby.
|
104
104
|
email:
|
@@ -385,7 +385,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
385
385
|
version: '0'
|
386
386
|
segments:
|
387
387
|
- 0
|
388
|
-
hash:
|
388
|
+
hash: 598136195800288460
|
389
389
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
390
390
|
none: false
|
391
391
|
requirements:
|