mongoid-multi-db 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. data/CHANGELOG.md +615 -0
  2. data/LICENSE +20 -0
  3. data/README.md +62 -0
  4. data/Rakefile +49 -0
  5. data/lib/config/locales/bg.yml +54 -0
  6. data/lib/config/locales/de.yml +54 -0
  7. data/lib/config/locales/en-GB.yml +55 -0
  8. data/lib/config/locales/en.yml +55 -0
  9. data/lib/config/locales/es.yml +52 -0
  10. data/lib/config/locales/fr.yml +55 -0
  11. data/lib/config/locales/hi.yml +46 -0
  12. data/lib/config/locales/hu.yml +57 -0
  13. data/lib/config/locales/id.yml +55 -0
  14. data/lib/config/locales/it.yml +52 -0
  15. data/lib/config/locales/ja.yml +50 -0
  16. data/lib/config/locales/kr.yml +47 -0
  17. data/lib/config/locales/nl.yml +52 -0
  18. data/lib/config/locales/pl.yml +52 -0
  19. data/lib/config/locales/pt-BR.yml +53 -0
  20. data/lib/config/locales/pt.yml +53 -0
  21. data/lib/config/locales/ro.yml +59 -0
  22. data/lib/config/locales/ru.yml +54 -0
  23. data/lib/config/locales/sv.yml +53 -0
  24. data/lib/config/locales/vi.yml +55 -0
  25. data/lib/config/locales/zh-CN.yml +46 -0
  26. data/lib/mongoid.rb +148 -0
  27. data/lib/mongoid/atomic.rb +230 -0
  28. data/lib/mongoid/atomic/modifiers.rb +243 -0
  29. data/lib/mongoid/atomic/paths.rb +3 -0
  30. data/lib/mongoid/atomic/paths/embedded.rb +43 -0
  31. data/lib/mongoid/atomic/paths/embedded/many.rb +44 -0
  32. data/lib/mongoid/atomic/paths/embedded/one.rb +43 -0
  33. data/lib/mongoid/atomic/paths/root.rb +40 -0
  34. data/lib/mongoid/attributes.rb +234 -0
  35. data/lib/mongoid/attributes/processing.rb +146 -0
  36. data/lib/mongoid/callbacks.rb +135 -0
  37. data/lib/mongoid/collection.rb +153 -0
  38. data/lib/mongoid/collection_proxy.rb +59 -0
  39. data/lib/mongoid/collections.rb +120 -0
  40. data/lib/mongoid/collections/master.rb +45 -0
  41. data/lib/mongoid/collections/operations.rb +44 -0
  42. data/lib/mongoid/collections/retry.rb +46 -0
  43. data/lib/mongoid/components.rb +96 -0
  44. data/lib/mongoid/config.rb +347 -0
  45. data/lib/mongoid/config/database.rb +186 -0
  46. data/lib/mongoid/config/replset_database.rb +82 -0
  47. data/lib/mongoid/connection_proxy.rb +30 -0
  48. data/lib/mongoid/contexts.rb +25 -0
  49. data/lib/mongoid/contexts/enumerable.rb +288 -0
  50. data/lib/mongoid/contexts/enumerable/sort.rb +43 -0
  51. data/lib/mongoid/contexts/mongo.rb +409 -0
  52. data/lib/mongoid/copyable.rb +48 -0
  53. data/lib/mongoid/criteria.rb +418 -0
  54. data/lib/mongoid/criterion/builder.rb +34 -0
  55. data/lib/mongoid/criterion/complex.rb +84 -0
  56. data/lib/mongoid/criterion/creational.rb +34 -0
  57. data/lib/mongoid/criterion/exclusion.rb +108 -0
  58. data/lib/mongoid/criterion/inclusion.rb +305 -0
  59. data/lib/mongoid/criterion/inspection.rb +22 -0
  60. data/lib/mongoid/criterion/optional.rb +232 -0
  61. data/lib/mongoid/criterion/selector.rb +153 -0
  62. data/lib/mongoid/cursor.rb +86 -0
  63. data/lib/mongoid/database_proxy.rb +97 -0
  64. data/lib/mongoid/default_scope.rb +36 -0
  65. data/lib/mongoid/dirty.rb +110 -0
  66. data/lib/mongoid/document.rb +280 -0
  67. data/lib/mongoid/errors.rb +17 -0
  68. data/lib/mongoid/errors/callback.rb +26 -0
  69. data/lib/mongoid/errors/document_not_found.rb +28 -0
  70. data/lib/mongoid/errors/eager_load.rb +25 -0
  71. data/lib/mongoid/errors/invalid_collection.rb +18 -0
  72. data/lib/mongoid/errors/invalid_database.rb +19 -0
  73. data/lib/mongoid/errors/invalid_field.rb +18 -0
  74. data/lib/mongoid/errors/invalid_find.rb +19 -0
  75. data/lib/mongoid/errors/invalid_options.rb +28 -0
  76. data/lib/mongoid/errors/invalid_time.rb +25 -0
  77. data/lib/mongoid/errors/invalid_type.rb +25 -0
  78. data/lib/mongoid/errors/mixed_relations.rb +37 -0
  79. data/lib/mongoid/errors/mongoid_error.rb +26 -0
  80. data/lib/mongoid/errors/too_many_nested_attribute_records.rb +20 -0
  81. data/lib/mongoid/errors/unsaved_document.rb +23 -0
  82. data/lib/mongoid/errors/unsupported_version.rb +20 -0
  83. data/lib/mongoid/errors/validations.rb +23 -0
  84. data/lib/mongoid/extensions.rb +82 -0
  85. data/lib/mongoid/extensions/array/deletion.rb +29 -0
  86. data/lib/mongoid/extensions/false_class/equality.rb +26 -0
  87. data/lib/mongoid/extensions/hash/criteria_helpers.rb +45 -0
  88. data/lib/mongoid/extensions/hash/scoping.rb +25 -0
  89. data/lib/mongoid/extensions/integer/checks.rb +23 -0
  90. data/lib/mongoid/extensions/nil/collectionization.rb +23 -0
  91. data/lib/mongoid/extensions/object/checks.rb +29 -0
  92. data/lib/mongoid/extensions/object/reflections.rb +48 -0
  93. data/lib/mongoid/extensions/object/substitutable.rb +15 -0
  94. data/lib/mongoid/extensions/object/yoda.rb +44 -0
  95. data/lib/mongoid/extensions/object_id/conversions.rb +60 -0
  96. data/lib/mongoid/extensions/proc/scoping.rb +25 -0
  97. data/lib/mongoid/extensions/string/checks.rb +36 -0
  98. data/lib/mongoid/extensions/string/conversions.rb +22 -0
  99. data/lib/mongoid/extensions/string/inflections.rb +118 -0
  100. data/lib/mongoid/extensions/symbol/checks.rb +23 -0
  101. data/lib/mongoid/extensions/symbol/inflections.rb +66 -0
  102. data/lib/mongoid/extensions/true_class/equality.rb +26 -0
  103. data/lib/mongoid/extras.rb +31 -0
  104. data/lib/mongoid/factory.rb +46 -0
  105. data/lib/mongoid/fields.rb +332 -0
  106. data/lib/mongoid/fields/mappings.rb +41 -0
  107. data/lib/mongoid/fields/serializable.rb +201 -0
  108. data/lib/mongoid/fields/serializable/array.rb +49 -0
  109. data/lib/mongoid/fields/serializable/big_decimal.rb +42 -0
  110. data/lib/mongoid/fields/serializable/bignum.rb +10 -0
  111. data/lib/mongoid/fields/serializable/binary.rb +11 -0
  112. data/lib/mongoid/fields/serializable/boolean.rb +43 -0
  113. data/lib/mongoid/fields/serializable/date.rb +51 -0
  114. data/lib/mongoid/fields/serializable/date_time.rb +28 -0
  115. data/lib/mongoid/fields/serializable/fixnum.rb +10 -0
  116. data/lib/mongoid/fields/serializable/float.rb +32 -0
  117. data/lib/mongoid/fields/serializable/foreign_keys/array.rb +42 -0
  118. data/lib/mongoid/fields/serializable/foreign_keys/object.rb +47 -0
  119. data/lib/mongoid/fields/serializable/hash.rb +11 -0
  120. data/lib/mongoid/fields/serializable/integer.rb +44 -0
  121. data/lib/mongoid/fields/serializable/localized.rb +41 -0
  122. data/lib/mongoid/fields/serializable/nil_class.rb +38 -0
  123. data/lib/mongoid/fields/serializable/object.rb +11 -0
  124. data/lib/mongoid/fields/serializable/object_id.rb +31 -0
  125. data/lib/mongoid/fields/serializable/range.rb +42 -0
  126. data/lib/mongoid/fields/serializable/set.rb +42 -0
  127. data/lib/mongoid/fields/serializable/string.rb +27 -0
  128. data/lib/mongoid/fields/serializable/symbol.rb +27 -0
  129. data/lib/mongoid/fields/serializable/time.rb +23 -0
  130. data/lib/mongoid/fields/serializable/time_with_zone.rb +23 -0
  131. data/lib/mongoid/fields/serializable/timekeeping.rb +106 -0
  132. data/lib/mongoid/finders.rb +152 -0
  133. data/lib/mongoid/hierarchy.rb +120 -0
  134. data/lib/mongoid/identity.rb +92 -0
  135. data/lib/mongoid/identity_map.rb +119 -0
  136. data/lib/mongoid/indexes.rb +54 -0
  137. data/lib/mongoid/inspection.rb +54 -0
  138. data/lib/mongoid/javascript.rb +20 -0
  139. data/lib/mongoid/javascript/functions.yml +63 -0
  140. data/lib/mongoid/json.rb +16 -0
  141. data/lib/mongoid/keys.rb +144 -0
  142. data/lib/mongoid/logger.rb +39 -0
  143. data/lib/mongoid/matchers.rb +32 -0
  144. data/lib/mongoid/matchers/all.rb +21 -0
  145. data/lib/mongoid/matchers/and.rb +30 -0
  146. data/lib/mongoid/matchers/default.rb +70 -0
  147. data/lib/mongoid/matchers/exists.rb +23 -0
  148. data/lib/mongoid/matchers/gt.rb +21 -0
  149. data/lib/mongoid/matchers/gte.rb +21 -0
  150. data/lib/mongoid/matchers/in.rb +21 -0
  151. data/lib/mongoid/matchers/lt.rb +21 -0
  152. data/lib/mongoid/matchers/lte.rb +21 -0
  153. data/lib/mongoid/matchers/ne.rb +21 -0
  154. data/lib/mongoid/matchers/nin.rb +21 -0
  155. data/lib/mongoid/matchers/or.rb +33 -0
  156. data/lib/mongoid/matchers/size.rb +21 -0
  157. data/lib/mongoid/matchers/strategies.rb +93 -0
  158. data/lib/mongoid/multi_database.rb +31 -0
  159. data/lib/mongoid/multi_parameter_attributes.rb +106 -0
  160. data/lib/mongoid/named_scope.rb +146 -0
  161. data/lib/mongoid/nested_attributes.rb +54 -0
  162. data/lib/mongoid/observer.rb +170 -0
  163. data/lib/mongoid/paranoia.rb +158 -0
  164. data/lib/mongoid/persistence.rb +264 -0
  165. data/lib/mongoid/persistence/atomic.rb +223 -0
  166. data/lib/mongoid/persistence/atomic/add_to_set.rb +35 -0
  167. data/lib/mongoid/persistence/atomic/bit.rb +37 -0
  168. data/lib/mongoid/persistence/atomic/inc.rb +31 -0
  169. data/lib/mongoid/persistence/atomic/operation.rb +85 -0
  170. data/lib/mongoid/persistence/atomic/pop.rb +34 -0
  171. data/lib/mongoid/persistence/atomic/pull.rb +34 -0
  172. data/lib/mongoid/persistence/atomic/pull_all.rb +34 -0
  173. data/lib/mongoid/persistence/atomic/push.rb +31 -0
  174. data/lib/mongoid/persistence/atomic/push_all.rb +31 -0
  175. data/lib/mongoid/persistence/atomic/rename.rb +31 -0
  176. data/lib/mongoid/persistence/atomic/sets.rb +30 -0
  177. data/lib/mongoid/persistence/atomic/unset.rb +28 -0
  178. data/lib/mongoid/persistence/deletion.rb +32 -0
  179. data/lib/mongoid/persistence/insertion.rb +41 -0
  180. data/lib/mongoid/persistence/modification.rb +37 -0
  181. data/lib/mongoid/persistence/operations.rb +211 -0
  182. data/lib/mongoid/persistence/operations/embedded/insert.rb +42 -0
  183. data/lib/mongoid/persistence/operations/embedded/remove.rb +40 -0
  184. data/lib/mongoid/persistence/operations/insert.rb +34 -0
  185. data/lib/mongoid/persistence/operations/remove.rb +33 -0
  186. data/lib/mongoid/persistence/operations/update.rb +64 -0
  187. data/lib/mongoid/railtie.rb +126 -0
  188. data/lib/mongoid/railties/database.rake +182 -0
  189. data/lib/mongoid/railties/document.rb +12 -0
  190. data/lib/mongoid/relations.rb +144 -0
  191. data/lib/mongoid/relations/accessors.rb +138 -0
  192. data/lib/mongoid/relations/auto_save.rb +38 -0
  193. data/lib/mongoid/relations/binding.rb +26 -0
  194. data/lib/mongoid/relations/bindings.rb +9 -0
  195. data/lib/mongoid/relations/bindings/embedded/in.rb +69 -0
  196. data/lib/mongoid/relations/bindings/embedded/many.rb +93 -0
  197. data/lib/mongoid/relations/bindings/embedded/one.rb +61 -0
  198. data/lib/mongoid/relations/bindings/referenced/in.rb +76 -0
  199. data/lib/mongoid/relations/bindings/referenced/many.rb +54 -0
  200. data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +51 -0
  201. data/lib/mongoid/relations/bindings/referenced/one.rb +58 -0
  202. data/lib/mongoid/relations/builder.rb +57 -0
  203. data/lib/mongoid/relations/builders.rb +83 -0
  204. data/lib/mongoid/relations/builders/embedded/in.rb +29 -0
  205. data/lib/mongoid/relations/builders/embedded/many.rb +40 -0
  206. data/lib/mongoid/relations/builders/embedded/one.rb +30 -0
  207. data/lib/mongoid/relations/builders/nested_attributes/many.rb +110 -0
  208. data/lib/mongoid/relations/builders/nested_attributes/one.rb +135 -0
  209. data/lib/mongoid/relations/builders/referenced/in.rb +26 -0
  210. data/lib/mongoid/relations/builders/referenced/many.rb +27 -0
  211. data/lib/mongoid/relations/builders/referenced/many_to_many.rb +38 -0
  212. data/lib/mongoid/relations/builders/referenced/one.rb +26 -0
  213. data/lib/mongoid/relations/cascading.rb +56 -0
  214. data/lib/mongoid/relations/cascading/delete.rb +19 -0
  215. data/lib/mongoid/relations/cascading/destroy.rb +26 -0
  216. data/lib/mongoid/relations/cascading/nullify.rb +18 -0
  217. data/lib/mongoid/relations/cascading/strategy.rb +26 -0
  218. data/lib/mongoid/relations/constraint.rb +42 -0
  219. data/lib/mongoid/relations/conversions.rb +35 -0
  220. data/lib/mongoid/relations/cyclic.rb +103 -0
  221. data/lib/mongoid/relations/embedded/atomic.rb +89 -0
  222. data/lib/mongoid/relations/embedded/atomic/operation.rb +63 -0
  223. data/lib/mongoid/relations/embedded/atomic/pull.rb +65 -0
  224. data/lib/mongoid/relations/embedded/atomic/push_all.rb +59 -0
  225. data/lib/mongoid/relations/embedded/atomic/set.rb +61 -0
  226. data/lib/mongoid/relations/embedded/atomic/unset.rb +41 -0
  227. data/lib/mongoid/relations/embedded/in.rb +220 -0
  228. data/lib/mongoid/relations/embedded/many.rb +560 -0
  229. data/lib/mongoid/relations/embedded/one.rb +206 -0
  230. data/lib/mongoid/relations/embedded/sort.rb +31 -0
  231. data/lib/mongoid/relations/macros.rb +310 -0
  232. data/lib/mongoid/relations/many.rb +135 -0
  233. data/lib/mongoid/relations/metadata.rb +919 -0
  234. data/lib/mongoid/relations/nested_builder.rb +75 -0
  235. data/lib/mongoid/relations/one.rb +36 -0
  236. data/lib/mongoid/relations/options.rb +47 -0
  237. data/lib/mongoid/relations/polymorphic.rb +40 -0
  238. data/lib/mongoid/relations/proxy.rb +145 -0
  239. data/lib/mongoid/relations/referenced/batch.rb +72 -0
  240. data/lib/mongoid/relations/referenced/batch/insert.rb +57 -0
  241. data/lib/mongoid/relations/referenced/in.rb +262 -0
  242. data/lib/mongoid/relations/referenced/many.rb +623 -0
  243. data/lib/mongoid/relations/referenced/many_to_many.rb +396 -0
  244. data/lib/mongoid/relations/referenced/one.rb +272 -0
  245. data/lib/mongoid/relations/reflections.rb +62 -0
  246. data/lib/mongoid/relations/synchronization.rb +153 -0
  247. data/lib/mongoid/relations/targets.rb +2 -0
  248. data/lib/mongoid/relations/targets/enumerable.rb +372 -0
  249. data/lib/mongoid/reloading.rb +91 -0
  250. data/lib/mongoid/safety.rb +105 -0
  251. data/lib/mongoid/scope.rb +31 -0
  252. data/lib/mongoid/serialization.rb +134 -0
  253. data/lib/mongoid/sharding.rb +61 -0
  254. data/lib/mongoid/state.rb +97 -0
  255. data/lib/mongoid/threaded.rb +530 -0
  256. data/lib/mongoid/threaded/lifecycle.rb +192 -0
  257. data/lib/mongoid/timestamps.rb +15 -0
  258. data/lib/mongoid/timestamps/created.rb +24 -0
  259. data/lib/mongoid/timestamps/timeless.rb +50 -0
  260. data/lib/mongoid/timestamps/updated.rb +26 -0
  261. data/lib/mongoid/validations.rb +140 -0
  262. data/lib/mongoid/validations/associated.rb +46 -0
  263. data/lib/mongoid/validations/uniqueness.rb +145 -0
  264. data/lib/mongoid/version.rb +4 -0
  265. data/lib/mongoid/versioning.rb +185 -0
  266. data/lib/rack/mongoid.rb +2 -0
  267. data/lib/rack/mongoid/middleware/identity_map.rb +38 -0
  268. data/lib/rails/generators/mongoid/config/config_generator.rb +25 -0
  269. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +20 -0
  270. data/lib/rails/generators/mongoid/model/model_generator.rb +24 -0
  271. data/lib/rails/generators/mongoid/model/templates/model.rb.tt +19 -0
  272. data/lib/rails/generators/mongoid/observer/observer_generator.rb +17 -0
  273. data/lib/rails/generators/mongoid/observer/templates/observer.rb.tt +4 -0
  274. data/lib/rails/generators/mongoid_generator.rb +70 -0
  275. data/lib/rails/mongoid.rb +91 -0
  276. metadata +465 -0
@@ -0,0 +1,615 @@
1
+ # Overview
2
+
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
+ ### New Features
9
+
10
+ * Ranges can now be passed to #where criteria to create a $gte/$lte query under the
11
+ covers. `Person.where(dob: start_date...end_date)`
12
+
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
+ * \#1431 Enumerable context should add to the loaded array post yield, so
20
+ that methods like #any? that short circuit based on the value of the block
21
+ dont falsely have extra documents.
22
+
23
+ * \#1418 Documents being loaded from the database for revision purposes
24
+ no longer get placed in the identity map.
25
+
26
+ * \#1399 Allow conversion of strings to integers in foreign keys where the
27
+ id is defined as an int.
28
+
29
+ * \#1397 Don't add default sorting criteria on first if they sort criteria
30
+ already exists.
31
+
32
+ * \#1394 Fix exists? to work when count is greater than 1. (Nick Hoffman)
33
+
34
+ * \#1392 Return 0 on aggregation functions where field is nonexistant.
35
+
36
+ * \#1391 Uniqueness validation now works properly on embedded documents that are
37
+ using primary key definitions.
38
+
39
+ * \#1390 When _type field is lower case class camelize before constantizing.
40
+
41
+ * \#1383 Fix cast on read for serializable fields that are subclassed.
42
+
43
+ * \#1326 Ensure base document on HABTM gets its keys saved after saving a newly
44
+ build child document.
45
+
46
+ * \#1301 Don't overwrite base metadata on embedded in relations if already set.
47
+
48
+ * \#1221 HABTM with inverse nil is allowed again on embedded documents.
49
+
50
+ * \#1208 Don't auto-persist child documents via the setter when setting from
51
+ an embedded_in.
52
+
53
+ * \#791 Root document updates its timestamps when only embedded documents have
54
+ changed.
55
+
56
+ ## 2.3.3
57
+
58
+ ### Resolved Issues
59
+
60
+ * \#1386 Lowered mongo/bson dependency to 1.3
61
+
62
+ * \#1377 Fix aggregation functions to properly handle nil or indefined values.
63
+ (Maxime Garcia)
64
+
65
+ * \#1373 Warn if a scope overrides another scope.
66
+
67
+ * \#1372 Never persist when binding inside of a read attribute for validation.
68
+
69
+ * \#1364 Fixed reloading of documents with non bson object id ids.
70
+
71
+ * \#1360 Fixed performance of Mongoid's observer instantiation by hooking into
72
+ Active Support's load hooks, a la AR.
73
+
74
+ * \#1358 Fixed type error on many to many synchronization when inverse_of is
75
+ set to nil.
76
+
77
+ * \#1356 $in criteria can now be chained to non-complex criteria on the same
78
+ key without error.
79
+
80
+ * \#1350, \#1351 Fixed errors in the string conversions of double quotes and
81
+ tilde when paramterizing keys.
82
+
83
+ * \#1349 Mongoid documents should not blow up when including Enumerable.
84
+ (Jonas Nicklas)
85
+
86
+ ## 2.3.2
87
+
88
+ ### Resolved Issues
89
+
90
+ * \#1347 Fix embedded matchers when provided a hash value that does not have a
91
+ modifier as a key.
92
+
93
+ * \#1346 Dup default sorting criteria when calling first/last on a criteria.
94
+
95
+ * \#1343 When passing no arguments to `Criteria#all_of` return all documents.
96
+ (Chris Leishman)
97
+
98
+ * \#1339 Ensure destroy callbacks are run on cascadable children when deleting via
99
+ nested attributes.
100
+
101
+ * \#1324 Setting `inverse_of: nil` on a many-to-many referencing the same class
102
+ returns nil for the inverse foreign key.
103
+
104
+ * \#1323 Allow both strings and symbols as ids in the attributes array for
105
+ nested attributes. (Michael Wood)
106
+
107
+ * \#1312 Setting a logger on the config now accepts anything that quacks like a
108
+ logger.
109
+
110
+ * \#1297 Don't hit the database when accessing relations if the base is new.
111
+
112
+ * \#1239 Allow appending of referenced relations in create blocks, post default set.
113
+
114
+ * \#1236 Ensure all models are loaded in rake tasks, so even in threadsafe mode
115
+ all indexes can be created.
116
+
117
+ * \#736 Calling #reload on embedded documents now works properly.
118
+
119
+ ## 2.3.1
120
+
121
+ ### Resolved Issues
122
+
123
+ * \#1338 Calling #find on a scope or relation checks that the document in the
124
+ identity map actually matches other scope parameters.
125
+
126
+ * \#1321 HABTM no longer allows duplicate entries or keys, instead of the previous
127
+ inconsistencies.
128
+
129
+ * \#1320 Fixed errors in perf benchmark.
130
+
131
+ * \#1316 Added a separate Rake task "db:mongoid:drop" so Mongoid and AR can coexist.
132
+ (Daniel Vartanov)
133
+
134
+ * \#1311 Fix issue with custom field serialization inheriting from hash.
135
+
136
+ * \#1310 The referenced many enumerable target no longer duplicates loaded and
137
+ added documents when the identity map is enabled.
138
+
139
+ * \#1295 Fixed having multiple includes only execute the eager loading of the first.
140
+
141
+ * \#1287 Fixed max versions limitation with versioning.
142
+
143
+ * \#1277 attribute_will_change! properly flags the attribute even if no change occured.
144
+
145
+ * \#1063 Paranoid documents properly run destroy callbacks on soft destroy.
146
+
147
+ * \#1061 Raise `Mongoid::Errors::InvalidTime` when time serialization fails.
148
+
149
+ * \#1002 Check for legal bson ids when attempting conversion.
150
+
151
+ * \#920 Allow relations to be named target.
152
+
153
+ * \#905 Return normalized class name in metadata if string was defined with a
154
+ prefixed ::.
155
+
156
+ * \#861 accepts_nested_attributes_for is no longer needed to set embedded documents
157
+ via a hash or array of hashes directly.
158
+
159
+ * \#857 Fixed cascading of dependent relations when base document is paranoid.
160
+
161
+ * \#768 Fixed class_attribute definitions module wide.
162
+
163
+ * \#408 Embedded documents can now be soft deleted via `Mongoid::Paranoia`.
164
+
165
+ ## 2.3.0
166
+
167
+ ### New Features
168
+
169
+ * Mongoid now supports basic localized fields, storing them under the covers as a
170
+ hash of locale => value pairs. `field :name, localize: true`
171
+
172
+ * \#1275 For applications that default safe mode to true, you can now tell a
173
+ single operation to persist without safe mode via #unsafely:
174
+ `person.unsafely.save`, `Person.unsafely.create`. (Matt Sanders)
175
+
176
+ * \#1256 Mongoid now can create indexes for models in Rails engines. (Caio Filipini)
177
+
178
+ * \#1228 Allow pre formatting of compsoite keys by passing a block to #key.
179
+ (Ben Hundley)
180
+
181
+ * \#1222 Scoped mass assignment is now supported. (Andrew Shaydurov)
182
+
183
+ * \#1196 Timestamps can now be turned off on a call-by-call basis via the use
184
+ of #timeless: `person.timeless.save`, `Person.timeless.create(:title => "Sir")`.
185
+
186
+ * \#1103 Allow developers to create their own custom complex criteria. (Ryan Ong)
187
+
188
+ * Mongoid now includes all defined fields in `serializable_hash` and `to_json`
189
+ results even if the fields have no values to make serialized documents easier
190
+ to use by ActiveResource clients.
191
+
192
+ * Support for MongoDB's $and operator is now available in the form of:
193
+ `Criteria#all_of(*args)` where args is multiple hash expressions.
194
+
195
+ * \#1250, \#1058 Embedded documents now can have their callbacks fired on a parent
196
+ save by setting `:cascade_callbacks => true` on the relation.
197
+ (pyromanic, Paul Rosania, Jak Charlton)
198
+
199
+ ### Major Changes
200
+
201
+ * Mongoid now depends on Active Model 3.1 and higher.
202
+
203
+ * Mongoid now depends on the Mongo Ruby Driver 1.4 and higher.
204
+
205
+ * Mongoid requires MongoDB 2.0.0 and higher.
206
+
207
+ ### Resolved Issues
208
+
209
+ * \#1308 Fixed scoping of HABTM finds.
210
+
211
+ * \#1300 Namespaced models should handle recursive embedding properly.
212
+
213
+ * \#1299 Self referenced documents with versioning no longer fail when inverse_of
214
+ is not defined on all relations.
215
+
216
+ * \#1296 Renamed internal building method to _building.
217
+
218
+ * \#1288, \#1289 _id and updated_at should not be part of versioned attributes.
219
+
220
+ * \#1273 Mongoid.preload_models now checks if preload configuration option is set,
221
+ where Mongoid.load_models always loads everything. (Ryan McGeary)
222
+
223
+ * \#1244 Has one relations now adhere to default dependant behaviour.
224
+
225
+ * \#1225 Fixed delayed persistence of embedded documents via $set.
226
+
227
+ * \#1166 Don't load config in Railtie if no env variables defined. (Terence Lee)
228
+
229
+ * \#1052 `alias_attribute` now works again as expected.
230
+
231
+ * \#939 Apply default attributes when upcasting via #becomes. (Christos Pappas)
232
+
233
+ * \#932 Fixed casting of integer fields with leading zeros.
234
+
235
+ * \#948 Reset version number on clone if versions existed.
236
+
237
+ * \#763 Don't merge $in criteria arrays when chaining named scopes.
238
+
239
+ * \#730 Existing models that have relations added post persistence of originals
240
+ can now have new relations added with no migrations.
241
+
242
+ * \#726 Embedded documents with compound keys not validate uniqueness correctly.
243
+
244
+ * \#582 Cyclic non embedded relations now validate uniqueness correctly.
245
+
246
+ * \#484 Validates uniqueness with multiple scopes of all types now work properly.
247
+
248
+ * Deleting versions created with `Mongoid::Versioning` no longer fires off
249
+ dependent cascading on relations.
250
+
251
+ ## 2.2.4
252
+
253
+ * \#1377 Fix aggregation functions to properly handle nil or indefined values.
254
+ (Maxime Garcia)
255
+
256
+ * \#1373 Warn if a scope overrides another scope.
257
+
258
+ * \#1372 Never persist when binding inside of a read attribute for validation.
259
+
260
+ * \#1358 Fixed type error on many to many synchronization when inverse_of is
261
+ set to nil.
262
+
263
+ * \#1356 $in criteria can now be chained to non-complex criteria on the same
264
+ key without error.
265
+
266
+ * \#1350, \#1351 Fixed errors in the string conversions of double quotes and
267
+ tilde when paramterizing keys.
268
+
269
+ * \#1349 Mongoid documents should not blow up when including Enumerable.
270
+ (Jonas Nicklas)
271
+
272
+ ## 2.2.3
273
+
274
+ * \#1295 Fixed having multiple includes only execute the eager loading of the first.
275
+
276
+ * \#1225 Fixed delayed persistence of embedded documents via $set.
277
+
278
+ * \#1002 Fix BSON object id conversion to check if legal first.
279
+
280
+ ## 2.2.2
281
+
282
+ * This release removes the restriction of a dependency on 1.3.x of the mongo
283
+ ruby driver. Users may now use 1.3.x through 1.4.x.
284
+
285
+ ## 2.2.1
286
+
287
+ ### Resolved Issues
288
+
289
+ * \#1210, \#517 Allow embedded document relation queries to use dot notation.
290
+ (Scott Ellard)
291
+
292
+ * \#1198 Enumerable target should use criteria count if loaded has no docs.
293
+
294
+ * \#1164 Get rid of remaining no method in_memory errors.
295
+
296
+ * \#1070 Allow custom field serializers to have their own constructors.
297
+
298
+ * \#1176 Allow access to parent documents from embedded docs in after_destroy
299
+ callbacks.
300
+
301
+ * \#1191 Context group methods (min, max, sum) no longer return NaN but instead
302
+ return nil if field doesn't exist or have values.
303
+
304
+ * \#1193, \#1271 Always return Integers for integer fields with .000 precisions,
305
+ not floats.
306
+
307
+ * \#1199 Fixed performance issues of hash and array field access when reading
308
+ multiple times.
309
+
310
+ * \#1218 Fixed issues with relations referencing models with integer foreign keys.
311
+
312
+ * \#1219 Fixed various conflicting modifications issues when pushing and pulling
313
+ from the same embedded document in a single call.
314
+
315
+ * \#1220 Metadata should not get overwritten by nil on binding.
316
+
317
+ * \#1231 Renamed Mongoid's atomic set class to Sets to avoid conflicts with Ruby's
318
+ native Set after document inclusion.
319
+
320
+ * \#1232 Fix access to related models during before_destroy callbacks when
321
+ cascading.
322
+
323
+ * \#1234 Fixed HABTM foreign key synchronization issues when destroying
324
+ documents.
325
+
326
+ * \#1243 Polymorphic relations dont convert to object ids when querying if the
327
+ ids are defined as strings.
328
+
329
+ * \#1247 Force Model.first to sort by ascending id to guarantee first document.
330
+
331
+ * \#1248 Added #unscoped to embedded many relations.
332
+
333
+ * \#1249 Destroy flags in nested attributes now actually destroy the document
334
+ for has_many instead of just breaking the relation.
335
+
336
+ * \#1272 Don't modify configuration options in place when creating replica set
337
+ connections.
338
+
339
+ ## 2.2.0
340
+
341
+ ### New Features
342
+
343
+ * Mongoid now contains eager loading in the form of `Criteria#includes(*args)`.
344
+ This works on has_one, has_many, belongs_to associations and requires the identity map to
345
+ be enabled in order to function. Set `identity_map_enabled: true` in your
346
+ `mongoid.yml`. Ex: `Person.where(title: "Sir").includes(:posts, :game)`
347
+
348
+ * Relations can now take a module as a value to the `:extend` option. (Roman
349
+ Shterenzon)
350
+
351
+ * Capped collections can be created by passing the options to the `#store_in`
352
+ macro: `Person.store_in :people, capped: true, max: 1000000`
353
+
354
+ * Mongoid::Collection now supports `collection.find_and_modify`
355
+
356
+ * `Document#has_attribute?` now aliases to `Document#attribute_present?`
357
+
358
+ * \#930 You can now turn off the Mongoid logger via the mongoid.yml by
359
+ doing `logger: false`
360
+
361
+ * \#909 We now raise a `Mongoid::Errors::Callback` exception if persisting with
362
+ a bang method and a callback returns false, instead of the uninformative
363
+ validations error from before.
364
+
365
+ ### Major Changes
366
+
367
+ * \#1173 has_many relations no longer delete all documents on a set of the relation
368
+ (= [ doc_one, doc_two ]) but look to the dependent option to determine what
369
+ behaviour should occur. :delete and :destroy will behave as before, :nullify and
370
+ no option specified will both nullify the old documents without deleting.
371
+
372
+ * \#1142, \#767 Embedded relations no longer immediately persist atomically
373
+ when accessed via a parent attributes set. This includes nested attributes setting
374
+ and `attributes=` or `write_attributes`. The child changes then remain dirty and
375
+ atomically update when save is called on them or the parent document.
376
+
377
+ ### Resolved Issues
378
+
379
+ * \#1190 Fixed the gemspec errors due to changing README and CHANGELOG to markdown.
380
+
381
+ * \#1180, \#1084, \#955 Mongoid now checks the field types rather than if the name
382
+ contains `/id/` when trying to convert to object ids on criteria.
383
+
384
+ * \#1176 Enumerable targets should always return the in memory documents first,
385
+ when calling `#first`
386
+
387
+ * \#1175 Make sure both sides of many to many relations are in sync during a create.
388
+
389
+ * \#1172 Referenced enumerable relations now properly handle `#to_json`
390
+ (Daniel Doubrovkine)
391
+
392
+ * \#1040 Increased performance of class load times by removing all delegate calls
393
+ to self.class.
394
+
395
+ ## 2.1.9
396
+
397
+ ### Resolved Issues
398
+
399
+ * \#1159 Fixed build blocks not to cancel out each other when nested.
400
+
401
+ * \#1154 Don't delete many-to-many documents on empty array set.
402
+
403
+ * \#1153 Retain parent document reference in after callbacks.
404
+
405
+ * \#1151 Fix associated validation infinite loop on self referencing documents.
406
+
407
+ * \#1150 Validates associated on `belongs_to` is `false` by default.
408
+
409
+ * \#1149 Fixed metadata setting on `belongs_to` relations.
410
+
411
+ * \#1145 Metadata inverse should return `nil` if `inverse_of` was set as `nil`.
412
+
413
+ * \#1139 Enumerable targets now quack like arrays.
414
+
415
+ * \#1136 Setting `belongs_to` parent to `nil` no longer deletes the parent.
416
+
417
+ * \#1120 Don't call `in_memory` on relations if they don't respond to it.
418
+
419
+ * \#1075 Set `self` in default procs to the document instance.
420
+
421
+ * \#1072 Writing attributes for nested documents can take a hash or array of hashes.
422
+
423
+ * \#990 Embedded documents can use a single `embedded_in` with multiple parent definitions.
424
+
425
+ ## 2.1.8
426
+
427
+ ### Resolved Issues
428
+
429
+ * \#1148 Fixed `respond_to?` on all relations to return properly.
430
+
431
+ * \#1146 Added back the Mongoid destructive fields check when defining fields.
432
+
433
+ * \#1141 Fixed conversions of `nil` values in criteria.
434
+
435
+ * \#1131 Verified Mongoid/Kaminari paginating correctly.
436
+
437
+ * \#1105 Fixed atomic update consumer to be scoped to class.
438
+
439
+ * \#1075 `self` in default lambdas and procs now references the document instance.
440
+
441
+ * \#740 Removed `embedded_object_id` configuration parameter.
442
+
443
+ * \#661 Fixed metadata caching on embedded documents.
444
+
445
+ * \#595 Fixed relation reload flagging.
446
+
447
+ * \#410 Moving documents from one relation to another now works as expected.
448
+
449
+ ## 2.1.7
450
+
451
+ This was a specific release to fix MRI 1.8.7 breakages introduced by 2.1.6.
452
+
453
+ ## 2.1.6
454
+
455
+ ### Resolved Issues
456
+
457
+ * \#1126 Fix setting of relations with other relation proxies.
458
+
459
+ * \#1122 Hash and array fields now properly flag as dirty on access and change.
460
+
461
+ * \#656 Fixed reload breaking relations on unsetting of already loaded associations.
462
+
463
+ * \#647 Prefer `#unset` to `#remove_attribute` for removing values.
464
+
465
+ * \#290 Verify pushes into deeply embedded documents.
466
+
467
+ ## 2.1.5
468
+
469
+ ### Resolved Issues
470
+
471
+ * \#1116 Embedded children retain reference to parent in destroy callbacks.
472
+
473
+ * \#1110, \#1115 Don't memoize metadata related helpers on documents.
474
+
475
+ * \#1112 `db:create_indexes` no longer indexes subclasses multiple times.
476
+
477
+ * \#1111, \#1098 Don't set `_id` in `$set` operations.
478
+
479
+ * \#1007 Update attribute properly tracks array changes.
480
+
481
+ ## 2.1.4
482
+
483
+ This was a specific release to get a Psych generated gemspec so no more parse errors would occur on those rubies that were using the new YAML parser.
484
+
485
+ ## 2.1.3
486
+
487
+ ### Resolved Issues
488
+
489
+ * \#1109 Fixed validations not loading one to ones into memory.
490
+
491
+ * \#1107 Mongoid no longer wants required `mongoid/railtie` in `application.rb`.
492
+
493
+ * \#1102 Fixed nested attributes deletion.
494
+
495
+ * \#1097 Reload now runs `after_initialize` callbacks.
496
+
497
+ * \#1079 Embeds many no longer duplicates documents.
498
+
499
+ * \#1078 Fixed array criteria matching on embedded documents.
500
+
501
+ * \#1028 Implement scoped on one-to-many and many-to-many relations.
502
+
503
+ * \#988 Many-to-many clear no longer deletes the child documents.
504
+
505
+ * \#977 Autosaving relations works also through nested attributes.
506
+
507
+ * \#972 Recursive embedding now handles namespacing on generated names.
508
+
509
+ * \#943 Don't override `Document#attributes`.
510
+
511
+ * \#893 Verify count is not caching on many to many relations.
512
+
513
+ * \#815 Verify `after_initialize` is run in the correct place.
514
+
515
+ * \#793 Verify `any_of` scopes chain properly with any other scope.
516
+
517
+ * \#776 Fixed mongoid case quality when dealing with subclasses.
518
+
519
+ * \#747 Fixed complex criteria using its keys to render its string value.
520
+
521
+ * \#721 `#safely` now properly raises validation errors when they occur.
522
+
523
+ ## 2.1.2
524
+
525
+ ### Resolved Issues
526
+
527
+ * \#1082 Alias `size` and `length` to `count` on criteria. (Adam Greene)
528
+
529
+ * \#1044 When multiple relations are defined for the same class, always return the default inverse first if `inverse_of` is not defined.
530
+
531
+ * \#710 Nested attributes accept both `id` and `_id` in hashes or arrays.
532
+
533
+ * \#1047 Ignore `nil` values passed to `embeds_man` pushes and substitution. (Derick Bailey)
534
+
535
+ ## 2.1.1
536
+
537
+ ### Resolved Issues
538
+
539
+ * \#1021, \#719 Many to many relations dont trigger extra database queries when pushing new documents.
540
+
541
+ * \#607 Calling `create` on large associations does not load the entire relation.
542
+
543
+ * \#1064 `Mongoid::Paranoia` should respect `unscoped` and `scoped`.
544
+
545
+ * \#1026 `model#update_attribute` now can update booleans to `false`.
546
+
547
+ * \#618 Crack XML library breaks Mongoid by adding `#attributes` method to the `String` class. (Stephen McGinty)
548
+
549
+ ## 2.1.0
550
+
551
+ ### Major Changes
552
+
553
+ * Mongoid now requires MongoDB 1.8.x in order to properly support the `#bit` and `#rename` atomic operations.
554
+
555
+ * Traditional slave support has been removed from Mongoid. Replica sets should be used in place of traditional master and slave setups.
556
+
557
+ * Custom field serialization has changed. Please see [serializable](https://github.com/mongoid/mongoid/blob/master/lib/mongoid/fields/serializable.rb) for changes.
558
+
559
+ * The dirty attribute tracking has been switched to use ActiveModel, this brings many bug fixes and changes:
560
+
561
+ * \#756 After callbacks and observers see what was changed instead of changes just made being in previous_changes
562
+
563
+ * \#434 Documents now are flagged as dirty when brand new or the state on instantiation differs from the database state. This is consistent with ActiveRecord.
564
+
565
+ * \#323 Mongoid now supports [field]_will_change! from ActiveModel::Dirty
566
+
567
+ * Mongoid model preloading in development mode now defaults to `false`.
568
+
569
+ * `:autosave => true` on relational associations now saves on update as well as create.
570
+
571
+ * Mongoid now has an identity map for simple `find_by_id` queries. See the website for documentation.
572
+
573
+ ### New Features
574
+
575
+ * \#1067 Fields now accept a `:versioned` attribute to be able to disable what fields are versioned with `Mongoid::Versioning`. (Jim Benton)
576
+
577
+ * \#587 Added order preference to many and many to many associations. (Gregory Man)
578
+
579
+ * Added ability to chain `order_by` statements. (Gregory Man)
580
+
581
+ * \#961 Allow arbitrary `Mongo::Connection` options to pass through `Mongoid::Config::Database` object. (Morgan Nelson)
582
+
583
+ * Enable `autosave` for many to many references. (Dave Krupinski)
584
+
585
+ * The following explicit atomic operations have been added: `Model#bit`, `Model#pop`, `Model#pull`, `Model#push_all`, `Model#rename`, `Model#unset`.
586
+
587
+ * Added exception translations for Hindi. (Sukeerthi Adiga)
588
+
589
+ ### Resolved Issues
590
+
591
+ * \#974 Fix `attribute_present?` to work correctly then attribute value is `false`, thanks to @nickhoffman. (Gregory Man)
592
+
593
+ * \#960 create indexes rake task is not recognizing a lot of mongoid models because it has problems guessing their model names from filenames. (Tobias Schlottke)
594
+
595
+ * \#874 Deleting from a M-M reference is one-sided. (nickhoffman, davekrupinski)
596
+
597
+ * Replace deprecated `class_inheritable_hash` dropped in Rails 3.1+. (Konstantin Shabanov)
598
+
599
+ * Fix inconsistent state when replacing an entire many to many relation.
600
+
601
+ * Don't clobber inheritable attributes when adding subclass field inheritance. (Dave Krupinski)
602
+
603
+ * \#914 Querying embedded documents with `$or` selector. (Max Golovnia)
604
+
605
+ * \#514 Fix marshaling of documents with relation extensions. (Chris Griego)
606
+
607
+ * `Metadata#extension` now returns a `Module`, instead of a `Proc`, when an extension is defined.
608
+
609
+ * \#837 When `allow_dynamic_fields` is set to `false` and loading an embedded document with an unrecognized field, an exception is raised.
610
+
611
+ * \#963 Initializing array of embedded documents via hash regressed (Chris Griego, Morgan Nelson)
612
+
613
+ * `Mongoid::Config.reset` resets the options to their default values.
614
+
615
+ * `Mongoid::Fields.defaults` is memoized for faster instantiation of models.