mongoid 2.2.6 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/CHANGELOG.md +2 -858
  2. data/Rakefile +2 -5
  3. data/lib/mongoid.rb +1 -1
  4. data/lib/mongoid/attributes.rb +68 -18
  5. data/lib/mongoid/attributes/processing.rb +4 -3
  6. data/lib/mongoid/callbacks.rb +102 -0
  7. data/lib/mongoid/collection.rb +1 -1
  8. data/lib/mongoid/components.rb +2 -1
  9. data/lib/mongoid/contexts/enumerable.rb +0 -24
  10. data/lib/mongoid/contexts/mongo.rb +2 -2
  11. data/lib/mongoid/copyable.rb +3 -1
  12. data/lib/mongoid/criteria.rb +18 -10
  13. data/lib/mongoid/criterion/complex.rb +11 -0
  14. data/lib/mongoid/criterion/inclusion.rb +38 -7
  15. data/lib/mongoid/criterion/optional.rb +2 -7
  16. data/lib/mongoid/criterion/selector.rb +1 -0
  17. data/lib/mongoid/dirty.rb +19 -0
  18. data/lib/mongoid/document.rb +16 -12
  19. data/lib/mongoid/extensions/hash/criteria_helpers.rb +1 -1
  20. data/lib/mongoid/extensions/object/checks.rb +4 -1
  21. data/lib/mongoid/extensions/object_id/conversions.rb +4 -2
  22. data/lib/mongoid/extensions/string/inflections.rb +2 -2
  23. data/lib/mongoid/factory.rb +7 -2
  24. data/lib/mongoid/fields.rb +4 -10
  25. data/lib/mongoid/fields/serializable.rb +18 -2
  26. data/lib/mongoid/fields/serializable/integer.rb +17 -5
  27. data/lib/mongoid/fields/serializable/localized.rb +41 -0
  28. data/lib/mongoid/finders.rb +5 -4
  29. data/lib/mongoid/hierarchy.rb +87 -84
  30. data/lib/mongoid/identity.rb +4 -2
  31. data/lib/mongoid/keys.rb +2 -1
  32. data/lib/mongoid/logger.rb +1 -7
  33. data/lib/mongoid/matchers/and.rb +30 -0
  34. data/lib/mongoid/matchers/in.rb +1 -1
  35. data/lib/mongoid/matchers/nin.rb +1 -1
  36. data/lib/mongoid/matchers/strategies.rb +6 -4
  37. data/lib/mongoid/multi_parameter_attributes.rb +3 -2
  38. data/lib/mongoid/named_scope.rb +3 -13
  39. data/lib/mongoid/nested_attributes.rb +1 -1
  40. data/lib/mongoid/paranoia.rb +2 -3
  41. data/lib/mongoid/persistence.rb +9 -5
  42. data/lib/mongoid/persistence/atomic/operation.rb +1 -1
  43. data/lib/mongoid/persistence/deletion.rb +1 -1
  44. data/lib/mongoid/persistence/insertion.rb +1 -1
  45. data/lib/mongoid/persistence/modification.rb +1 -1
  46. data/lib/mongoid/railtie.rb +1 -1
  47. data/lib/mongoid/railties/database.rake +9 -1
  48. data/lib/mongoid/relations.rb +1 -0
  49. data/lib/mongoid/relations/accessors.rb +1 -1
  50. data/lib/mongoid/relations/builders.rb +6 -4
  51. data/lib/mongoid/relations/builders/referenced/many.rb +1 -23
  52. data/lib/mongoid/relations/builders/referenced/one.rb +1 -1
  53. data/lib/mongoid/relations/cascading.rb +5 -3
  54. data/lib/mongoid/relations/conversions.rb +35 -0
  55. data/lib/mongoid/relations/embedded/atomic.rb +3 -3
  56. data/lib/mongoid/relations/embedded/in.rb +1 -1
  57. data/lib/mongoid/relations/embedded/many.rb +16 -13
  58. data/lib/mongoid/relations/embedded/one.rb +3 -3
  59. data/lib/mongoid/relations/metadata.rb +19 -15
  60. data/lib/mongoid/relations/proxy.rb +4 -5
  61. data/lib/mongoid/relations/referenced/in.rb +1 -1
  62. data/lib/mongoid/relations/referenced/many.rb +12 -31
  63. data/lib/mongoid/relations/referenced/many_to_many.rb +4 -5
  64. data/lib/mongoid/relations/referenced/one.rb +6 -8
  65. data/lib/mongoid/relations/synchronization.rb +3 -5
  66. data/lib/mongoid/safety.rb +34 -4
  67. data/lib/mongoid/serialization.rb +20 -6
  68. data/lib/mongoid/threaded.rb +47 -0
  69. data/lib/mongoid/timestamps.rb +1 -0
  70. data/lib/mongoid/timestamps/created.rb +1 -8
  71. data/lib/mongoid/timestamps/timeless.rb +50 -0
  72. data/lib/mongoid/timestamps/updated.rb +2 -9
  73. data/lib/mongoid/validations.rb +0 -2
  74. data/lib/mongoid/validations/associated.rb +1 -2
  75. data/lib/mongoid/validations/uniqueness.rb +89 -36
  76. data/lib/mongoid/version.rb +1 -1
  77. data/lib/mongoid/versioning.rb +5 -6
  78. data/lib/rails/generators/mongoid_generator.rb +1 -1
  79. data/lib/rails/mongoid.rb +14 -5
  80. metadata +27 -23
@@ -1,830 +1,13 @@
1
1
  # Overview
2
2
 
3
- For instructions on upgrading to newer versions, visit
4
- [mongoid.org](http://mongoid.org/docs/upgrading.html).
5
-
6
- ## 3.0.0 (branch: master)
7
-
8
- ### New Features
9
-
10
- * \#1741 Mongoid now provides a rake task to force remove indexes for
11
- environments where Mongoid manages the index definitions and the
12
- removal should be automated. (Hans Hasselberg)
13
-
14
- rake db:force_remove_indexes
15
- rake db:mongoid:force_remove_indexes
16
-
17
- * \#1726 `Mongoid.load!` now accepts an optional second argument for the
18
- environment to load. This takes precedence over any environment variable
19
- that is set if provided.
20
-
21
- Mongoid.load!("/path/to/mongoid.yml", :development)
22
-
23
- * \#1724 Mongoid now supports regex fields.
24
-
25
- class Rule
26
- include Mongoid::Document
27
- field :pattern, type: Regexp, default: /[^abc]/
28
- end
29
-
30
- * \#1714/\#1706 Added better logging on index creation. (Hans Hasselberg)
31
-
32
- When an index is present on a root document model:
33
-
34
- Creating indexes on: Model for: name, dob.
35
-
36
- When an index is defined on an embedded model:
37
-
38
- Index ignored on: Address, please define in the root model.
39
-
40
- When no index is defined, nothing is logged, and if a bad index is
41
- defined an error is raised.
42
-
43
- * \#1710 For cases when you don't want Mongoid to auto-protect the id
44
- and type attributes, you can set a configuration option to turn this
45
- off.
46
-
47
- Mongoid.protect_sensitive_fields = false
48
-
49
- * \#1685 Belongs to relations now have build_ and create_ methods.
50
-
51
- class Comment
52
- include Mongoid::Document
53
- belongs_to :user
54
- end
55
-
56
- comment = Comment.new
57
- comment.build_user # Build a new user object
58
- comment.create_user # Create a new user object
59
-
60
- * \#1684 Raise a `Mongoid::Errors::InverseNotFound` when attempting to
61
- set a child on a relation without the proper inverse_of definitions
62
- due to Mongoid not being able to determine it.
63
-
64
- class Lush
65
- include Mongoid::Document
66
- embeds_one :whiskey, class_name: "Drink"
67
- end
68
-
69
- class Drink
70
- include Mongoid::Document
71
- embedded_in :alcoholic, class_name: "Lush"
72
- end
73
-
74
- lush = Lush.new
75
- lush.whiskey = Drink.new # raises an InverseNotFound error.
76
-
77
- * \#1680 Polymorphic relations now use `*_type` keys in lookup queries.
78
-
79
- class User
80
- include Mongoid::Document
81
- has_many :comments, as: :commentable
82
- end
83
-
84
- class Comment
85
- include Mongoid::Document
86
- belongs_to :commentable, polymorphic: true
87
- end
88
-
89
- user = User.find(id)
90
- user.comments # Uses user.id and type "User" in the query.
91
-
92
- * \#1677 Support for parent separable polymorphic relations to the same
93
- parent class is now available. This only works if set from the parent
94
- side in order to know which relation the children belong to.
95
- (Douwe Maan)
96
-
97
- class Face
98
- include Mongoid::Document
99
- has_one :left_eye, class_name: "Eye", as: :visible
100
- has_one :right_eye, class_name: "Eye", as: :visible
101
- end
102
-
103
- class Eye
104
- include Mongoid::Document
105
- belongs_to :visible, polymorphic: true
106
- end
107
-
108
- face = Face.new
109
- right_eye = Eye.new
110
- left_eye = Eye.new
111
- face.right_eye = right_eye
112
- face.left_eye = left_eye
113
- right_eye.visible = face # Will raise an error.
114
-
115
- * \#1650 Objects that respond to \#to_criteria can now be merged into
116
- existing criteria objects.
117
-
118
- class Filter
119
- def to_criteria
120
- # return a Criteria object.
121
- end
122
- end
123
-
124
- criteria = Person.where(title: "Sir")
125
- criteria.merge(filter)
126
-
127
- * \#1635 All exceptions now provide more comprehensive errors, including
128
- the problem that occured, a detail summary of why it happened, and
129
- potential resolutions. Example:
130
-
131
- (Mongoid::Errors::DocumentNotFound)
132
- Problem:
133
- Document not found for class Town with
134
- id(s) [BSON::ObjectId('4f35781b8ad54812e1000001')].
135
- Summary:
136
- When calling Town.find with an id or array of ids,
137
- each parameter must match a document in the database
138
- or this error will be raised.
139
- Resolution:
140
- Search for an id that is in the database or set the
141
- Mongoid.raise_not_found_error configuration option to
142
- false, which will cause a nil to be returned instead
143
- of raising this error.
144
-
145
- * \#1616 `Model.find_by` added which takes a hash of arugments to search
146
- for in the database. If no single document is returned a DocumentNotFound
147
- error is raised. (Piotr Jakubowski)
148
-
149
- Band.find_by(name: "Depeche Mode")
150
-
151
- * \#1477 Mongoid now automatically protects the id and type attributes
152
- from mass assignment. You can override this (not recommended) by redefining
153
- them as accessible.
154
-
155
- class Band
156
- include Mongoid::Document
157
- attr_accessible :id, :_id, :_type
158
- end
159
-
160
- * \#1459 The identity map can be disabled now for specific code execution
161
- by passing options to the unit of work.
162
-
163
- Mongoid.unit_of_work(disable: :all) do
164
- # Disables the identity map on all threads for the block.
165
- end
166
-
167
- Mongoid.unit_of_work(disable: :current) do
168
- # Disables the identity map on the current thread for the block.
169
- end
170
-
171
- Mongoid.unit_of_work do
172
- # Business as usual.
173
- end
174
-
175
- * \#1355 Associations now can have safety options provided to them on single
176
- document persistence operations.
177
-
178
- band.albums.safely.push(album)
179
- band.albums.safely.create(name: "Smiths")
180
-
181
- album.safely.create_producer(name: "Flood")
182
-
183
- * \#1348 Eager loading is now supported on many-to-many relations.
184
-
185
- * \#1292 Remove attribute now unsets the attribute when the document is
186
- saved instead of setting to nil.
187
-
188
- band = Band.find(id)
189
- band.remove_attribute(:label) # Uses $unset when the document is saved.
190
-
191
- * \#1212 Embedded documents can now be popped off a relation with persistence.
192
-
193
- band.albums.pop # Pop 1 document and persist the removal.
194
- band.albums.pop(3) # Pop 3 documents and persist the removal.
195
-
196
- * \#1081 Mongoid indexes both id and type as a compound index when providing
197
- `index: true` to a polymorphic belongs_to.
198
-
199
- class Comment
200
- include Mongoid::Document
201
-
202
- # Indexes commentable_id and commentable_type as a compound index.
203
- belongs_to :commentable, polymorphic: true, index: true
204
- end
205
-
206
- * \#1053 Raise a `Mongoid::Errors::UnknownAttribute` instead of no method
207
- when attempting to set a field that is not defined and allow dynamic
208
- fields is false. (Cyril Mougel)
209
-
210
- Mongoid.allow_dynamic_fields = false
211
-
212
- class Person
213
- include Mongoid::Document
214
- field :title, type: String
215
- end
216
-
217
- Person.new.age = 50 # raises the UnknownAttribute error.
218
-
219
- * \#772 Fields can now be flagged as readonly, which will only let their
220
- values be set when the document is new.
221
-
222
- class Band
223
- include Mongoid::Document
224
- field :name, type: String
225
- field :genre, type: String
226
-
227
- attr_readonly :name, :genre
228
- end
229
-
230
- Readonly values are ignored when attempting to set them on persisted
231
- documents, with the exception of update_attribute and remove_attribute,
232
- where errors will get raised.
233
-
234
- band = Band.create(name: "Depeche Mode")
235
- band.update_attribute(:name, "Smiths") # Raises ReadonlyAttribute error.
236
- band.remove_attribute(:name) # Raises ReadonlyAttribute error.
237
-
238
-
239
- ### Major Changes
240
-
241
- * `Model.defaults` no longer exists. You may get all defaults with a
242
- combination of `Model.pre_processed_defaults` and
243
- `Model.post_processed_defaults`
244
-
245
- * `Model.identity` and `Model.key` have been removed. For custom ids,
246
- users must now override the _id field.
247
-
248
- When the default value is a proc, the default is applied *after* all
249
- other attributes are set.
250
-
251
- class Band
252
- include Mongoid::Document
253
- field :_id, type: String, default: ->{ name }
254
- end
255
-
256
- To have the default applied *before* other attributes, set `:pre_processed`
257
- to true.
258
-
259
- class Band
260
- include Mongoid::Document
261
- field :_id,
262
- type: String,
263
- pre_processed: true,
264
- default: ->{ BSON::ObjectId.new.to_s }
265
- end
266
-
267
- * Custom application exceptions in various languages has been removed,
268
- along with the `Mongoid.add_language` feature.
269
-
270
- * Mongoid no longer supports 1.8 syntax. 1.9.x or other vms running in
271
- 1.9 mode is now only supported.
272
-
273
- * \#1734 When searching for documents via `Model.find` with multiple ids,
274
- Mongoid will raise an error if not *all* ids are found, and tell you
275
- what the missing ones were. Previously the error only got raised if
276
- nothing was returned.
277
-
278
- * \#1484 `Model#has_attribute?` now behaves the same as Active Record.
279
-
280
- * \#1471 Mongoid no longer strips any level of precision off of times.
281
-
282
- * \#1475 Active support's time zone is now used by default in time
283
- serialization if it is defined.
284
-
285
- * \#1342 `Model.find` and `model.relation.find` now only take a single or
286
- multiple ids. The first/last/all with a conditions hash has been removed.
287
-
288
- * \#1270 Relation macros have been changed to match their AR counterparts:
289
- only :has_one, :has_many, :has_and_belongs_to_many, and :belongs_to
290
- exist now.
291
-
292
- * \#1268 `Model#new?` has been removed, developers must now always use
293
- `Model#new_record?`.
294
-
295
- * \#933 `:field.size` has been renamed to `:field.count` in criteria for
296
- $size not to conflict with Symbol's size method.
297
-
298
- ### Resolved Issues
299
-
300
- * \#1718 Ensure consistency of #first/#last in relations - they now always
301
- match first/last in the database, but opts for in memory first.
302
-
303
- * \#1692/\#1376 `Model#updateattributes` and `Model#update_attributes!` now
304
- accept assignment options. (Hans Hasselberg)
305
-
306
- * \#1688/\#1207 Don't require namespacing when providing class name on
307
- relation macros inside the namespace. (Hans Hasselberg)
308
-
309
- * \#1665/\#1672 Expand complex criteria in nested criteria selectors, like
310
- \#matches. (Hans Hasselberg)
311
-
312
- * \#1335 Don't add id sorting criteria to first/last is there is already
313
- sorting options on the criteria.
314
-
315
- * \#1135 DateTimes now properly get time zones on derserialization.
316
-
317
- ## 2.4.5 (branch: 2.4.0-stable)
318
-
319
- ### Resolved Issues
320
-
321
- * \#1751 Mongoid's logger now responds to level for Ruby logging API
322
- compatibility.
323
-
324
- * \#1744/#1750 Sorting works now for localized fields in embedded documents
325
- using the criteria API. (Hans Hasselberg)
326
-
327
- * \#1746 Presence validation now shows which locales were empty for
328
- localized fields. (Cyril Mougel)
329
-
330
- * \#1727 Allow dot notation in embedded criteria to work on both embeds one
331
- and embeds many. (Lyle Underwood)
332
-
333
- * \#1723 Initialize callbacks should cascade through children without needing
334
- to determine if the child is changed.
335
-
336
- * \#1715 Serializable hashes are now consistent on inclusion of embedded
337
- documents per or post save.
338
-
339
- * \#1713 Fixing === checks when comparing a class with an instance of a
340
- subclass.
341
-
342
- * \#1495 Callbacks no longer get the 'super called outside of method` errors on
343
- busted 1.8.7 rubies.
344
-
345
- ## 2.4.4
346
-
347
- ### Resolved Issues
348
-
349
- * \#1705 Allow changing the order of many to many foreign keys.
350
-
351
- * \#1703 Updated at is now versioned again. (Lucas Souza)
352
-
353
- * \#1686 Set the base metadata on unbind as well as bind for belongs to
354
- relations.
355
-
356
- * \#1681 Attempt to create indexes for models without namespacing if the
357
- namespace does not exist for the subdirectory.
358
-
359
- * \#1676 Allow eager loading to work as a default scope.
360
-
361
- * \#1665/\#1672 Expand complex criteria in nested criteria selectors, like
362
- \#matches. (Hans Hasselberg)
363
-
364
- * \#1668 Ensure Mongoid logger exists before calling warn. (Rémy Coutable)
365
-
366
- * \#1661 Ensure uniqueness validation works on cloned documents.
367
-
368
- * \#1659 Clear delayed atomic sets when resetting the same embedded relation.
369
-
370
- * \#1656/\#1657 Don't hit database for uniqueness validation if BOTH scope
371
- and attribute hasn't changed. (priyaaank)
372
-
373
- * \#1205/\#1642 When limiting fields returned from the database via
374
- `Criteria#only` and `Criteria#without` and then subsequently saving
375
- the document. Default values no longer override excluded fields.
376
-
377
- ## 2.4.3
378
-
379
- ### Resolved Issues
380
-
381
- * \#1647 DateTime serialization when already in UTC does not convert to
382
- local time.
383
-
384
- * \#1641/\#1639 Mongoid.observer.disable :all now behaves as AR does.
385
-
386
- * \#1640 Update consumers should be tied to the name of the collection
387
- they persist to, not the name of the class.
388
-
389
- * \#1637/\#1636 Scopes no longer modify parent class scopes when subclassing.
390
- (Hans Hasselberg)
391
-
392
- * \#1629 $all and $in criteria on embedded many relations now properly
393
- handles regex searches and elements of varying length. (Douwe Maan)
394
-
395
- * \#1623/\#1634 Default scopes no longer break Mongoid::Versioning.
396
- (Hans Hasselberg)
397
-
398
- * \#1605 Fix regression of rescue responses, Rails 3.2
399
-
400
- ## 2.4.2
401
-
402
- ### Resolved Issues
403
-
404
- * \#1628 _type field can once again be included in serialization to json
405
- or xml as a global option with `include_type_for_serialization`.
406
- (Roman Shterenzon)
407
-
408
- * \#1627 Validating format now works properly with localized fields.
409
- (Douwe Maan)
410
-
411
- * \#1617 Relation proxy methods now show up in Mongoid's list of
412
- prohibited fields.
413
-
414
- * \#1615 Allow a single configuration of host and port for all spec runs,
415
- overridden by setting MONGOID_SPEC_HOST and MONGOID_SPEC_PORT env vars.
416
-
417
- * \#1610 When versioning paranoid documents and max version is set, hard
418
- delete old versions from the embedded relation.
419
-
420
- * \#1609 Allow connection retry during cursor iteration as well as all other
421
- operations.
422
-
423
- * \#1608 Guard against no method errors when passing ids in nested attributes
424
- and the documents do not exist.
425
-
426
- * \#1605 Remove deprecation warning on rescue responses, Rails 3.2
427
-
428
- * \#1602 Preserve structure of $and and $or queries when typecasting.
429
-
430
- * \#1600 Uniqueness validation no longer errors when provided a relation.
431
-
432
- * \#1599 Make sure enumerable targets yield to what is in memory first when
433
- performing #each, not always the unloaded first.
434
-
435
- * \#1597 Fix the ability to change the order of array fields with the same
436
- elements.
437
-
438
- * \#1590 Allow proper serialization of boolean values in criteria where the
439
- field is nested inside an array.
440
-
441
- ## 2.4.1
442
-
443
- ### Resolved Issues
444
-
445
- * \#1593 Arrays on embedded documents now properly atomically update when
446
- modified from original version.
447
-
448
- * \#1592 Don't swallow exceptions from index generation in the create_indexes
449
- rake task.
450
-
451
- * \#1589 Allow assignment of empty array to HABTM when no documents are yet
452
- loaded into memory.
453
-
454
- * \#1587 When a previous value for an array field was an explicit nil, it can
455
- now be reset atomically with new values.
456
-
457
- * \#1585 `Model#respond_to?` returns true now for the setter when allowing
458
- dynamic fields.
459
-
460
- * \#1582 Allow nil values to be set in arrays.
461
-
462
- * \#1580 Allow arrays to be set to nil post save, and not just empty.
463
-
464
- * \#1579 Don't call #to_a on individual set field elements in criterion.
465
-
466
- * \#1576 Don't hit database on uniqueness validation if the field getting
467
- validated has not changed.
468
-
469
- * \#1571 Aliased fields get all the dirty attribute methods and all getters and
470
- setters for both the original name and the alias. (Hans Hasselberg)
471
-
472
- * \#1568 Fallback to development environment with warning when no env configured.
473
-
474
- * \#1565 For fields and foreign keys with non-standard Ruby or database names,
475
- use define_method instead of class_eval for creating the accessors and
476
- dirty methods.
477
-
478
- * \#1557 Internal strategy class no longer conflicts with models.
479
-
480
- * \#1551 Parent documents now return `true` for `Model#changed?` if only child
481
- (embedded) documents have changed.
482
-
483
- * \#1547 Resetting persisted children from a parent save when new waits until post
484
- callbacks, mirroring update functionality.
485
-
486
- * \#1536 Eager loading now happens when calling `first` or `last` on a
487
- criteria if inclusions are specified.
488
-
489
- ## 2.4.0
490
-
491
- ### New Features
492
-
493
- * Ranges can now be passed to #where criteria to create a $gte/$lte query under the
494
- covers. `Person.where(dob: start_date...end_date)`
495
-
496
- * Custom serializable fields can now override #selection to provide
497
- customized serialization for criteria queries.
498
-
499
- * \#1544 Internals use `Array.wrap` instead of `to_a` now where possible.
500
-
501
- * \#1511 Presence validation now supports localized fields. (Tiago Rafael Godinho)
502
-
503
- * \#1506 `Model.set` will now accept false and nil values. (Marten Veldthuis)
504
-
505
- * \#1505 `Model.delete_all/destroy_all` now take either a :conditions hash or
506
- the attributes directly.
507
-
508
- * \#1504 `Model.recursively_embeds_many` now accepts a :cascade_callbacks
509
- option. (Pavel Pravosud)
510
-
511
- * \#1496 Mongoid now casts strings back to symbols for symbol fields that
512
- get saved as strings by another application.
513
-
514
- * \#1454, \#900 Associations now have an `after_build` callback that gets
515
- executed after `.build` or `build_` methods are called.
516
- (Jeffrey Jones, Ryan Townsend)
517
-
518
- * \#1451 Ranges can now be any range value, not just numbers. (aupajo)
519
-
520
- * \#1448 Localization is now used when sorting. (Hans Hasselberg)
521
-
522
- * \#1422 Mongoid raises an error at yaml load if no environment is found.
523
- (Tom Stuart)
524
-
525
- * \#1413 $not support added to criteria symbol methods. (Marc Weil)
526
-
527
- * \#1403 Added configuration option `scope_overwrite_exception` which defaults to
528
- false for raising an error when defining a named scope with the same name of
529
- an existing method. (Christoph Grabo)
530
-
531
- * \#1388 `model.add_to_set` now supports adding multiple values and performs an
532
- $addToSet with $each under the covers. (Christian Felder)
533
-
534
- * \#1387 Added `Model#cache_key` for use in Rails caching. (Seivan Heidari)
535
-
536
- * \#1380 Calling Model.find(id) will now properly convert to and from any type
537
- based on the type of the _id field.
538
-
539
- * \#1363 Added fallbacks and default support to localized fields, and added
540
- ability to get and set all translations at once.
541
-
542
- * \#1362 Aliased fields now properly typecast in criteria.
543
-
544
- * \#1337 Array fields, including HABTM many foreign keys now have smarter dirty
545
- checking and no longer perform a simple $set if the array has changed. If
546
- items have only been added to the array, it performs a $pushAll. If items
547
- have only been removed, it performs a $pullAll. If both additions and
548
- removals have occurred it performs a $set to avoid conflicting mods.
549
-
550
- ### Resolved Issues
551
-
552
- * Calling `Document#as_document` on a frozen document on Rubinius returns the
553
- attributes instead of nil.
554
-
555
- * \#1554 Split application of default values into proc/non-procs, where
556
- non-procs get executed immediately during instantiation, and procs get
557
- executed after all other values are set.
558
-
559
- * \#1553 Combinations of adding and removing values from an array use a $set
560
- on the current contents of the array, not the new values.
561
-
562
- * \#1546 Dirty changes should be returned in a hash with indifferent access.
563
-
564
- * \#1542 Eager loading now respects the options (ie skip, limit) provided to
565
- the criteria when fetch the associations.
566
-
567
- * \#1530 Don't duplicate added values to arrays via dirty tracking if the
568
- array is a foreign key field.
569
-
570
- * \#1529 Calling `unscoped` on relational associations now works properly.
571
-
572
- * \#1524 Allow access to relations in overridden field setters by pre-setting
573
- foreign key default values.
574
-
575
- * \#1523 Allow disabling of observers via `disable`. (Jonas Schneider)
576
-
577
- * \#1522 Fixed create indexes rake task for Rails 3.2. (Gray Manley)
578
-
579
- * \#1517 Fix Mongoid documents to properly work with RSpec's stub_model.
580
- (Tiago Rafael Godinho)
581
-
582
- * \#1516 Don't duplicate relational many documents on bind.
583
-
584
- * \#1515 Mongoid no longer attempts to serialize custom fields on complex
585
- criteria by default.
586
-
587
- * \#1503 Has many relation substitution now handles any kind of mix of existing
588
- and new docs.
589
-
590
- * \#1502 Nested attributes on embedded documents respects if the child is
591
- paranoid.
592
-
593
- * \#1497 Use provided message on failing uniqueness validation. (Justin Etheredge)
594
-
595
- * \#1491 Return nil when no default set on localized fields. (Tiago Rafael Godinho)
596
-
597
- * \#1483 Sending module includes at runtime which add new fields to a parent
598
- document, also have the fields added to subclasses.
599
-
600
- * \#1482 Applying new sorting options does not merge into previously
601
- chained criteria. (Gerad Suyderhoud)
602
-
603
- * \#1481 Fix invalid query when accessing many-to-many relations before
604
- defaults are set.
605
-
606
- * \#1480 Mongoid's internal serialized field types renamespaced to Internal in order
607
- to not conflict with ruby core classes in custom serializable types.
608
-
609
- * \#1479 Don't duplicate ids on many-to-many when using create or create!
610
-
611
- * \#1469 When extract_id returns nil, get the document out of the identity map
612
- by the criteria selector.
613
-
614
- * \#1467 Defining a field named metadata now properly raises an invalid field
615
- error.
616
-
617
- * \#1463 Batch insert consumers are now scoped to collection to avoid persistence
618
- of documents to other collections in callbacks going to the wrong place.
619
-
620
- * \#1462 Assigning has many relations via nested attribtues `*_attributes=` does
621
- not autosave the relation.
622
-
623
- * \#1461 Fixed serialization of foreign key fields in complex criteria not to
624
- escape the entire hash.
625
-
626
- * \#1458 Versioning no longer skips fields that have been protected from mass
627
- assignment.
628
-
629
- * \#1455, \#1456 Calling destroy on any document now temporarily marks it as
630
- flagged for destroy until the operation is complete. (Nader Akhnoukh)
631
-
632
- * \#1453 `Model#to_key` should return a value when the document is destroyed.
633
-
634
- * \#1449 New documents no longer get persisted when replaced on a has one as
635
- a side effect. (jasonsydes)
636
-
637
- * \#1439 embedded? should return true when relation defined as cyclic.
638
-
639
- * \#1433 Polymorphic nested attributes for embedded and relational 1-1 now
640
- update properly.
641
-
642
- * \#1426 Frozen documents can now be cloned. (aagrawal2001)
643
-
644
- * \#1382 Raise proper error when creating indexes via rake task if index
645
- definition is incorrect. (Mathieu Ravaux)
646
-
647
- * \#1381, \#1371 The identity map now functions properly with inherited
648
- documents. (Paul Canavese)
649
-
650
- * \#1370 Split concat on embedded arrays into its own method to handle the
651
- batch processing due to after callback run execution issues.
652
-
653
- * \#1366 Array and hash values now get deep copied for dirty tracking.
654
-
655
- * \#1359 Provide ability to not have default scope applied to all named
656
- scopes via using lambdas.
657
-
658
- * \#1333 Fixed errors with custom types that exist in namespaces. (Peter Gumeson)
659
-
660
- * \#1259 Default values are treated as dirty if they differ from the database
661
- state.
662
-
663
- * \#1255 Ensure embedded documents respect the defined default scope.
664
-
665
- ## 2.3.4
666
-
667
- * \#1445 Prevent duplicate documents in the loaded array on the target
668
- enumerable for relational associations.
669
-
670
- * \#1442 When using create_ methods for has one relations, the appropriate
671
- destructive methods now get called when replacing an existing document.
672
-
673
- * \#1431 Enumerable context should add to the loaded array post yield, so
674
- that methods like #any? that short circuit based on the value of the block
675
- dont falsely have extra documents.
676
-
677
- * \#1418 Documents being loaded from the database for revision purposes
678
- no longer get placed in the identity map.
679
-
680
- * \#1399 Allow conversion of strings to integers in foreign keys where the
681
- id is defined as an int.
682
-
683
- * \#1397 Don't add default sorting criteria on first if they sort criteria
684
- already exists.
685
-
686
- * \#1394 Fix exists? to work when count is greater than 1. (Nick Hoffman)
687
-
688
- * \#1392 Return 0 on aggregation functions where field is nonexistant.
689
-
690
- * \#1391 Uniqueness validation now works properly on embedded documents that are
691
- using primary key definitions.
692
-
693
- * \#1390 When _type field is lower case class camelize before constantizing.
694
-
695
- * \#1383 Fix cast on read for serializable fields that are subclassed.
696
-
697
- * \#1357 Delayed atomic sets from update_attributes on embedded documents
698
- multiple levels deep now properly persist.
699
-
700
- * \#1326 Ensure base document on HABTM gets its keys saved after saving a newly
701
- build child document.
702
-
703
- * \#1301 Don't overwrite base metadata on embedded in relations if already set.
704
-
705
- * \#1221 HABTM with inverse nil is allowed again on embedded documents.
706
-
707
- * \#1208 Don't auto-persist child documents via the setter when setting from
708
- an embedded_in.
709
-
710
- * \#791 Root document updates its timestamps when only embedded documents have
711
- changed.
712
-
713
- ## 2.3.3
714
-
715
- ### Resolved Issues
716
-
717
- * \#1386 Lowered mongo/bson dependency to 1.3
718
-
719
- * \#1377 Fix aggregation functions to properly handle nil or indefined values.
720
- (Maxime Garcia)
721
-
722
- * \#1373 Warn if a scope overrides another scope.
723
-
724
- * \#1372 Never persist when binding inside of a read attribute for validation.
725
-
726
- * \#1364 Fixed reloading of documents with non bson object id ids.
727
-
728
- * \#1360 Fixed performance of Mongoid's observer instantiation by hooking into
729
- Active Support's load hooks, a la AR.
730
-
731
- * \#1358 Fixed type error on many to many synchronization when inverse_of is
732
- set to nil.
733
-
734
- * \#1356 $in criteria can now be chained to non-complex criteria on the same
735
- key without error.
736
-
737
- * \#1350, \#1351 Fixed errors in the string conversions of double quotes and
738
- tilde when paramterizing keys.
739
-
740
- * \#1349 Mongoid documents should not blow up when including Enumerable.
741
- (Jonas Nicklas)
742
-
743
- ## 2.3.2
744
-
745
- ### Resolved Issues
746
-
747
- * \#1347 Fix embedded matchers when provided a hash value that does not have a
748
- modifier as a key.
749
-
750
- * \#1346 Dup default sorting criteria when calling first/last on a criteria.
751
-
752
- * \#1343 When passing no arguments to `Criteria#all_of` return all documents.
753
- (Chris Leishman)
754
-
755
- * \#1339 Ensure destroy callbacks are run on cascadable children when deleting via
756
- nested attributes.
757
-
758
- * \#1324 Setting `inverse_of: nil` on a many-to-many referencing the same class
759
- returns nil for the inverse foreign key.
760
-
761
- * \#1323 Allow both strings and symbols as ids in the attributes array for
762
- nested attributes. (Michael Wood)
763
-
764
- * \#1312 Setting a logger on the config now accepts anything that quacks like a
765
- logger.
766
-
767
- * \#1297 Don't hit the database when accessing relations if the base is new.
768
-
769
- * \#1239 Allow appending of referenced relations in create blocks, post default set.
770
-
771
- * \#1236 Ensure all models are loaded in rake tasks, so even in threadsafe mode
772
- all indexes can be created.
773
-
774
- * \#736 Calling #reload on embedded documents now works properly.
775
-
776
- ## 2.3.1
777
-
778
- ### Resolved Issues
779
-
780
- * \#1338 Calling #find on a scope or relation checks that the document in the
781
- identity map actually matches other scope parameters.
782
-
783
- * \#1321 HABTM no longer allows duplicate entries or keys, instead of the previous
784
- inconsistencies.
785
-
786
- * \#1320 Fixed errors in perf benchmark.
787
-
788
- * \#1316 Added a separate Rake task "db:mongoid:drop" so Mongoid and AR can coexist.
789
- (Daniel Vartanov)
790
-
791
- * \#1311 Fix issue with custom field serialization inheriting from hash.
792
-
793
- * \#1310 The referenced many enumerable target no longer duplicates loaded and
794
- added documents when the identity map is enabled.
795
-
796
- * \#1295 Fixed having multiple includes only execute the eager loading of the first.
797
-
798
- * \#1287 Fixed max versions limitation with versioning.
799
-
800
- * \#1277 attribute_will_change! properly flags the attribute even if no change occured.
801
-
802
- * \#1063 Paranoid documents properly run destroy callbacks on soft destroy.
803
-
804
- * \#1061 Raise `Mongoid::Errors::InvalidTime` when time serialization fails.
805
-
806
- * \#1002 Check for legal bson ids when attempting conversion.
807
-
808
- * \#920 Allow relations to be named target.
809
-
810
- * \#905 Return normalized class name in metadata if string was defined with a
811
- prefixed ::.
812
-
813
- * \#861 accepts_nested_attributes_for is no longer needed to set embedded documents
814
- via a hash or array of hashes directly.
815
-
816
- * \#857 Fixed cascading of dependent relations when base document is paranoid.
817
-
818
- * \#768 Fixed class_attribute definitions module wide.
819
-
820
- * \#408 Embedded documents can now be soft deleted via `Mongoid::Paranoia`.
3
+ For instructions on upgrading to newer versions, visit [mongoid.org](http://mongoid.org/docs/upgrading.html).
821
4
 
822
5
  ## 2.3.0
823
6
 
824
7
  ### New Features
825
8
 
826
9
  * Mongoid now supports basic localized fields, storing them under the covers as a
827
- hash of locale => value pairs. `field :name, localize: true`
10
+ hash of locale => value pairs. `field :name, localized: true`
828
11
 
829
12
  * \#1275 For applications that default safe mode to true, you can now tell a
830
13
  single operation to persist without safe mode via #unsafely:
@@ -905,45 +88,6 @@ For instructions on upgrading to newer versions, visit
905
88
  * Deleting versions created with `Mongoid::Versioning` no longer fires off
906
89
  dependent cascading on relations.
907
90
 
908
- ## 2.2.6
909
-
910
- * \#1751 Mongoid's logger now responds to level for Ruby logging API
911
- compatibility.
912
-
913
- ## 2.2.5
914
-
915
- * This was a small patch release to address 2.2.x Heroku errors during asset
916
- compilation.
917
-
918
- ## 2.2.4
919
-
920
- * \#1377 Fix aggregation functions to properly handle nil or indefined values.
921
- (Maxime Garcia)
922
-
923
- * \#1373 Warn if a scope overrides another scope.
924
-
925
- * \#1372 Never persist when binding inside of a read attribute for validation.
926
-
927
- * \#1358 Fixed type error on many to many synchronization when inverse_of is
928
- set to nil.
929
-
930
- * \#1356 $in criteria can now be chained to non-complex criteria on the same
931
- key without error.
932
-
933
- * \#1350, \#1351 Fixed errors in the string conversions of double quotes and
934
- tilde when paramterizing keys.
935
-
936
- * \#1349 Mongoid documents should not blow up when including Enumerable.
937
- (Jonas Nicklas)
938
-
939
- ## 2.2.3
940
-
941
- * \#1295 Fixed having multiple includes only execute the eager loading of the first.
942
-
943
- * \#1225 Fixed delayed persistence of embedded documents via $set.
944
-
945
- * \#1002 Fix BSON object id conversion to check if legal first.
946
-
947
91
  ## 2.2.2
948
92
 
949
93
  * This release removes the restriction of a dependency on 1.3.x of the mongo