mongoid 2.2.3 → 2.2.4
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 +110 -1
- data/lib/mongoid/criteria.rb +10 -5
- data/lib/mongoid/extensions/object/checks.rb +1 -4
- data/lib/mongoid/extensions/string/inflections.rb +2 -2
- data/lib/mongoid/named_scope.rb +13 -3
- data/lib/mongoid/relations/metadata.rb +13 -0
- data/lib/mongoid/relations/referenced/many.rb +1 -1
- data/lib/mongoid/relations/referenced/many_to_many.rb +3 -1
- data/lib/mongoid/relations/synchronization.rb +4 -2
- data/lib/mongoid/validations.rb +2 -0
- data/lib/mongoid/version.rb +1 -1
- metadata +19 -19
data/CHANGELOG.md
CHANGED
@@ -5,13 +5,87 @@ For instructions on upgrading to newer versions, visit
|
|
5
5
|
|
6
6
|
## 2.4.0 \[ In Development \] \[ Branch: master \]
|
7
7
|
|
8
|
+
### New Features
|
9
|
+
|
8
10
|
* Ranges can now be passed to #where criteria to create a $gte/$lte query under the
|
9
11
|
covers. `Person.where(dob: start_date...end_date)`
|
10
12
|
|
11
|
-
|
13
|
+
### Resolved Issues
|
14
|
+
|
15
|
+
* \#1333 Fixed errors with custom types that exist in namespaces. (Peter Gumeson)
|
16
|
+
|
17
|
+
## 2.3.4 \[ In Development \] \[ Branch: 2.3.0-stable \]
|
18
|
+
|
19
|
+
## 2.3.3
|
20
|
+
|
21
|
+
### Resolved Issues
|
22
|
+
|
23
|
+
* \#1386 Lowered mongo/bson dependency to 1.3
|
24
|
+
|
25
|
+
* \#1377 Fix aggregation functions to properly handle nil or indefined values.
|
26
|
+
(Maxime Garcia)
|
27
|
+
|
28
|
+
* \#1373 Warn if a scope overrides another scope.
|
29
|
+
|
30
|
+
* \#1372 Never persist when binding inside of a read attribute for validation.
|
31
|
+
|
32
|
+
* \#1364 Fixed reloading of documents with non bson object id ids.
|
33
|
+
|
34
|
+
* \#1360 Fixed performance of Mongoid's observer instantiation by hooking into
|
35
|
+
Active Support's load hooks, a la AR.
|
36
|
+
|
37
|
+
* \#1358 Fixed type error on many to many synchronization when inverse_of is
|
38
|
+
set to nil.
|
39
|
+
|
40
|
+
* \#1356 $in criteria can now be chained to non-complex criteria on the same
|
41
|
+
key without error.
|
42
|
+
|
43
|
+
* \#1350, \#1351 Fixed errors in the string conversions of double quotes and
|
44
|
+
tilde when paramterizing keys.
|
45
|
+
|
46
|
+
* \#1349 Mongoid documents should not blow up when including Enumerable.
|
47
|
+
(Jonas Nicklas)
|
48
|
+
|
49
|
+
## 2.3.2
|
50
|
+
|
51
|
+
### Resolved Issues
|
52
|
+
|
53
|
+
* \#1347 Fix embedded matchers when provided a hash value that does not have a
|
54
|
+
modifier as a key.
|
55
|
+
|
56
|
+
* \#1346 Dup default sorting criteria when calling first/last on a criteria.
|
57
|
+
|
58
|
+
* \#1343 When passing no arguments to `Criteria#all_of` return all documents.
|
59
|
+
(Chris Leishman)
|
60
|
+
|
61
|
+
* \#1339 Ensure destroy callbacks are run on cascadable children when deleting via
|
62
|
+
nested attributes.
|
63
|
+
|
64
|
+
* \#1324 Setting `inverse_of: nil` on a many-to-many referencing the same class
|
65
|
+
returns nil for the inverse foreign key.
|
66
|
+
|
67
|
+
* \#1323 Allow both strings and symbols as ids in the attributes array for
|
68
|
+
nested attributes. (Michael Wood)
|
69
|
+
|
70
|
+
* \#1312 Setting a logger on the config now accepts anything that quacks like a
|
71
|
+
logger.
|
72
|
+
|
73
|
+
* \#1297 Don't hit the database when accessing relations if the base is new.
|
74
|
+
|
75
|
+
* \#1239 Allow appending of referenced relations in create blocks, post default set.
|
76
|
+
|
77
|
+
* \#1236 Ensure all models are loaded in rake tasks, so even in threadsafe mode
|
78
|
+
all indexes can be created.
|
79
|
+
|
80
|
+
* \#736 Calling #reload on embedded documents now works properly.
|
81
|
+
|
82
|
+
## 2.3.1
|
12
83
|
|
13
84
|
### Resolved Issues
|
14
85
|
|
86
|
+
* \#1338 Calling #find on a scope or relation checks that the document in the
|
87
|
+
identity map actually matches other scope parameters.
|
88
|
+
|
15
89
|
* \#1321 HABTM no longer allows duplicate entries or keys, instead of the previous
|
16
90
|
inconsistencies.
|
17
91
|
|
@@ -22,17 +96,31 @@ For instructions on upgrading to newer versions, visit
|
|
22
96
|
|
23
97
|
* \#1311 Fix issue with custom field serialization inheriting from hash.
|
24
98
|
|
99
|
+
* \#1310 The referenced many enumerable target no longer duplicates loaded and
|
100
|
+
added documents when the identity map is enabled.
|
101
|
+
|
25
102
|
* \#1295 Fixed having multiple includes only execute the eager loading of the first.
|
26
103
|
|
27
104
|
* \#1287 Fixed max versions limitation with versioning.
|
28
105
|
|
29
106
|
* \#1277 attribute_will_change! properly flags the attribute even if no change occured.
|
30
107
|
|
108
|
+
* \#1063 Paranoid documents properly run destroy callbacks on soft destroy.
|
109
|
+
|
110
|
+
* \#1061 Raise `Mongoid::Errors::InvalidTime` when time serialization fails.
|
111
|
+
|
112
|
+
* \#1002 Check for legal bson ids when attempting conversion.
|
113
|
+
|
31
114
|
* \#920 Allow relations to be named target.
|
32
115
|
|
116
|
+
* \#905 Return normalized class name in metadata if string was defined with a
|
117
|
+
prefixed ::.
|
118
|
+
|
33
119
|
* \#861 accepts_nested_attributes_for is no longer needed to set embedded documents
|
34
120
|
via a hash or array of hashes directly.
|
35
121
|
|
122
|
+
* \#857 Fixed cascading of dependent relations when base document is paranoid.
|
123
|
+
|
36
124
|
* \#768 Fixed class_attribute definitions module wide.
|
37
125
|
|
38
126
|
* \#408 Embedded documents can now be soft deleted via `Mongoid::Paranoia`.
|
@@ -123,6 +211,27 @@ For instructions on upgrading to newer versions, visit
|
|
123
211
|
* Deleting versions created with `Mongoid::Versioning` no longer fires off
|
124
212
|
dependent cascading on relations.
|
125
213
|
|
214
|
+
## 2.2.4
|
215
|
+
|
216
|
+
* \#1377 Fix aggregation functions to properly handle nil or indefined values.
|
217
|
+
(Maxime Garcia)
|
218
|
+
|
219
|
+
* \#1373 Warn if a scope overrides another scope.
|
220
|
+
|
221
|
+
* \#1372 Never persist when binding inside of a read attribute for validation.
|
222
|
+
|
223
|
+
* \#1358 Fixed type error on many to many synchronization when inverse_of is
|
224
|
+
set to nil.
|
225
|
+
|
226
|
+
* \#1356 $in criteria can now be chained to non-complex criteria on the same
|
227
|
+
key without error.
|
228
|
+
|
229
|
+
* \#1350, \#1351 Fixed errors in the string conversions of double quotes and
|
230
|
+
tilde when paramterizing keys.
|
231
|
+
|
232
|
+
* \#1349 Mongoid documents should not blow up when including Enumerable.
|
233
|
+
(Jonas Nicklas)
|
234
|
+
|
126
235
|
## 2.2.3
|
127
236
|
|
128
237
|
* \#1295 Fixed having multiple includes only execute the eager loading of the first.
|
data/lib/mongoid/criteria.rb
CHANGED
@@ -383,14 +383,19 @@ module Mongoid #:nodoc:
|
|
383
383
|
clone.tap do |crit|
|
384
384
|
converted = BSON::ObjectId.convert(klass, attributes || {})
|
385
385
|
converted.each_pair do |key, value|
|
386
|
-
|
386
|
+
existing = crit.selector[key]
|
387
|
+
unless existing
|
387
388
|
crit.selector[key] = { operator => value }
|
388
389
|
else
|
389
|
-
if
|
390
|
-
|
391
|
-
|
390
|
+
if existing.respond_to?(:merge)
|
391
|
+
if existing.has_key?(operator)
|
392
|
+
new_value = existing.values.first.send(combine, value)
|
393
|
+
crit.selector[key] = { operator => new_value }
|
394
|
+
else
|
395
|
+
crit.selector[key][operator] = value
|
396
|
+
end
|
392
397
|
else
|
393
|
-
crit.selector[key]
|
398
|
+
crit.selector[key] = { operator => value }
|
394
399
|
end
|
395
400
|
end
|
396
401
|
end
|
@@ -14,9 +14,6 @@ module Mongoid #:nodoc:
|
|
14
14
|
# @example Is the array vacant?
|
15
15
|
# [].vacant?
|
16
16
|
#
|
17
|
-
# @example Is the hash vacant?
|
18
|
-
# {}.vacant?
|
19
|
-
#
|
20
17
|
# @example Is the object vacant?
|
21
18
|
# nil.vacant?
|
22
19
|
#
|
@@ -24,7 +21,7 @@ module Mongoid #:nodoc:
|
|
24
21
|
#
|
25
22
|
# @since 2.0.2
|
26
23
|
def _vacant?
|
27
|
-
is_a?(::
|
24
|
+
is_a?(::Array) || is_a?(::String) ? empty? : !self
|
28
25
|
end
|
29
26
|
end
|
30
27
|
end
|
@@ -18,7 +18,7 @@ module Mongoid #:nodoc:
|
|
18
18
|
CHAR_CONV = {
|
19
19
|
" " => "-",
|
20
20
|
"!" => "-excl-",
|
21
|
-
"\"" => "-
|
21
|
+
"\"" => "-dblquo-",
|
22
22
|
"#" => "-hash-",
|
23
23
|
"$" => "-dol-",
|
24
24
|
"%" => "-perc-",
|
@@ -48,7 +48,7 @@ module Mongoid #:nodoc:
|
|
48
48
|
"{" => "-ocurly-",
|
49
49
|
"|" => "-pipe-",
|
50
50
|
"}" => "-clcurly-",
|
51
|
-
"~" => "-
|
51
|
+
"~" => "-tilde-"
|
52
52
|
}
|
53
53
|
|
54
54
|
REVERSALS = {
|
data/lib/mongoid/named_scope.rb
CHANGED
@@ -125,10 +125,20 @@ module Mongoid #:nodoc:
|
|
125
125
|
|
126
126
|
protected
|
127
127
|
|
128
|
+
# Warns if overriding another scope or method.
|
129
|
+
#
|
130
|
+
# @example Warn if name exists.
|
131
|
+
# Model.valid_scope_name?("test")
|
132
|
+
#
|
133
|
+
# @param [ String, Symbol ] name The name of the scope.
|
128
134
|
def valid_scope_name?(name)
|
129
|
-
if
|
130
|
-
Mongoid.logger
|
131
|
-
|
135
|
+
if scopes[name] || respond_to?(name, true)
|
136
|
+
if Mongoid.logger
|
137
|
+
Mongoid.logger.warn(
|
138
|
+
"Creating scope :#{name}. " +
|
139
|
+
"Overwriting existing method #{self.name}.#{name}."
|
140
|
+
)
|
141
|
+
end
|
132
142
|
end
|
133
143
|
end
|
134
144
|
end
|
@@ -229,6 +229,19 @@ module Mongoid # :nodoc:
|
|
229
229
|
!!extension
|
230
230
|
end
|
231
231
|
|
232
|
+
# Does this metadata have a forced nil inverse_of defined. (Used in many
|
233
|
+
# to manies)
|
234
|
+
#
|
235
|
+
# @example Is this a forced nil inverse?
|
236
|
+
# metadata.forced_nil_inverse?
|
237
|
+
#
|
238
|
+
# @return [ true, false ] If inverse_of has been explicitly set to nil.
|
239
|
+
#
|
240
|
+
# @since 2.3.3
|
241
|
+
def forced_nil_inverse?
|
242
|
+
has_key?(:inverse_of) && inverse_of.nil?
|
243
|
+
end
|
244
|
+
|
232
245
|
# Handles all the logic for figuring out what the foreign_key is for each
|
233
246
|
# relations query. The logic is as follows:
|
234
247
|
#
|
@@ -142,7 +142,9 @@ module Mongoid # :nodoc:
|
|
142
142
|
#
|
143
143
|
# @since 2.0.0.rc.1
|
144
144
|
def nullify
|
145
|
-
|
145
|
+
unless metadata.forced_nil_inverse?
|
146
|
+
criteria.pull(metadata.inverse_foreign_key, base.id)
|
147
|
+
end
|
146
148
|
if persistable?
|
147
149
|
base.set(
|
148
150
|
metadata.foreign_key,
|
data/lib/mongoid/validations.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.2.
|
4
|
+
version: 2.2.4
|
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-10-
|
12
|
+
date: 2011-10-31 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
16
|
-
requirement: &
|
16
|
+
requirement: &70285743605420 !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: *70285743605420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tzinfo
|
27
|
-
requirement: &
|
27
|
+
requirement: &70285743604460 !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: *70285743604460
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mongo
|
38
|
-
requirement: &
|
38
|
+
requirement: &70285743603500 !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: *70285743603500
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &70285743602700 !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: *70285743602700
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bson_ext
|
60
|
-
requirement: &
|
60
|
+
requirement: &70285743601320 !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: *70285743601320
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
|
-
requirement: &
|
71
|
+
requirement: &70285743600280 !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: *70285743600280
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70285743588060 !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: *70285743588060
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: watchr
|
93
|
-
requirement: &
|
93
|
+
requirement: &70285743587280 !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: *70285743587280
|
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: 1180237711887586276
|
389
389
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
390
390
|
none: false
|
391
391
|
requirements:
|