activerecord 4.1.16 → 4.2.11.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

Files changed (185) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1162 -1801
  3. data/README.rdoc +15 -10
  4. data/lib/active_record/aggregations.rb +15 -8
  5. data/lib/active_record/association_relation.rb +13 -0
  6. data/lib/active_record/associations/alias_tracker.rb +3 -12
  7. data/lib/active_record/associations/association.rb +16 -4
  8. data/lib/active_record/associations/association_scope.rb +83 -38
  9. data/lib/active_record/associations/belongs_to_association.rb +28 -10
  10. data/lib/active_record/associations/builder/association.rb +15 -4
  11. data/lib/active_record/associations/builder/belongs_to.rb +7 -29
  12. data/lib/active_record/associations/builder/collection_association.rb +5 -1
  13. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +8 -13
  14. data/lib/active_record/associations/builder/has_many.rb +1 -1
  15. data/lib/active_record/associations/builder/has_one.rb +2 -2
  16. data/lib/active_record/associations/builder/singular_association.rb +8 -1
  17. data/lib/active_record/associations/collection_association.rb +63 -27
  18. data/lib/active_record/associations/collection_proxy.rb +29 -35
  19. data/lib/active_record/associations/foreign_association.rb +11 -0
  20. data/lib/active_record/associations/has_many_association.rb +83 -22
  21. data/lib/active_record/associations/has_many_through_association.rb +49 -26
  22. data/lib/active_record/associations/has_one_association.rb +1 -1
  23. data/lib/active_record/associations/join_dependency/join_association.rb +25 -15
  24. data/lib/active_record/associations/join_dependency/join_part.rb +0 -1
  25. data/lib/active_record/associations/join_dependency.rb +26 -13
  26. data/lib/active_record/associations/preloader/association.rb +14 -11
  27. data/lib/active_record/associations/preloader/through_association.rb +4 -3
  28. data/lib/active_record/associations/preloader.rb +36 -26
  29. data/lib/active_record/associations/singular_association.rb +17 -2
  30. data/lib/active_record/associations/through_association.rb +5 -12
  31. data/lib/active_record/associations.rb +158 -49
  32. data/lib/active_record/attribute.rb +163 -0
  33. data/lib/active_record/attribute_assignment.rb +19 -11
  34. data/lib/active_record/attribute_decorators.rb +66 -0
  35. data/lib/active_record/attribute_methods/before_type_cast.rb +7 -2
  36. data/lib/active_record/attribute_methods/dirty.rb +107 -43
  37. data/lib/active_record/attribute_methods/primary_key.rb +7 -8
  38. data/lib/active_record/attribute_methods/query.rb +1 -1
  39. data/lib/active_record/attribute_methods/read.rb +22 -59
  40. data/lib/active_record/attribute_methods/serialization.rb +16 -150
  41. data/lib/active_record/attribute_methods/time_zone_conversion.rb +38 -40
  42. data/lib/active_record/attribute_methods/write.rb +9 -24
  43. data/lib/active_record/attribute_methods.rb +56 -94
  44. data/lib/active_record/attribute_set/builder.rb +106 -0
  45. data/lib/active_record/attribute_set.rb +81 -0
  46. data/lib/active_record/attributes.rb +147 -0
  47. data/lib/active_record/autosave_association.rb +19 -12
  48. data/lib/active_record/base.rb +13 -24
  49. data/lib/active_record/callbacks.rb +6 -6
  50. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +84 -52
  51. data/lib/active_record/connection_adapters/abstract/database_statements.rb +52 -50
  52. data/lib/active_record/connection_adapters/abstract/query_cache.rb +1 -1
  53. data/lib/active_record/connection_adapters/abstract/quoting.rb +60 -60
  54. data/lib/active_record/connection_adapters/abstract/savepoints.rb +1 -1
  55. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +39 -4
  56. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +138 -56
  57. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +14 -34
  58. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +268 -71
  59. data/lib/active_record/connection_adapters/abstract/transaction.rb +125 -118
  60. data/lib/active_record/connection_adapters/abstract_adapter.rb +171 -59
  61. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +293 -139
  62. data/lib/active_record/connection_adapters/column.rb +29 -240
  63. data/lib/active_record/connection_adapters/connection_specification.rb +15 -24
  64. data/lib/active_record/connection_adapters/mysql2_adapter.rb +16 -32
  65. data/lib/active_record/connection_adapters/mysql_adapter.rb +67 -144
  66. data/lib/active_record/connection_adapters/postgresql/array_parser.rb +15 -27
  67. data/lib/active_record/connection_adapters/postgresql/column.rb +20 -0
  68. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +40 -25
  69. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +100 -0
  70. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +52 -0
  71. data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +13 -0
  72. data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +15 -0
  73. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +46 -0
  74. data/lib/active_record/connection_adapters/postgresql/oid/date.rb +11 -0
  75. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +36 -0
  76. data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +13 -0
  77. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +19 -0
  78. data/lib/active_record/connection_adapters/postgresql/oid/float.rb +21 -0
  79. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +59 -0
  80. data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +13 -0
  81. data/lib/active_record/connection_adapters/postgresql/oid/infinity.rb +13 -0
  82. data/lib/active_record/connection_adapters/postgresql/oid/integer.rb +11 -0
  83. data/lib/active_record/connection_adapters/postgresql/oid/json.rb +35 -0
  84. data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +23 -0
  85. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +43 -0
  86. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +43 -0
  87. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +79 -0
  88. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +19 -0
  89. data/lib/active_record/connection_adapters/postgresql/oid/time.rb +11 -0
  90. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +109 -0
  91. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +21 -0
  92. data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +26 -0
  93. data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +28 -0
  94. data/lib/active_record/connection_adapters/postgresql/oid.rb +29 -388
  95. data/lib/active_record/connection_adapters/postgresql/quoting.rb +46 -136
  96. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +4 -4
  97. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +152 -0
  98. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +131 -43
  99. data/lib/active_record/connection_adapters/postgresql/utils.rb +77 -0
  100. data/lib/active_record/connection_adapters/postgresql_adapter.rb +224 -477
  101. data/lib/active_record/connection_adapters/schema_cache.rb +14 -28
  102. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +61 -75
  103. data/lib/active_record/connection_handling.rb +1 -1
  104. data/lib/active_record/core.rb +163 -39
  105. data/lib/active_record/counter_cache.rb +60 -6
  106. data/lib/active_record/enum.rb +9 -11
  107. data/lib/active_record/errors.rb +53 -30
  108. data/lib/active_record/explain.rb +1 -1
  109. data/lib/active_record/explain_subscriber.rb +1 -1
  110. data/lib/active_record/fixtures.rb +55 -69
  111. data/lib/active_record/gem_version.rb +4 -4
  112. data/lib/active_record/inheritance.rb +35 -10
  113. data/lib/active_record/integration.rb +4 -4
  114. data/lib/active_record/legacy_yaml_adapter.rb +30 -0
  115. data/lib/active_record/locking/optimistic.rb +46 -26
  116. data/lib/active_record/migration/command_recorder.rb +19 -2
  117. data/lib/active_record/migration/join_table.rb +1 -1
  118. data/lib/active_record/migration.rb +71 -46
  119. data/lib/active_record/model_schema.rb +52 -58
  120. data/lib/active_record/nested_attributes.rb +5 -5
  121. data/lib/active_record/no_touching.rb +1 -1
  122. data/lib/active_record/persistence.rb +46 -26
  123. data/lib/active_record/query_cache.rb +3 -3
  124. data/lib/active_record/querying.rb +10 -7
  125. data/lib/active_record/railtie.rb +18 -11
  126. data/lib/active_record/railties/databases.rake +50 -51
  127. data/lib/active_record/readonly_attributes.rb +0 -1
  128. data/lib/active_record/reflection.rb +273 -114
  129. data/lib/active_record/relation/batches.rb +0 -2
  130. data/lib/active_record/relation/calculations.rb +41 -37
  131. data/lib/active_record/relation/finder_methods.rb +70 -47
  132. data/lib/active_record/relation/merger.rb +39 -29
  133. data/lib/active_record/relation/predicate_builder/array_handler.rb +32 -13
  134. data/lib/active_record/relation/predicate_builder/relation_handler.rb +1 -5
  135. data/lib/active_record/relation/predicate_builder.rb +16 -8
  136. data/lib/active_record/relation/query_methods.rb +114 -65
  137. data/lib/active_record/relation/spawn_methods.rb +3 -0
  138. data/lib/active_record/relation.rb +57 -25
  139. data/lib/active_record/result.rb +18 -7
  140. data/lib/active_record/sanitization.rb +12 -2
  141. data/lib/active_record/schema.rb +0 -1
  142. data/lib/active_record/schema_dumper.rb +59 -28
  143. data/lib/active_record/schema_migration.rb +5 -4
  144. data/lib/active_record/scoping/default.rb +6 -4
  145. data/lib/active_record/scoping/named.rb +4 -0
  146. data/lib/active_record/serializers/xml_serializer.rb +3 -7
  147. data/lib/active_record/statement_cache.rb +95 -10
  148. data/lib/active_record/store.rb +5 -5
  149. data/lib/active_record/tasks/database_tasks.rb +61 -6
  150. data/lib/active_record/tasks/mysql_database_tasks.rb +20 -11
  151. data/lib/active_record/tasks/postgresql_database_tasks.rb +20 -9
  152. data/lib/active_record/timestamp.rb +9 -7
  153. data/lib/active_record/transactions.rb +53 -27
  154. data/lib/active_record/type/big_integer.rb +13 -0
  155. data/lib/active_record/type/binary.rb +50 -0
  156. data/lib/active_record/type/boolean.rb +31 -0
  157. data/lib/active_record/type/date.rb +50 -0
  158. data/lib/active_record/type/date_time.rb +54 -0
  159. data/lib/active_record/type/decimal.rb +64 -0
  160. data/lib/active_record/type/decimal_without_scale.rb +11 -0
  161. data/lib/active_record/type/decorator.rb +14 -0
  162. data/lib/active_record/type/float.rb +19 -0
  163. data/lib/active_record/type/hash_lookup_type_map.rb +23 -0
  164. data/lib/active_record/type/integer.rb +59 -0
  165. data/lib/active_record/type/mutable.rb +16 -0
  166. data/lib/active_record/type/numeric.rb +36 -0
  167. data/lib/active_record/type/serialized.rb +62 -0
  168. data/lib/active_record/type/string.rb +40 -0
  169. data/lib/active_record/type/text.rb +11 -0
  170. data/lib/active_record/type/time.rb +26 -0
  171. data/lib/active_record/type/time_value.rb +38 -0
  172. data/lib/active_record/type/type_map.rb +64 -0
  173. data/lib/active_record/type/unsigned_integer.rb +15 -0
  174. data/lib/active_record/type/value.rb +110 -0
  175. data/lib/active_record/type.rb +23 -0
  176. data/lib/active_record/validations/associated.rb +5 -3
  177. data/lib/active_record/validations/presence.rb +5 -3
  178. data/lib/active_record/validations/uniqueness.rb +25 -29
  179. data/lib/active_record/validations.rb +25 -19
  180. data/lib/active_record.rb +4 -0
  181. data/lib/rails/generators/active_record/migration/migration_generator.rb +8 -4
  182. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +1 -1
  183. data/lib/rails/generators/active_record/model/templates/model.rb +1 -1
  184. metadata +66 -11
  185. data/lib/active_record/connection_adapters/postgresql/cast.rb +0 -168
data/CHANGELOG.md CHANGED
@@ -1,2682 +1,2043 @@
1
- ## Rails 4.1.16 (July 12, 2016) ##
1
+ ## Rails 4.2.11.3 (May 15, 2020) ##
2
2
 
3
- * Correctly pass MySQL options when using structure_dump or structure_load
4
-
5
- Specifically, it fixes an issue when using SSL authentication.
6
-
7
- *Alex Coomans*
8
-
9
-
10
- ## Rails 4.1.15 (March 07, 2016) ##
11
-
12
- * Fixes custom primary keys for associations when calling `Relation#where`
13
-
14
- Fixes #23327.
15
-
16
- *Rick Song*
17
-
18
- * No longer pass deprecated option `-i` to `pg_dump`.
19
-
20
- *Paul Sadauskas*
21
-
22
-
23
- ## Rails 4.1.14.2 (February 26, 2016) ##
24
-
25
- * No changes.
26
-
27
-
28
- ## Rails 4.1.14.1 (January 25, 2015) ##
29
-
30
- * No changes.
31
-
32
-
33
- ## Rails 4.1.14 (November 12, 2015) ##
34
-
35
- * No longer pass deprecated option `-i` to `pg_dump`.
36
-
37
- *Paul Sadauskas*
38
-
39
- * Includes HABTM returns correct size now. It's caused by the join dependency
40
- only instantiates one HABTM object because the join table hasn't a primary key.
41
-
42
- Fixes #16032.
43
-
44
- Examples:
45
-
46
- before:
47
-
48
- Project.first.salaried_developers.size # => 3
49
- Project.includes(:salaried_developers).first.salaried_developers.size # => 1
50
-
51
- after:
52
-
53
- Project.first.salaried_developers.size # => 3
54
- Project.includes(:salaried_developers).first.salaried_developers.size # => 3
55
-
56
- *Bigxiang*
57
-
58
-
59
- ## Rails 4.1.13 (August 24, 2015) ##
60
-
61
- * Don't define autosave association callbacks twice from
62
- `accepts_nested_attributes_for`.
63
-
64
- Fixes #18704.
65
-
66
- *Sean Griffin*
67
-
68
-
69
- ## Rails 4.1.12 (June 25, 2015) ##
70
-
71
- * Raises the right exception when declares a has many through
72
- association with missing source.
73
-
74
- *Mauro George*
75
-
76
- * Revert behavior of `db:schema:load` back to loading the full
77
- environment. This ensures that initializers are run.
78
-
79
- Fixes #19545.
80
-
81
- *Yves Senn*
82
-
83
- * Rename `:class` to `:anonymous_class` in association options.
84
-
85
- Fixes #19659.
86
-
87
- *Andrew White*
88
-
89
- * Fix referencing wrong table aliases while joining tables of has many through
90
- association (only when calling calculation methods).
91
-
92
- Fixes #19276.
93
-
94
- *pinglamb*
95
-
96
-
97
- ## Rails 4.1.11 (June 16, 2015) ##
98
-
99
- * No changes.
100
-
101
-
102
- ## Rails 4.1.10 (March 19, 2015) ##
103
-
104
- * Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type column
105
-
106
- Fixes #17139.
107
-
108
- *Miklos Fazekas*
109
-
110
- * A `NullRelation` should represent nothing. This fixes a bug where
111
- `Comment.where(post_id: Post.none)` returned a non-empty result.
112
-
113
- Closes #15176.
114
-
115
- *Matthew Draper*, *Yves Senn*
116
-
117
- * Respect custom primary keys for associations when calling `Relation#where`
118
-
119
- Fixes #18813.
120
-
121
- *Sean Griffin*
122
-
123
- * Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
124
-
125
- SplitTest.group(:key).count
126
- Property.group(:value).count
127
-
128
- *Bogdan Gusiev*
129
-
130
- * Fixed setting of foreign_key for through associations while building of new record.
131
-
132
- Fixes #12698.
133
-
134
- *Ivan Antropov*
135
-
136
- * Fixed automatic inverse_of for models nested in module.
137
-
138
- *Andrew McCloud*
139
-
140
- * Fix `reaping_frequency` option when the value is a string.
141
-
142
- This usually happens when it is configured using `DATABASE_URL`.
143
-
144
- *korbin*
145
-
146
-
147
- ## Rails 4.1.9 (January 6, 2015) ##
148
-
149
- * `db:schema:load` and `db:structure:load` no longer purge the database
150
- before loading the schema. This is left for the user to do.
151
- `db:test:prepare` will still purge the database.
152
-
153
- Closes #17945.
154
-
155
- *Yves Senn*
156
-
157
- * Bring back `db:test:prepare` to synchronize the test database schema.
158
-
159
- Manual synchronization using `bin/rake db:test:prepare` is required
160
- when a migration is rolled-back, edited and reapplied.
161
-
162
- `ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
163
- to synchronize the schema. Plugins can use this task as a hook to
164
- provide custom behavior after the schema has been loaded.
165
-
166
- NOTE: `test:prepare` runs before the schema was synchronized.
167
-
168
- Fixes #17171, #15787.
169
-
170
- *Yves Senn*
171
-
172
- * Renaming a table in pg also renames the primary key index.
173
-
174
- Fixes #12856
175
-
176
- *Sean Griffin*
177
-
178
- * Make it possible to access fixtures excluded by a `default_scope`.
179
-
180
- *Yves Senn*
181
-
182
- * `timestamps` and `add_timestamps` passes additional options along.
183
- (like `null: false`)
184
-
185
- Closes #17624.
186
-
187
- *Yves Senn*
188
-
189
-
190
- ## Rails 4.1.8 (November 16, 2014) ##
191
-
192
- * Cache `CollectionAssociation#reader` proxies separately before and after
193
- the owner has been saved so that the proxy is not cached without the
194
- owner's id.
195
-
196
- *Ben Woosley*
197
-
198
- * Fix preloading of associations which unscope a default scope.
199
-
200
- Fixes #11036.
201
-
202
- *Byron Bischoff*
203
-
204
- * Do not use `RENAME INDEX` syntax for MariaDB 10.0.
205
-
206
- Fixes #15931.
207
-
208
- *Jeff Browning*
209
-
210
- * Allow included modules to override association methods.
211
-
212
- Fixes #16684.
213
-
214
- *Yves Senn*
215
-
216
- * Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
217
- the database connection to the current environment.
218
-
219
- Fixes #16757.
220
-
221
- *Joshua Cody*, *Yves Senn*
222
-
223
- * `db:purge` with MySQL respects `Rails.env`.
224
-
225
- *Yves Senn*
226
-
227
- * Fixed automatic maintaining test schema to properly handle sql structure
228
- schema format.
229
-
230
- Fixes #15394.
231
-
232
- *Wojciech Wnętrzak*
233
-
234
- * Fix has_many :through relation merging failing when dynamic conditions are
235
- passed as a lambda with an arity of one.
236
-
237
- Fixes #16128.
238
-
239
- *Agis Anastasopoulos*
240
-
241
-
242
- ## Rails 4.1.7.1 (November 19, 2014) ##
243
-
244
- * No changes.
245
-
246
-
247
- ## Rails 4.1.7 (October 29, 2014) ##
248
-
249
- * No changes.
250
-
251
-
252
- ## Rails 4.1.6 (September 11, 2014) ##
253
-
254
- * Fixed a regression where whitespaces were stripped from DISTINCT queries in
255
- PostgreSQL.
256
-
257
- *Agis Anastasopoulos*
258
-
259
- Fixes #16623.
260
-
261
- * Fixed an issue where custom accessor methods (such as those generated by
262
- `enum`) with the same name as a global method are incorrectly overridden
263
- when subclassing.
264
-
265
- Fixes #16288.
266
-
267
- * Baseclass becomes! subclass.
268
-
269
- Before this change, a record which changed its STI type, could not be found when updated.
270
- Setting update_record to the base class, ensures the record can be found.
271
-
272
- Fixes #14785.
273
-
274
- *Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
275
-
276
- * Fix regression on after_commit that didnt fire when having nested transactions.
277
-
278
- Fixes #16425.
279
-
280
- *arthurnn*
281
-
282
- * Define `id_was` to get the previous value of the primary key.
283
-
284
- Currently when we call id_was and we have a custom primary key name
285
- Active Record will return the current value of the primary key. This
286
- make impossible to correctly do an update operation if you change the
287
- id.
288
-
289
- Fixes #16413.
290
-
291
- *Rafael Mendonça França*
292
-
293
- * Fix the schema dump generated for tables without constraints and with
294
- primary key with default value of custom PostgreSQL function result.
295
-
296
- Fixes #16111.
297
-
298
- *Andrey Novikov*
299
-
300
- * Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
301
-
302
- With 4.1.x, `serialize` started returning a string when `JSON` was passed as
303
- the second attribute. It will now return a hash as per previous versions.
304
-
305
- Example:
306
-
307
- class Post < ActiveRecord::Base
308
- serialize :comment, JSON
309
- end
310
-
311
- class Comment
312
- include ActiveModel::Model
313
- attr_accessor :category, :text
314
- end
315
-
316
- post = Post.create!
317
- post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
318
- post.save!
319
-
320
- # 4.0
321
- post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
322
-
323
- # 4.1 before
324
- post.comment # => "#<Comment:0x007f80ab48ff98>"
325
-
326
- # 4.1 after
327
- post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
328
-
329
- When using `JSON` as the coder in `serialize`, Active Record will use the
330
- new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
331
- `ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
332
- correctly using the `#as_json` hook.
333
-
334
- To keep the previous behaviour, supply a custom coder instead
335
- ([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
336
-
337
- Fixes #15594.
338
-
339
- *Jenn Cooper*
340
-
341
- * Fixed error in `reset_counters` when associations have `select` scope.
342
- (Call to `count` generates invalid SQL.)
343
-
344
- *Cade Truitt*
345
-
346
- * After a successful `reload`, `new_record?` is always false.
347
-
348
- Fixes #12101.
349
-
350
- *Matthew Draper*
351
-
352
- * Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
353
- are part of the URI structure, not the actual host.
354
-
355
- Fixes #15705.
356
-
357
- *Andy Bakun*, *Aaron Stone*
358
-
359
- * Don't error when quoting user defined types in PostgreSQL.
360
-
361
- Fixes #15697.
362
-
363
- *Sean Griffin*
364
-
365
- * Ensure both parent IDs are set on join records when both sides of a
366
- through association are new.
367
-
368
- *Sean Griffin*
369
-
370
- * Pluck now works when selecting columns from different tables with the same
371
- name.
372
-
373
- Fixes #15649.
374
-
375
- *Sean Griffin*
376
-
377
- * `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
378
- `Enumerable#find` does.
379
-
380
- Fixes #15382.
381
-
382
- *James Yang*
383
-
384
- * `ActiveRecord::SchemaMigration` has no primary key regardless of the
385
- `primary_key_prefix_type` configuration.
386
-
387
- Fixes #15051.
388
-
389
- *JoseLuis Torres*, *Yves Senn*
390
-
391
- * `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
392
-
393
- Fixes #15538.
394
-
395
- *Yves Senn*
396
-
397
- * Fixed `columns_for_distinct` of postgresql adapter to work correctly
398
- with orders without sort direction modifiers.
399
-
400
- *Nikolay Kondratyev*
401
-
402
- * Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
403
- Fixes duplication in combination with `store_accessor`.
404
-
405
- Fixes #15369.
406
-
407
- *Yves Senn*
408
-
409
- * `rake railties:install:migrations` respects the order of railties.
410
-
411
- *Arun Agrawal*
412
-
413
-
414
- ## Rails 4.1.5 (August 18, 2014) ##
415
-
416
- * No changes.
417
-
418
-
419
- ## Rails 4.1.4 (July 2, 2014) ##
420
-
421
- * Fix regression added from the latest security fix.
422
-
423
- *Sean Griffin*, *Matthew Draper*
424
-
425
-
426
- ## Rails 4.1.3 (July 2, 2014) ##
427
-
428
- * Fix SQL Injection Vulnerability in 'range' quoting.
429
-
430
- Fixes CVE-2014-3483
431
-
432
- *Rafael Mendonça França*
433
-
434
-
435
- ## Rails 4.1.2 (June 26, 2014) ##
436
-
437
- * Fix regression on eager loading association based on SQL query rather than
438
- existing column.
439
-
440
- Fixes #15480.
3
+ * No changes.
441
4
 
442
- *Lauro Caetano*, *Carlos Antonio da Silva*
443
5
 
444
- * Fix redefine a has_and_belongs_to_many inside inherited class
445
- Fixing regression case, where redefining the same has_an_belongs_to_many
446
- definition into a subclass would raise.
6
+ ## Rails 4.2.11.2 (May 15, 2020) ##
447
7
 
448
- Fixes #14983.
8
+ * No changes.
449
9
 
450
- *arthurnn*
451
10
 
452
- * Fix has_and_belongs_to_many public reflection.
453
- When defining a has_and_belongs_to_many, internally we convert that to two has_many.
454
- But as `reflections` is a public API, people expect to see the right macro.
11
+ ## Rails 4.2.11.1 (March 11, 2019) ##
455
12
 
456
- Fixes #14682.
13
+ * No changes.
457
14
 
458
- *arthurnn*
459
15
 
460
- * Fixed serialization for records with an attribute named `format`.
16
+ ## Rails 4.2.11 (November 27, 2018) ##
461
17
 
462
- Fixes #15188.
18
+ * No changes.
463
19
 
464
- *Godfrey Chan*
465
20
 
466
- * Fixed serialized fields returning serialized data after being updated with
467
- `update_column`.
21
+ ## Rails 4.2.10 (September 27, 2017) ##
468
22
 
469
- *Simon Hørup Eskildsen*
23
+ * `Relation#joins` is no longer affected by the target model's
24
+ `current_scope`, with the exception of `unscoped`.
470
25
 
471
- * When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
472
- on a NullRelation should return a Hash.
26
+ Fixes #29338.
473
27
 
474
- *Kuldeep Aggarwal*
28
+ *Sean Griffin*
475
29
 
476
- * Fixed polymorphic eager loading when using a String as foreign key.
30
+ ## Rails 4.2.9 (June 26, 2017) ##
477
31
 
478
- Fixes #14734.
32
+ * Fix regression caused by `collection_singular_ids=` ignoring different primary key on relationship.
479
33
 
480
- *Lauro Caetano*
34
+ *Nick Pezza*
481
35
 
482
- * Fixed the inferred table name of a has_and_belongs_to_many auxiliar
483
- table inside a schema.
36
+ * Fix `rake db:schema:load` with subdirectories.
484
37
 
485
- Fixes #14824
38
+ *Ryuta Kamizono*
486
39
 
487
- *Eric Chahin*
40
+ * Fix `rake db:migrate:status` with subdirectories.
488
41
 
489
- * Fix bug that added `table_name_prefix` and `table_name_suffix` to
490
- extension names in PostgreSQL when migrating.
42
+ *Ryuta Kamizono*
491
43
 
492
- *Joao Carlos*
44
+ * Fix regression of #1969 with SELECT aliases in HAVING clause.
493
45
 
494
- * Floats with limit >= 25 that get turned into doubles in MySQL no longer have
495
- their limit dropped from the schema.
46
+ *Eugene Kenny*
496
47
 
497
- Fixes #14135.
48
+ * Fix `wait_timeout` to configurable for mysql2 adapter.
498
49
 
499
- *Aaron Nelson*
50
+ Fixes #26556.
500
51
 
501
- * Fix how to calculate associated class name when using namespaced has_and_belongs_to_many
502
- association.
52
+ *Ryuta Kamizono*
503
53
 
504
- Fixes #14709.
54
+ * Make `table_name=` reset current statement cache,
55
+ so queries are not run against the previous table name.
505
56
 
506
- *Kassio Borges*
57
+ *namusyaka*
507
58
 
508
- * `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
509
- strings in column names as equal.
510
59
 
511
- This fixes a rare case in which more bind values are passed than there are
512
- placeholders for them in the generated SQL statement, which can make PostgreSQL
513
- throw a `StatementInvalid` exception.
60
+ ## Rails 4.2.8 (February 21, 2017) ##
514
61
 
515
- *Nat Budin*
62
+ * Using a mysql2 connection after it fails to reconnect will now have an error message
63
+ saying the connection is closed rather than an undefined method error message.
516
64
 
517
- * Fix `stored_attributes` to correctly merge the details of stored
518
- attributes defined in parent classes.
65
+ *Dylan Thacker-Smith*
519
66
 
520
- Fixes #14672.
67
+ * Bust Model.attribute_names cache when resetting column information
521
68
 
522
- *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
69
+ *James Coleman*
523
70
 
524
- * `change_column_default` allows `[]` as argument to `change_column_default`.
71
+ * Fix query caching when type information is reset
525
72
 
526
- Fixes #11586.
73
+ Backports ancillary fix in 5.0.
527
74
 
528
- *Yves Senn*
75
+ *James Coleman*
529
76
 
530
- * Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
531
- NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
77
+ * Allow `joins` to be unscoped.
532
78
 
533
- Example:
79
+ Fixes #13775.
534
80
 
535
- # Before
536
- Point.create(value: 1.0/0)
537
- Point.last.value # => 0.0
81
+ *Takashi Kokubun*
538
82
 
539
- # After
540
- Point.create(value: 1.0/0)
541
- Point.last.value # => Infinity
83
+ * Hashes can once again be passed to setters of `composed_of`, if all of the
84
+ mapping methods are methods implemented on `Hash`.
542
85
 
543
- *Innokenty Mikhailov*
86
+ Fixes #25978.
544
87
 
545
- * Allow the PostgreSQL adapter to handle bigserial primary key types again.
88
+ *Sean Griffin*
546
89
 
547
- Fixes #10410.
548
90
 
549
- *Patrick Robertson*
91
+ ## Rails 4.2.7 (July 12, 2016) ##
550
92
 
551
- * Fixed has_and_belongs_to_many's CollectionAssociation size calculation.
93
+ * Inspecting an object with an associated array of over 10 elements no longer
94
+ truncates the array, preventing `inspect` from looping infinitely in some
95
+ cases.
552
96
 
553
- has_and_belongs_to_many should fall back to using the normal CollectionAssociation's
554
- size calculation if the collection is not cached or loaded.
97
+ *Kevin McPhillips*
555
98
 
556
- Fixes #14913 and #14914.
99
+ * Ensure hashes can be assigned to attributes created using `composed_of`.
100
+ Fixes #25210.
557
101
 
558
- *Fred Wu*
102
+ *Sean Griffin*
559
103
 
560
- * Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
104
+ * Queries such as `Computer.joins(:monitor).group(:status).count` will now be
105
+ interpreted as `Computer.joins(:monitor).group('computers.status').count`
106
+ so that when `Computer` and `Monitor` have both `status` columns we don't
107
+ have conflicts in projection.
561
108
 
562
- In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
563
- In 4.0 series it is delegated to `Array#join`.
109
+ *Rafael Sales*
564
110
 
565
- *Bogdan Gusiev*
111
+ * ActiveRecord::Relation#count: raise an ArgumentError when finder options
112
+ are specified or an ActiveRecord::StatementInvalid when an invalid type
113
+ is provided for a column name (e.g. a Hash).
566
114
 
567
- * Log nil binary column values correctly.
115
+ Fixes #20434
568
116
 
569
- When an object with a binary column is updated with a nil value
570
- in that column, the SQL logger would throw an exception when trying
571
- to log that nil value. This only occurs when updating a record
572
- that already has a non-nil value in that column since an initial nil
573
- value isn't included in the SQL anyway (at least, when dirty checking
574
- is enabled.) The column's new value will now be logged as `<NULL binary data>`
575
- to parallel the existing `<N bytes of binary data>` for non-nil values.
117
+ *Konstantinos Rousis*
576
118
 
577
- *James Coleman*
119
+ * Correctly pass MySQL options when using structure_dump or structure_load
578
120
 
579
- * Stringify all variables keys of MySQL connection configuration.
121
+ Specifically, it fixes an issue when using SSL authentication.
580
122
 
581
- When `sql_mode` variable for MySQL adapters set in configuration as `String`
582
- was ignored and overwritten by strict mode option.
123
+ *Alex Coomans*
583
124
 
584
- Fixes #14895.
585
125
 
586
- *Paul Nikitochkin*
126
+ ## Rails 4.2.6 (March 07, 2016) ##
587
127
 
588
- * Ensure SQLite3 statements are closed on errors.
128
+ * Fix a bug where using `t.foreign_key` twice with the same `to_table` within
129
+ the same table definition would only create one foreign key.
589
130
 
590
- Fixes #13631.
131
+ *George Millo*
591
132
 
592
- *Timur Alperovich*
133
+ * Fix regression in dirty attribute tracking after #dup. Changes to the
134
+ clone no longer show as changed attributes in the original object.
593
135
 
594
- * Fix excluding lower bounds of PostgreSQL date and int ranges.
136
+ *Dominic Cleal*
595
137
 
596
- *River MacLeod*, *Yves Senn*
138
+ * Fix regression when loading fixture files with symbol keys.
597
139
 
598
- * When using a custom `join_table` name on a `habtm`, rails was not saving it
599
- on Reflections. This causes a problem when rails loads fixtures, because it
600
- uses the reflections to set database with fixtures.
140
+ Closes #22584.
601
141
 
602
- Fixes #14845.
142
+ *Yves Senn*
603
143
 
604
- *Kassio Borges*
144
+ * Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
605
145
 
606
- * `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
146
+ Fixes #22346.
607
147
 
608
- Fixes #14841.
148
+ *Nick Muerdter*, *ckoenig*
609
149
 
610
- *Lucas Mazza*
150
+ * Introduce `connection.data_sources` and `connection.data_source_exists?`.
151
+ These methods determine what relations can be used to back Active Record
152
+ models (usually tables and views).
611
153
 
612
- * Fix name collision with `Array#select!` with `Relation#select!`.
154
+ *Yves Senn*, *Matthew Draper*
613
155
 
614
- Fixes #14752.
615
156
 
616
- *Earl St Sauver*
157
+ ## Rails 4.2.5.2 (February 26, 2016) ##
617
158
 
618
- * Fixed unexpected behavior for `has_many :through` associations going through a scoped `has_many`.
159
+ * No changes.
619
160
 
620
- If a `has_many` association is adjusted using a scope, and another `has_many :through`
621
- uses this association, then the scope adjustment is unexpectedly neglected.
622
161
 
623
- Fixes #14537.
162
+ ## Rails 4.2.5.1 (January 25, 2015) ##
624
163
 
625
- *Jan Habermann*
164
+ * No changes.
626
165
 
627
- * When a destroyed record is duped, the dup is not `destroyed?`.
628
166
 
629
- *Kuldeep Aggarwal*
167
+ ## Rails 4.2.5 (November 12, 2015) ##
630
168
 
631
- * Fixed has_many association to make it support irregular inflections.
169
+ * No longer pass deprecated option `-i` to `pg_dump`.
632
170
 
633
- Fixes #8928.
171
+ *Paul Sadauskas*
634
172
 
635
- *arthurnn*, *Javier Goizueta*
173
+ * Set `scope.reordering_value` to `true` if :reordering values are specified.
636
174
 
637
- * Calling `delete_all` on an unloaded `CollectionProxy` no longer
638
- generates a SQL statement containing each id of the collection:
175
+ Fixes #21886.
639
176
 
640
- Before:
177
+ *Hiroaki Izu*
641
178
 
642
- DELETE FROM `model` WHERE `model`.`parent_id` = 1
643
- AND `model`.`id` IN (1, 2, 3...)
179
+ * Avoid disabling errors on the PostgreSQL connection when enabling the
180
+ standard_conforming_strings setting. Errors were previously disabled because
181
+ the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
182
+ versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
183
+ setting exists. Disabling errors caused problems when using a connection
184
+ pooling tool like PgBouncer because it's not guaranteed to have the same
185
+ connection between calls to `execute` and it could leave the connection
186
+ with errors disabled.
644
187
 
645
- After:
188
+ Fixes #22101.
646
189
 
647
- DELETE FROM `model` WHERE `model`.`parent_id` = 1
190
+ *Harry Marr*
648
191
 
649
- *Eileen M. Uchitelle*, *Aaron Patterson*
192
+ * Includes HABTM returns correct size now. It's caused by the join dependency
193
+ only instantiates one HABTM object because the join table hasn't a primary key.
650
194
 
651
- * Fixed a problem where count used with a grouping was not returning a Hash.
195
+ Fixes #16032.
652
196
 
653
- Fixes #14721.
197
+ Examples:
654
198
 
655
- *Eric Chahin*
199
+ before:
656
200
 
657
- * Do not quote uuid default value on `change_column`.
201
+ Project.first.salaried_developers.size # => 3
202
+ Project.includes(:salaried_developers).first.salaried_developers.size # => 1
658
203
 
659
- Fixes #14604.
204
+ after:
660
205
 
661
- *Eric Chahin*
206
+ Project.first.salaried_developers.size # => 3
207
+ Project.includes(:salaried_developers).first.salaried_developers.size # => 3
662
208
 
663
- * The comparison between `Relation` and `CollectionProxy` should be consistent.
209
+ *Bigxiang*
664
210
 
665
- Example:
211
+ * Descriptive error message when fixtures contain a missing column.
666
212
 
667
- author.posts == Post.where(author_id: author.id)
668
- # => true
669
- Post.where(author_id: author.id) == author.posts
670
- # => true
213
+ Closes #21201.
671
214
 
672
- Fixes #13506.
215
+ *Yves Senn*
673
216
 
674
- *Lauro Caetano*
217
+ * `bin/rake db:migrate` uses
218
+ `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
219
+ `Migrator.migrations_paths`.
675
220
 
676
- * PostgreSQL adapter only warns once for every missing OID per connection.
221
+ *Tobias Bielohlawek*
677
222
 
678
- Fixes #14275.
223
+ * Fix `rewhere` in a `has_many` association.
679
224
 
680
- *Matthew Draper*, *Yves Senn*
225
+ Fixes #21955.
681
226
 
682
- * Fixed error for aggregate methods (`empty?`, `any?`, `count`) with `select`
683
- which created invalid SQL.
227
+ *Josh Branchaud*, *Kal*
684
228
 
685
- Fixes #13648.
229
+ * Added run_cmd class method to ActiveRecord::Tasks::DatabaseTasks for
230
+ drying up Kernel.system() calls within this namespace and to avoid
231
+ shell expansion by using a paramter list instead of string as arguments
232
+ for Kernel.system(). Thanks to Nate Berkopec for supply patch to get
233
+ test units passing.
686
234
 
687
- *Simon Woker*
235
+ *Bryan Paxton*
688
236
 
689
- * Fix insertion of records via `has_many :through` association with scope.
237
+ * Avoid leaking the first relation we call `first` on, per model.
690
238
 
691
- Fixes #3548.
239
+ Fixes #21921.
692
240
 
693
- *Ivan Antropov*
241
+ *Matthew Draper*, *Jean Boussier*
694
242
 
695
- * Make possible to have an association called `records`.
243
+ * Allow deserialization of Active Record models that were YAML encoded prior
244
+ to Rails 4.2
696
245
 
697
- Fixes #11645.
246
+ *Sean Griffin*
698
247
 
699
- *prathamesh-sonpatki*
248
+ * Correctly apply `unscope` when preloading through associations.
700
249
 
701
- * `to_sql` on an association now matches the query that is actually executed, where it
702
- could previously have incorrectly accrued additional conditions (e.g. as a result of
703
- a previous query). CollectionProxy now always defers to the association scope's
704
- `arel` method so the (incorrect) inherited one should be entirely concealed.
250
+ *Jimmy Bourassa*
705
251
 
706
- Fixes #14003.
252
+ * Ensure `select` quotes aliased attributes, even when using `from`.
707
253
 
708
- *Jefferson Lai*
254
+ Fixes #21488
709
255
 
710
- * Fixed error when using `with_options` with lambda.
256
+ *Sean Griffin & @johanlunds*
711
257
 
712
- Fixes #9805.
258
+ * Correct query for PostgreSQL 8.2 compatibility.
713
259
 
714
- *Lauro Caetano*
260
+ *Ben Murphy*, *Matthew Draper*
715
261
 
716
- * Fixed error when specifying a non-empty default value on a PostgreSQL array column.
262
+ * Uniqueness validator raises descriptive error when running on a persisted
263
+ record without primary key.
717
264
 
718
- Fixes #10613.
265
+ Closes #21304.
719
266
 
720
- *Luke Steensen*
267
+ *Yves Senn*
721
268
 
722
- * Fixed error where .persisted? throws SystemStackError for an unsaved model with a
723
- custom primary key that didn't save due to validation error.
724
269
 
725
- Fixes #14393.
270
+ ## Rails 4.2.4 (August 24, 2015) ##
726
271
 
727
- *Chris Finne*
272
+ * Skip statement cache on through association reader.
728
273
 
729
- * `rake db:structure:dump` only dumps schema information if the schema
730
- migration table exists.
274
+ If the through class has default scopes we should skip the statement
275
+ cache.
731
276
 
732
- Fixes #14217.
277
+ Closes #20745.
733
278
 
734
- *Yves Senn*
279
+ *Rafael Mendonça França*
735
280
 
736
- * Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
281
+ * Fixes #19420. When generating schema.rb using Postgres BigInt[] data type
282
+ the limit: 8 was not coming through. This caused it to become Int[] data type
283
+ after doing a rebuild off of schema.rb.
737
284
 
738
- Fixes #14361.
285
+ *Jake Waller*
739
286
 
740
- *arthurnn*
287
+ * Fix state being carried over from previous transaction.
741
288
 
742
- * Only save `has_one` associations if record has changes. Previously after save
743
- related callbacks, such as `#after_commit`, were triggered when the
744
- `has_one` object did not get saved to the db.
289
+ Considering the following example where `name` is a required attribute.
290
+ Before we had `new_record?` returning `true` for a persisted record:
745
291
 
746
- *Alan Kennedy*
292
+ author = Author.create! name: 'foo'
293
+ author.name = nil
294
+ author.save # => false
295
+ author.new_record? # => true
747
296
 
297
+ Fixes #20824.
748
298
 
749
- ## Rails 4.1.1 (May 6, 2014) ##
299
+ *Roque Pinel*
750
300
 
751
- * No changes.
301
+ * Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
302
+ when validating associations.
752
303
 
304
+ Fixes #20882.
753
305
 
754
- ## Rails 4.1.0 (April 8, 2014) ##
306
+ *Sean Griffin*
755
307
 
756
- * Fixed a problem where an enum would overwrite values of another enum
757
- with the same name in an unrelated class.
308
+ * Fix through associations using scopes having the scope merged multiple
309
+ times.
758
310
 
759
- Fixes #14607.
311
+ Fixes #20721.
312
+ Fixes #20727.
760
313
 
761
- *Evan Whalen*
314
+ *Sean Griffin*
762
315
 
316
+ * `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
317
+ other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
763
318
 
764
- * Block a few default Class methods as scope name.
319
+ Fixes #20743.
765
320
 
766
- For instance, this will raise:
321
+ *Yves Senn*
767
322
 
768
- scope :public, -> { where(status: 1) }
323
+ * Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
324
+ a wrong type to a namespaced association.
769
325
 
770
- *arthurnn*
326
+ Fixes #20545.
771
327
 
772
- * Deprecate SQLite database URLs containing an
773
- authority.
328
+ *Diego Carrion*
774
329
 
775
- The current "correct" spellings for in-memory, relative, and
776
- absolute URLs, respectively, are:
330
+ * Prevent error when using `force_reload: true` on an unassigned polymorphic
331
+ belongs_to association.
777
332
 
778
- sqlite3::memory:
779
- sqlite3:relative/path
780
- sqlite3:/full/path
333
+ Fixes #20426.
781
334
 
782
- The previous spelling (`sqlite3:///relative/path`) continues to work
783
- as it did in Rails 4.0, but with a deprecation warning: in the next
784
- release, that spelling will instead be interpreted as an absolute
785
- path.
335
+ *James Dabbs*
786
336
 
787
- *Matthew Draper*
788
337
 
789
- * `where.not` adds `references` for `includes` like normal `where` calls do.
338
+ ## Rails 4.2.3 (June 25, 2015) ##
790
339
 
791
- Fixes #14406.
340
+ * Let `WITH` queries (Common Table Expressions) be explainable.
792
341
 
793
- *Yves Senn*
342
+ *Vladimir Kochnev*
794
343
 
795
- * `includes` is able to detect the right preloading strategy when string
796
- joins are involved.
344
+ * Fix n+1 query problem when eager loading nil associations (fixes #18312)
797
345
 
798
- Fixes #14109.
346
+ *Sammy Larbi*
799
347
 
800
- *Aaron Patterson*, *Yves Senn*
348
+ * Fixed an error which would occur in dirty checking when calling
349
+ `update_attributes` from a getter.
801
350
 
802
- * Fixed error with validation with enum fields for records where the
803
- value for any enum attribute is always evaluated as 0 during
804
- uniqueness validation.
351
+ Fixes #20531.
805
352
 
806
- Fixes #14172.
353
+ *Sean Griffin*
807
354
 
808
- *Vilius Luneckas* *Ahmed AbouElhamayed*
355
+ * Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
356
+ as columns.
809
357
 
810
- * `before_add` callbacks are fired before the record is saved on
811
- `has_and_belongs_to_many` assocations *and* on `has_many :through`
812
- associations. Before this change, `before_add` callbacks would be fired
813
- before the record was saved on `has_and_belongs_to_many` associations, but
814
- *not* on `has_many :through` associations.
358
+ Fixes #20360.
815
359
 
816
- Fixes #14144.
360
+ *Sean Griffin*
817
361
 
818
- * Fixed STI classes not defining an attribute method if there is a
819
- conflicting private method defined on its ancestors.
362
+ * Clear query cache when `ActiveRecord::Base#reload` is called.
820
363
 
821
- Fixes #11569.
364
+ *Shane Hender*
822
365
 
823
- *Godfrey Chan*
366
+ * Pass `:extend` option for `has_and_belongs_to_many` associations to the
367
+ underlying `has_many :through`.
824
368
 
825
- * Default scopes are no longer overriden by chained conditions.
369
+ *Jaehyun Shin*
826
370
 
827
- Before this change when you defined a `default_scope` in a model
828
- it was overriden by chained conditions in the same field. Now it
829
- is merged like any other scope.
371
+ * Make `unscope` aware of "less than" and "greater than" conditions.
830
372
 
831
- Before:
373
+ *TAKAHASHI Kazuaki*
832
374
 
833
- class User < ActiveRecord::Base
834
- default_scope { where state: 'pending' }
835
- scope :active, -> { where state: 'active' }
836
- scope :inactive, -> { where state: 'inactive' }
837
- end
375
+ * Revert behavior of `db:schema:load` back to loading the full
376
+ environment. This ensures that initializers are run.
838
377
 
839
- User.all
840
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
378
+ Fixes #19545.
841
379
 
842
- User.active
843
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
380
+ *Yves Senn*
844
381
 
845
- User.where(state: 'inactive')
846
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
382
+ * Fix missing index when using `timestamps` with the `index` option.
847
383
 
848
- After:
384
+ The `index` option used with `timestamps` should be passed to both
385
+ `column` definitions for `created_at` and `updated_at` rather than just
386
+ the first.
849
387
 
850
- class User < ActiveRecord::Base
851
- default_scope { where state: 'pending' }
852
- scope :active, -> { where state: 'active' }
853
- scope :inactive, -> { where state: 'inactive' }
854
- end
388
+ *Paul Mucur*
855
389
 
856
- User.all
857
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
390
+ * Rename `:class` to `:anonymous_class` in association options.
858
391
 
859
- User.active
860
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'active'
392
+ Fixes #19659.
861
393
 
862
- User.where(state: 'inactive')
863
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'inactive'
394
+ *Andrew White*
864
395
 
865
- To get the previous behavior it is needed to explicitly remove the
866
- `default_scope` condition using `unscoped`, `unscope`, `rewhere` or
867
- `except`.
396
+ * Fixed a bug where uniqueness validations would error on out of range values,
397
+ even if an validation should have prevented it from hitting the database.
868
398
 
869
- Example:
399
+ *Andrey Voronkov*
870
400
 
871
- class User < ActiveRecord::Base
872
- default_scope { where state: 'pending' }
873
- scope :active, -> { unscope(where: :state).where(state: 'active') }
874
- scope :inactive, -> { rewhere state: 'inactive' }
875
- end
401
+ * Foreign key related methods in the migration DSL respect
402
+ `ActiveRecord::Base.pluralize_table_names = false`.
876
403
 
877
- User.all
878
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
404
+ Fixes #19643.
879
405
 
880
- User.active
881
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
406
+ *Mehmet Emin İNAÇ*
882
407
 
883
- User.inactive
884
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
408
+ * Reduce memory usage from loading types on pg.
885
409
 
886
- * Perform necessary deeper encoding when hstore is inside an array.
410
+ Fixes #19578.
887
411
 
888
- Fixes #11135.
412
+ *Sean Griffin*
889
413
 
890
- *Josh Goodall*, *Genadi Samokovarov*
414
+ * Fix referencing wrong table aliases while joining tables of has many through
415
+ association (only when calling calculation methods).
891
416
 
892
- * Properly detect if a connection is still active before using it
893
- in multi-threaded environments.
417
+ Fixes #19276.
894
418
 
895
- Fixes #12867.
419
+ *pinglamb*
896
420
 
897
- *Kevin Casey*, *Matthew Draper*, *William (B.J.) Snow Orvis*
421
+ * Don't attempt to update counter caches, when the column wasn't selected.
898
422
 
899
- * When inverting add_index use the index name if present instead of
900
- the columns.
423
+ Fixes #19437.
901
424
 
902
- If there are two indices with matching columns and one of them is
903
- explicitly named then reverting the migration adding the named one
904
- would instead drop the unnamed one.
425
+ *Sean Griffin*
905
426
 
906
- The inversion of add_index will now drop the index by its name if
907
- it is present.
427
+ * Correctly persist a serialized attribute that has been returned to
428
+ its default value by an in-place modification.
908
429
 
909
- *Hubert Dąbrowski*
430
+ Fixes #19467.
910
431
 
911
- * Add flag to disable schema dump after migration.
432
+ *Matthew Draper*
912
433
 
913
- Add a config parameter on Active Record named `dump_schema_after_migration`
914
- which is true by default. Now schema dump does not happen at the
915
- end of migration rake task if `dump_schema_after_migration` is false.
434
+ * Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
916
435
 
917
- *Emil Soman*
436
+ *James Cox*
918
437
 
919
- * `find_in_batches`, `find_each`, `Result#each` and `Enumerable#index_by` now
920
- return an `Enumerator` that can calculate its size.
438
+ * Dont enroll records in the transaction if they dont have commit callbacks.
439
+ That was causing a memory grow problem when creating a lot of records inside a transaction.
921
440
 
922
- See also #13938.
441
+ Fixes #15549.
923
442
 
924
- *Marc-André Lafortune*
443
+ *Will Bryant*, *Aaron Patterson*
925
444
 
926
- * Make sure transaction state gets reset after a commit operation on the record.
445
+ * Correctly create through records when created on a has many through
446
+ association when using `where`.
927
447
 
928
- If a new transaction was open inside a callback, the record was loosing track
929
- of the transaction level state, and it was leaking that state.
448
+ Fixes #19073.
930
449
 
931
- Fixes #12566.
450
+ *Sean Griffin*
932
451
 
933
- *arthurnn*
934
452
 
935
- * Pass `has_and_belongs_to_many` `:autosave` option to
936
- the underlying `has_many :through` association.
453
+ ## Rails 4.2.2 (June 16, 2015) ##
937
454
 
938
- Fixes #13923.
455
+ * No Changes *
939
456
 
940
- *Yves Senn*
941
457
 
942
- * PostgreSQL implementation of `SchemaStatements#index_name_exists?`.
458
+ ## Rails 4.2.1 (March 19, 2015) ##
943
459
 
944
- The database agnostic implementation does not detect with indexes that are
945
- not supported by the ActiveRecord schema dumper. For example, expressions
946
- indexes would not be detected.
460
+ * Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type column
947
461
 
948
- Fixes #11018.
462
+ Fixes #17139.
949
463
 
950
- *Jonathan Baudanza*
464
+ *Miklos Fazekas*
951
465
 
952
- * Parsing PostgreSQL arrays with empty strings now works correctly.
466
+ * `remove_reference` with `foreign_key: true` removes the foreign key before
467
+ removing the column. This fixes a bug where it was not possible to remove
468
+ the column on MySQL.
953
469
 
954
- Previously, if you tried to parse `{"1","","2","","3"}` the result
955
- would be `["1","2","3"]`, removing the empty strings from the array,
956
- which would be incorrect. Now it will correctly produce `["1","","2","","3"]`
957
- as the result of parsing the above PostgreSQL array.
470
+ Fixes #18664.
958
471
 
959
- Fixes #13907.
472
+ *Yves Senn*
960
473
 
961
- *Maurício Linhares*
474
+ * Add a `:foreign_key` option to `references` and associated migration
475
+ methods. The model and migration generators now use this option, rather than
476
+ the `add_foreign_key` form.
962
477
 
963
- * Associations now raise `ArgumentError` on name conflicts.
478
+ *Sean Griffin*
964
479
 
965
- Dangerous association names conflicts include instance or class methods already
966
- defined by `ActiveRecord::Base`.
480
+ * Fix rounding problem for PostgreSQL timestamp column.
967
481
 
968
- Example:
482
+ If timestamp column have the precision, it need to format according to
483
+ the precision of timestamp column.
969
484
 
970
- class Car < ActiveRecord::Base
971
- has_many :errors
972
- end
973
- # Will raise ArgumentError.
485
+ *Ryuta Kamizono*
974
486
 
975
- Fixes #13217.
487
+ * Respect the database default charset for `schema_migrations` table.
976
488
 
977
- *Lauro Caetano*
489
+ The charset of `version` column in `schema_migrations` table is depend
490
+ on the database default charset and collation rather than the encoding
491
+ of the connection.
978
492
 
979
- * Fix regressions on `select_*` methods.
980
- When `select_*` methods receive a `Relation` object, they should be able to
981
- get the arel/binds from it.
982
- Also fix regressions on `select_rows` that was ignoring the binds.
493
+ *Ryuta Kamizono*
983
494
 
984
- Fixes #7538, #12017, #13731, #12056.
495
+ * Respect custom primary keys for associations when calling `Relation#where`
985
496
 
986
- *arthurnn*
497
+ Fixes #18813.
987
498
 
988
- * Active Record objects can now be correctly dumped, loaded and dumped again
989
- without issues.
499
+ *Sean Griffin*
990
500
 
991
- Previously, if you did `YAML.dump`, `YAML.load` and then `YAML.dump` again
992
- in an Active Record model that used serialization it would fail at the last
993
- dump due to the fields not being correctly serialized before being dumped
994
- to YAML. Now it is possible to dump and load the same object as many times
995
- as needed without any issues.
501
+ * Fixed several edge cases which could result in a counter cache updating
502
+ twice or not updating at all for `has_many` and `has_many :through`.
996
503
 
997
- Fixes #13861.
504
+ Fixes #10865.
998
505
 
999
- *Maurício Linhares*
506
+ *Sean Griffin*
1000
507
 
1001
- * `find_in_batches` now returns an `Enumerator` when called without a block, so that it
1002
- can be chained with other `Enumerable` methods.
508
+ * Foreign keys added by migrations were given random, generated names. This
509
+ meant a different `structure.sql` would be generated every time a developer
510
+ ran migrations on their machine.
1003
511
 
1004
- *Marc-André Lafortune*
512
+ The generated part of foreign key names is now a hash of the table name and
513
+ column name, which is consistent every time you run the migration.
1005
514
 
1006
- * `enum` now raises on "dangerous" name conflicts.
515
+ *Chris Sinjakli*
1007
516
 
1008
- Dangerous name conflicts includes instance or class method conflicts
1009
- with methods defined within `ActiveRecord::Base` but not its ancestors,
1010
- as well as conflicts with methods generated by other enums on the same
1011
- class.
517
+ * Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
1012
518
 
1013
- Fixes #13389.
519
+ SplitTest.group(:key).count
520
+ Property.group(:value).count
1014
521
 
1015
- *Godfrey Chan*
522
+ *Bogdan Gusiev*
1016
523
 
1017
- * `scope` now raises on "dangerous" name conflicts.
524
+ * Don't define autosave association callbacks twice from
525
+ `accepts_nested_attributes_for`.
1018
526
 
1019
- Similar to dangerous attribute methods, a scope name conflict is
1020
- dangerous if it conflicts with an existing class method defined within
1021
- `ActiveRecord::Base` but not its ancestors.
527
+ Fixes #18704.
1022
528
 
1023
- See also #13389.
529
+ *Sean Griffin*
1024
530
 
1025
- *Godfrey Chan*, *Philippe Creux*
531
+ * Integer types will no longer raise a `RangeError` when assigning an
532
+ attribute, but will instead raise when going to the database.
1026
533
 
1027
- * Correctly send an user provided statement to a `lock!()` call.
534
+ Fixes several vague issues which were never reported directly. See the
535
+ commit message from the commit which added this line for some examples.
1028
536
 
1029
- person.lock! 'FOR SHARE NOWAIT'
1030
- # Before: SELECT * ... LIMIT 1 FOR UPDATE
1031
- # After: SELECT * ... LIMIT 1 FOR SHARE NOWAIT
537
+ *Sean Griffin*
1032
538
 
1033
- Fixes #13788.
539
+ * Values which would error while being sent to the database (such as an
540
+ ASCII-8BIT string with invalid UTF-8 bytes on Sqlite3), no longer error on
541
+ assignment. They will still error when sent to the database, but you are
542
+ given the ability to re-assign it to a valid value.
1034
543
 
1035
- *Maurício Linhares*
544
+ Fixes #18580.
1036
545
 
1037
- * Handle aliased attributes `select()`, `order()` and `reorder()`.
546
+ *Sean Griffin*
1038
547
 
1039
- *Tsutomu Kuroda*
548
+ * Don't remove join dependencies in `Relation#exists?`
1040
549
 
1041
- * Reset the collection association when calling `reset` on it.
550
+ Fixes #18632.
1042
551
 
1043
- Before:
552
+ *Sean Griffin*
1044
553
 
1045
- post.comments.loaded? # => true
1046
- post.comments.reset
1047
- post.comments.loaded? # => true
554
+ * Invalid values assigned to a JSON column are assumed to be `nil`.
1048
555
 
1049
- After:
556
+ Fixes #18629.
1050
557
 
1051
- post.comments.loaded? # => true
1052
- post.comments.reset
1053
- post.comments.loaded? # => false
558
+ *Sean Griffin*
1054
559
 
1055
- Fixes #13777.
560
+ * No longer issue deprecation warning when including a scope with extensions.
561
+ Previously every scope with extension methods was transformed into an
562
+ instance dependent scope. Including such a scope would wrongfully issue a
563
+ deprecation warning. This is no longer the case.
1056
564
 
1057
- *Kelsey Schlarman*
565
+ Fixes #18467.
1058
566
 
1059
- * Make enum fields work as expected with the `ActiveModel::Dirty` API.
567
+ *Yves Senn*
1060
568
 
1061
- Before this change, using the dirty API would have surprising results:
569
+ * Correctly use the type provided by `serialize` when updating records using
570
+ optimistic locking.
1062
571
 
1063
- conversation = Conversation.new
1064
- conversation.status = :active
1065
- conversation.status = :archived
1066
- conversation.status_was # => 0
572
+ Fixes #18385.
1067
573
 
1068
- After this change, the same code would result in:
574
+ *Sean Griffin*
1069
575
 
1070
- conversation = Conversation.new
1071
- conversation.status = :active
1072
- conversation.status = :archived
1073
- conversation.status_was # => "active"
576
+ * `attribute_will_change!` will no longer cause non-persistable attributes to
577
+ be sent to the database.
1074
578
 
1075
- *Rafael Mendonça França*
579
+ Fixes #18407.
1076
580
 
1077
- * `has_one` and `belongs_to` accessors don't add ORDER BY to the queries
1078
- anymore.
581
+ *Sean Griffin*
1079
582
 
1080
- Since Rails 4.0, we add an ORDER BY in the `first` method to ensure
1081
- consistent results among different database engines. But for singular
1082
- associations this behavior is not needed since we will have one record to
1083
- return. As this ORDER BY option can lead some performance issues we are
1084
- removing it for singular associations accessors.
583
+ * Format the datetime string according to the precision of the datetime field.
1085
584
 
1086
- Fixes #12623.
585
+ Incompatible to rounding behavior between MySQL 5.6 and earlier.
1087
586
 
1088
- *Rafael Mendonça França*
587
+ In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
588
+ is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
1089
589
 
1090
- * Prepend table name for column names passed to `Relation#select`.
590
+ http://bugs.mysql.com/bug.php?id=68760
1091
591
 
1092
- Example:
592
+ *Ryuta Kamizono*
1093
593
 
1094
- Post.select(:id)
1095
- # Before: => SELECT id FROM "posts"
1096
- # After: => SELECT "posts"."id" FROM "posts"
594
+ * Allow precision option for MySQL datetimes.
1097
595
 
1098
- *Yves Senn*
596
+ *Ryuta Kamizono*
1099
597
 
1100
- * Fail early with "Primary key not included in the custom select clause"
1101
- in `find_in_batches`.
598
+ * Clear query cache on rollback.
1102
599
 
1103
- Before this patch, the exception was raised after the first batch was
1104
- yielded to the block. This means that you only get it, when you hit the
1105
- `batch_size` treshold. This could shadow the issue in development.
600
+ *Florian Weingarten*
1106
601
 
1107
- *Alexander Balashov*
602
+ * Fixed setting of foreign_key for through associations while building of new record.
1108
603
 
1109
- * Ensure `second` through `fifth` methods act like the `first` finder.
604
+ Fixes #12698.
1110
605
 
1111
- The famous ordinal Array instance methods defined in ActiveSupport
1112
- (`first`, `second`, `third`, `fourth`, and `fifth`) are now available as
1113
- full-fledged finders in ActiveRecord. The biggest benefit of this is ordering
1114
- of the records returned now defaults to the table's primary key in ascending order.
606
+ *Ivan Antropov*
1115
607
 
1116
- Fixes #13743.
608
+ * Fixed automatic inverse_of for models nested in module.
1117
609
 
1118
- Example:
610
+ *Andrew McCloud*
1119
611
 
1120
- User.all.second
612
+ * Fix `reaping_frequency` option when the value is a string.
1121
613
 
1122
- # Before
1123
- # => 'SELECT "users".* FROM "users"'
614
+ This usually happens when it is configured using `DATABASE_URL`.
1124
615
 
1125
- # After
1126
- # => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 1'
616
+ *korbin*
1127
617
 
1128
- User.offset(3).second
618
+ * Fix error message when trying to create an associated record and the foreign
619
+ key is missing.
1129
620
 
1130
- # Before
1131
- # => 'SELECT "users".* FROM "users" LIMIT -1 OFFSET 3' # sqlite3 gem
1132
- # => 'SELECT "users".* FROM "users" OFFSET 3' # pg gem
1133
- # => 'SELECT `users`.* FROM `users` LIMIT 18446744073709551615 OFFSET 3' # mysql2 gem
621
+ Before this fix the following exception was being raised:
1134
622
 
1135
- # After
1136
- # => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 4'
623
+ NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
1137
624
 
1138
- *Jason Meller*
625
+ Now the message is:
1139
626
 
1140
- * ActiveRecord states are now correctly restored after a rollback for
1141
- models that did not define any transactional callbacks (i.e.
1142
- `after_commit`, `after_rollback` or `after_create`).
627
+ ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
1143
628
 
1144
- Fixes #13744.
629
+ *Rafael Mendonça França*
1145
630
 
1146
- *Godfrey Chan*
631
+ * Fix change detection problem for PostgreSQL bytea type and
632
+ `ArgumentError: string contains null byte` exception with pg-0.18.
1147
633
 
1148
- * Make `touch` fire the `after_commit` and `after_rollback` callbacks.
634
+ Fixes #17680.
1149
635
 
1150
- *Harry Brundage*
636
+ *Lars Kanis*
1151
637
 
1152
- * Enable partial indexes for `sqlite >= 3.8.0`.
638
+ * When a table has a composite primary key, the `primary_key` method for
639
+ SQLite3 and PostgreSQL adapters was only returning the first field of the key.
640
+ Ensures that it will return nil instead, as Active Record doesn't support
641
+ composite primary keys.
1153
642
 
1154
- See http://www.sqlite.org/partialindex.html
643
+ Fixes #18070.
1155
644
 
1156
- *Cody Cutrer*
645
+ *arthurnn*
1157
646
 
1158
- * Don't try to get the subclass if the inheritance column doesn't exist
647
+ * Ensure `first!` and friends work on loaded associations.
1159
648
 
1160
- The `subclass_from_attrs` method is called even if the column specified by
1161
- the `inheritance_column` setting doesn't exist. This prevents setting associations
1162
- via the attributes hash if the association name clashes with the value of the setting,
1163
- typically `:type`. This worked previously in Rails 3.2.
649
+ Fixes #18237.
1164
650
 
1165
- *Ujjwal Thaakar*
651
+ *Sean Griffin*
1166
652
 
1167
- * Enum mappings are now exposed via class methods instead of constants.
653
+ * Dump the default `nil` for PostgreSQL UUID primary key.
1168
654
 
1169
- Example:
655
+ *Ryuta Kamizono*
1170
656
 
1171
- class Conversation < ActiveRecord::Base
1172
- enum status: [ :active, :archived ]
1173
- end
657
+ * Don't raise when writing an attribute with an out-of-range datetime passed
658
+ by the user.
1174
659
 
1175
- Before:
660
+ *Grey Baker*
1176
661
 
1177
- Conversation::STATUS # => { "active" => 0, "archived" => 1 }
662
+ * Fixes bug with 'ActiveRecord::Type::Numeric' that causes negative values to
663
+ be marked as having changed when set to the same negative value.
1178
664
 
1179
- After:
665
+ Fixes #18161.
1180
666
 
1181
- Conversation.statuses # => { "active" => 0, "archived" => 1 }
667
+ *Daniel Fox*
1182
668
 
1183
- *Godfrey Chan*
1184
669
 
1185
- * Set `NameError#name` when STI-class-lookup fails.
670
+ ## Rails 4.2.0 (December 20, 2014) ##
1186
671
 
1187
- *Chulki Lee*
672
+ * Introduce `force: :cascade` option for `create_table`. Using this option
673
+ will recreate tables even if they have dependent objects (like foreign keys).
674
+ `db/schema.rb` now uses `force: :cascade`. This makes it possible to
675
+ reload the schema when foreign keys are in place.
1188
676
 
1189
- * Fix bug in `becomes!` when changing from the base model to a STI sub-class.
677
+ *Matthew Draper*, *Yves Senn*
1190
678
 
1191
- Fixes #13272.
679
+ * `db:schema:load` and `db:structure:load` no longer purge the database
680
+ before loading the schema. This is left for the user to do.
681
+ `db:test:prepare` will still purge the database.
1192
682
 
1193
- *the-web-dev*, *Yves Senn*
683
+ Fixes #17945.
1194
684
 
1195
- * Currently Active Record can be configured via the environment variable
1196
- `DATABASE_URL` or by manually injecting a hash of values which is what Rails does,
1197
- reading in `database.yml` and setting Active Record appropriately. Active Record
1198
- expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot
1199
- rip out this functionality without deprecating. This presents a problem though
1200
- when both config is set, and a `DATABASE_URL` is present. Currently the
1201
- `DATABASE_URL` should "win" and none of the values in `database.yml` are
1202
- used. This is somewhat unexpected, if one were to set values such as
1203
- `pool` in the `production:` group of `database.yml` they are ignored.
685
+ *Yves Senn*
1204
686
 
1205
- There are many ways that Active Record initiates a connection today:
687
+ * Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.
1206
688
 
1207
- - Stand Alone (without rails)
1208
- - `rake db:<tasks>`
1209
- - `ActiveRecord.establish_connection`
689
+ *Ryuta Kamizono*
1210
690
 
1211
- - With Rails
1212
- - `rake db:<tasks>`
1213
- - `rails <server> | <console>`
1214
- - `rails dbconsole`
691
+ * Add `foreign_type` option to `has_one` and `has_many` association macros.
1215
692
 
1216
- Now all of these behave exactly the same way. The best way to do
1217
- this is to put all of this logic in one place so it is guaranteed to be used.
693
+ This option enables to define the column name of associated object's type for polymorphic associations.
1218
694
 
1219
- Here is the matrix of how this behavior works:
695
+ *Ulisses Almeida, Kassio Borges*
1220
696
 
1221
- ```
1222
- No database.yml
1223
- No DATABASE_URL
1224
- => Error
1225
- ```
697
+ * `add_timestamps` and `remove_timestamps` now properly reversible with
698
+ options.
1226
699
 
1227
- ```
1228
- database.yml present
1229
- No DATABASE_URL
1230
- => Use database.yml configuration
1231
- ```
700
+ *Noam Gagliardi-Rabinovich*
1232
701
 
1233
- ```
1234
- No database.yml
1235
- DATABASE_URL present
1236
- => use DATABASE_URL configuration
1237
- ```
702
+ * Bring back `db:test:prepare` to synchronize the test database schema.
1238
703
 
1239
- ```
1240
- database.yml present
1241
- DATABASE_URL present
1242
- => Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url`
1243
- sub key "wins". If other paramaters `adapter` or `database` are specified in YAML,
1244
- they are discarded as the `url` sub key "wins".
1245
- ```
704
+ Manual synchronization using `bin/rake db:test:prepare` is required
705
+ when a migration is rolled-back, edited and reapplied.
1246
706
 
1247
- Current implementation uses `ActiveRecord::Base.configurations` to resolve and merge
1248
- all connection information before returning. This is achieved through a utility
1249
- class: `ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig`.
707
+ `ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
708
+ to synchronize the schema. Plugins can use this task as a hook to
709
+ provide custom behavior after the schema has been loaded.
1250
710
 
1251
- To understand the exact behavior of this class, it is best to review the
1252
- behavior in `activerecord/test/cases/connection_adapters/connection_handler_test.rb`.
711
+ NOTE: `test:prepare` runs before the schema is synchronized.
1253
712
 
1254
- *Richard Schneeman*
713
+ Fixes #17171, #15787.
1255
714
 
1256
- * Make `change_column_null` revertable. Fixes #13576.
715
+ *Yves Senn*
1257
716
 
1258
- *Yves Senn*, *Nishant Modak*, *Prathamesh Sonpatki*
717
+ * Change `reflections` public api to return the keys as String objects.
1259
718
 
1260
- * Don't create/drop the test database if RAILS_ENV is specified explicitly.
719
+ Fixes #16928.
1261
720
 
1262
- Previously, when the environment was development, we would always
1263
- create or drop both the test and development databases.
721
+ *arthurnn*
1264
722
 
1265
- Now, if RAILS_ENV is explicitly defined as development, we don't create
1266
- the test database.
723
+ * Renaming a table in pg also renames the primary key index.
1267
724
 
1268
- *Damien Mathieu*
725
+ Fixes #12856
1269
726
 
1270
- * Initialize version on Migration objects so that it can be used in a migration,
1271
- and it will be included in the announce message.
727
+ *Sean Griffin*
1272
728
 
1273
- *Dylan Thacker-Smith*
729
+ * Make it possible to access fixtures excluded by a `default_scope`.
1274
730
 
1275
- * `change_table` now uses the current adapter's `update_table_definition`
1276
- method to retrieve a specific table definition.
1277
- This ensures that `change_table` and `create_table` will use
1278
- similar objects.
731
+ *Yves Senn*
1279
732
 
1280
- Fixes #13577, #13503.
733
+ * Fix preloading of associations with a scope containing joins along with
734
+ conditions on the joined association.
1281
735
 
1282
- *Nishant Modak*, *Prathamesh Sonpatki*, *Rafael Mendonça França*
736
+ *Siddharth Sharma*
1283
737
 
1284
- * Fixed ActiveRecord::Store nil conversion TypeError when using YAML coder.
1285
- In case the YAML passed as paramter is nil, uses an empty string.
738
+ * Add `Table#name` to match `TableDefinition#name`.
1286
739
 
1287
- Fixes #13570.
740
+ *Cody Cutrer*
1288
741
 
1289
- *Thales Oliveira*
742
+ * Cache `CollectionAssociation#reader` proxies separately before and after
743
+ the owner has been saved so that the proxy is not cached without the
744
+ owner's id.
1290
745
 
1291
- * Deprecate unused `ActiveRecord::Base.symbolized_base_class`
1292
- and `ActiveRecord::Base.symbolized_sti_name` without replacement.
746
+ *Ben Woosley*
1293
747
 
1294
- *Yves Senn*
748
+ * `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
1295
749
 
1296
- * Since the `test_help.rb` file in Railties now automatically maintains
1297
- your test schema, the `rake db:test:*` tasks are deprecated. This
1298
- doesn't stop you manually running other tasks on your test database
1299
- if needed:
750
+ *Franky W.*
1300
751
 
1301
- rake db:schema:load RAILS_ENV=test
752
+ * Fix preloading of associations which unscope a default scope.
1302
753
 
1303
- *Jon Leighton*
754
+ Fixes #11036.
1304
755
 
1305
- * Fix presence validator for association when the associated record responds to `to_a`.
756
+ *Byron Bischoff*
1306
757
 
1307
- *gmarik*
758
+ * Added SchemaDumper support for tables with jsonb columns.
1308
759
 
1309
- * Fixed regression on preload/includes with multiple arguments failing in certain conditions,
1310
- raising a NoMethodError internally by calling `reflect_on_association` for `NilClass:Class`.
760
+ *Ted O'Meara*
1311
761
 
1312
- Fixes #13437.
762
+ * Deprecate `sanitize_sql_hash_for_conditions` without replacement. Using a
763
+ `Relation` for performing queries and updates is the prefered API.
1313
764
 
1314
- *Vipul A M*, *khustochka*
765
+ *Sean Griffin*
1315
766
 
1316
- * Add the ability to nullify the `enum` column.
767
+ * Queries now properly type cast values that are part of a join statement,
768
+ even when using type decorators such as `serialize`.
1317
769
 
1318
- Example:
770
+ *Melanie Gilman & Sean Griffin*
1319
771
 
1320
- class Conversation < ActiveRecord::Base
1321
- enum gender: [:female, :male]
1322
- end
772
+ * MySQL enum type lookups, with values matching another type, no longer result
773
+ in an endless loop.
1323
774
 
1324
- Conversation::GENDER # => { female: 0, male: 1 }
775
+ Fixes #17402.
1325
776
 
1326
- # conversation.update! gender: 0
1327
- conversation.female!
1328
- conversation.female? # => true
1329
- conversation.gender # => "female"
777
+ *Yves Senn*
1330
778
 
1331
- # conversation.update! gender: nil
1332
- conversation.gender = nil
1333
- conversation.gender.nil? # => true
1334
- conversation.gender # => nil
779
+ * Raise `ArgumentError` when the body of a scope is not callable.
1335
780
 
1336
- *Amr Tamimi*
781
+ *Mauro George*
1337
782
 
1338
- * Connection specification now accepts a "url" key. The value of this
1339
- key is expected to contain a database URL. The database URL will be
1340
- expanded into a hash and merged.
783
+ * Use type column first in multi-column indexes created with `add-reference`.
1341
784
 
1342
- *Richard Schneeman*
785
+ *Derek Prior*
1343
786
 
1344
- * An `ArgumentError` is now raised on a call to `Relation#where.not(nil)`.
787
+ * Fix `Relation.rewhere` to work with Range values.
1345
788
 
1346
- Example:
789
+ *Dan Olson*
1347
790
 
1348
- User.where.not(nil)
791
+ * `AR::UnknownAttributeError` now includes the class name of a record.
1349
792
 
1350
- # Before
1351
- # => 'SELECT `users`.* FROM `users` WHERE (NOT (NULL))'
793
+ User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"})
794
+ # => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
1352
795
 
1353
- # After
1354
- # => ArgumentError, 'Invalid argument for .where.not(), got nil.'
796
+ *Yuki Nishijima*
1355
797
 
1356
- *Kuldeep Aggarwal*
798
+ * Fix a regression causing `after_create` callbacks to run before associated
799
+ records are autosaved.
1357
800
 
1358
- * Deprecated use of string argument as a configuration lookup in
1359
- `ActiveRecord::Base.establish_connection`. Instead, a symbol must be given.
801
+ Fixes #17209.
1360
802
 
1361
- *José Valim*
803
+ *Agis Anastasopoulos*
1362
804
 
1363
- * Fixed `update_column`, `update_columns`, and `update_all` to correctly serialize
1364
- values for `array`, `hstore` and `json` column types in PostgreSQL.
805
+ * Honor overridden `rack.test` in Rack environment for the connection
806
+ management middleware.
1365
807
 
1366
- Fixes #12261.
808
+ *Simon Eskildsen*
1367
809
 
1368
- *Tadas Tamosauskas*, *Carlos Antonio da Silva*
810
+ * Add a truncate method to the connection.
1369
811
 
1370
- * Do not consider PostgreSQL array columns as number or text columns.
812
+ *Aaron Patterson*
1371
813
 
1372
- The code uses these checks in several places to know what to do with a
1373
- particular column, for instance AR attribute query methods has a branch
1374
- like this:
814
+ * Don't autosave unchanged has_one through records.
1375
815
 
1376
- if column.number?
1377
- !value.zero?
1378
- end
816
+ *Alan Kennedy*, *Steve Parrington*
1379
817
 
1380
- This should never be true for array columns, since it would be the same
1381
- as running [].zero?, which results in a NoMethodError exception.
818
+ * Do not dump foreign keys for ignored tables.
1382
819
 
1383
- Fixing this by ensuring that array columns in PostgreSQL never return
1384
- true for number?/text? checks.
820
+ *Yves Senn*
1385
821
 
1386
- *Carlos Antonio da Silva*
822
+ * PostgreSQL adapter correctly dumps foreign keys targeting tables
823
+ outside the schema search path.
1387
824
 
1388
- * When connecting to a non-existant database, the error:
1389
- `ActiveRecord::NoDatabaseError` will now be raised. When being used with Rails
1390
- the error message will include information on how to create a database:
1391
- `rake db:create`. Supported adapters: postgresql, mysql, mysql2, sqlite3
825
+ Fixes #16907.
1392
826
 
1393
- *Richard Schneeman*
827
+ *Matthew Draper*, *Yves Senn*
1394
828
 
1395
- * Do not raise `'cannot touch on a new record object'` exception on destroying
1396
- already destroyed `belongs_to` association with `touch: true` option.
829
+ * When a thread is killed, rollback the active transaction, instead of
830
+ committing it during the stack unwind. Previously, we could commit half-
831
+ completed work. This fix only works for Ruby 2.0+; on 1.9, we can't
832
+ distinguish a thread kill from an ordinary non-local (block) return, so must
833
+ default to committing.
1397
834
 
1398
- Fixes #13445.
835
+ *Chris Hanks*
1399
836
 
1400
- Example:
837
+ * A `NullRelation` should represent nothing. This fixes a bug where
838
+ `Comment.where(post_id: Post.none)` returned a non-empty result.
1401
839
 
1402
- # Given Comment has belongs_to :post, touch: true
1403
- comment.post.destroy
1404
- comment.destroy # no longer raises an error
840
+ Fixes #15176.
1405
841
 
1406
- *Paul Nikitochkin*
842
+ *Matthew Draper*, *Yves Senn*
1407
843
 
1408
- * Fix a bug when assigning an array containing string numbers to a
1409
- PostgreSQL integer array column.
844
+ * Include default column limits in schema.rb. Allows defaults to be changed
845
+ in the future without affecting old migrations that assumed old defaults.
1410
846
 
1411
- Fixes #13444.
847
+ *Jeremy Kemper*
1412
848
 
1413
- Example:
849
+ * MySQL: schema.rb now includes TEXT and BLOB column limits.
1414
850
 
1415
- # Given Book#ratings is of type :integer, array: true
1416
- Book.new(ratings: [1, 2]) # worked before
1417
- Book.new(ratings: ['1', '2']) # now works as well
851
+ *Jeremy Kemper*
1418
852
 
1419
- *Damien Mathieu*
853
+ * MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB.
1420
854
 
1421
- * Fix `PostgreSQL` insert to properly extract table name from multiline string SQL.
855
+ *Jeremy Kemper*
1422
856
 
1423
- Previously, executing an insert SQL in `PostgreSQL` with a command like this:
857
+ * SQLite3Adapter now checks for views in `table_exists?`. Fixes #14041.
1424
858
 
1425
- insert into articles(
1426
- number)
1427
- values(
1428
- 5152
1429
- )
859
+ *Girish Sonawane*
1430
860
 
1431
- would not work because the adapter was unable to extract the correct `articles`
1432
- table name.
861
+ * Introduce `connection.supports_views?` to check whether the current adapter
862
+ has support for SQL views. Connection adapters should define this method.
1433
863
 
1434
- *Kuldeep Aggarwal*
864
+ *Yves Senn*
1435
865
 
1436
- * Correctly escape PostgreSQL arrays.
866
+ * Allow included modules to override association methods.
1437
867
 
1438
- Fixes: CVE-2014-0080
868
+ Fixes #16684.
1439
869
 
1440
- * `Relation` no longer has mutator methods like `#map!` and `#delete_if`. Convert
1441
- to an `Array` by calling `#to_a` before using these methods.
870
+ *Yves Senn*
1442
871
 
1443
- It intends to prevent odd bugs and confusion in code that call mutator
1444
- methods directly on the `Relation`.
872
+ * Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
873
+ the database connection to the current environment.
1445
874
 
1446
- Example:
875
+ Fixes #16757.
1447
876
 
1448
- # Instead of this
1449
- Author.where(name: 'Hank Moody').compact!
877
+ *Joshua Cody*, *Yves Senn*
1450
878
 
1451
- # Now you have to do this
1452
- authors = Author.where(name: 'Hank Moody').to_a
1453
- authors.compact!
879
+ * MySQL: set the connection collation along with the charset.
1454
880
 
1455
- *Lauro Caetano*
881
+ Sets the connection collation to the database collation configured in
882
+ database.yml. Otherwise, `SET NAMES utf8mb4` will use the default
883
+ collation for that charset (utf8mb4_general_ci) when you may have chosen
884
+ a different collation, like utf8mb4_unicode_ci.
1456
885
 
1457
- * Better support for `where()` conditions that use a `belongs_to`
1458
- association name.
886
+ This only applies to literal string comparisons, not column values, so it
887
+ is unlikely to affect you.
1459
888
 
1460
- Using the name of an association in `where` previously worked only
1461
- if the value was a single `ActiveRecord::Base` object. e.g.
889
+ *Jeremy Kemper*
1462
890
 
1463
- Post.where(author: Author.first)
891
+ * `default_sequence_name` from the PostgreSQL adapter returns a `String`.
1464
892
 
1465
- Any other values, including `nil`, would cause invalid SQL to be
1466
- generated. This change supports arguments in the `where` query
1467
- conditions where the key is a `belongs_to` association name and the
1468
- value is `nil`, an `Array` of `ActiveRecord::Base` objects, or an
1469
- `ActiveRecord::Relation` object.
893
+ *Yves Senn*
1470
894
 
1471
- class Post < ActiveRecord::Base
1472
- belongs_to :author
1473
- end
895
+ * Fix a regression where whitespaces were stripped from DISTINCT queries in
896
+ PostgreSQL.
1474
897
 
1475
- `nil` value finds records where the association is not set:
898
+ *Agis Anastasopoulos*
1476
899
 
1477
- Post.where(author: nil)
1478
- # SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IS NULL
900
+ Fixes #16623.
1479
901
 
1480
- `Array` values find records where the association foreign key
1481
- matches the ids of the passed ActiveRecord models, resulting
1482
- in the same query as `Post.where(author_id: [1,2])`:
902
+ * Fix has_many :through relation merging failing when dynamic conditions are
903
+ passed as a lambda with an arity of one.
1483
904
 
1484
- authors_array = [Author.find(1), Author.find(2)]
1485
- Post.where(author: authors_array)
1486
- # SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IN (1, 2)
905
+ Fixes #16128.
1487
906
 
1488
- `ActiveRecord::Relation` values find records using the same
1489
- query as `Post.where(author_id: Author.where(last_name: "Emde"))`
907
+ *Agis Anastasopoulos*
1490
908
 
1491
- Post.where(author: Author.where(last_name: "Emde"))
1492
- # SELECT "posts".* FROM "posts"
1493
- # WHERE "posts"."author_id" IN (
1494
- # SELECT "authors"."id" FROM "authors"
1495
- # WHERE "authors"."last_name" = 'Emde')
909
+ * Fix `Relation#exists?` to work with polymorphic associations.
1496
910
 
1497
- Polymorphic `belongs_to` associations will continue to be handled
1498
- appropriately, with the polymorphic `association_type` field added
1499
- to the query to match the base class of the value. This feature
1500
- previously only worked when the value was a single `ActveRecord::Base`.
911
+ Fixes #15821.
1501
912
 
1502
- class Post < ActiveRecord::Base
1503
- belongs_to :author, polymorphic: true
1504
- end
913
+ *Kassio Borges*
1505
914
 
1506
- Post.where(author: Author.where(last_name: "Emde"))
1507
- # Generates a query similar to:
1508
- Post.where(author_id: Author.where(last_name: "Emde"), author_type: "Author")
915
+ * Currently, Active Record rescues any errors raised within
916
+ `after_rollback`/`after_create` callbacks and prints them to the logs.
917
+ Future versions of Rails will not rescue these errors anymore and
918
+ just bubble them up like the other callbacks.
1509
919
 
1510
- *Martin Emde*
920
+ This commit adds an opt-in flag to enable not rescuing the errors.
1511
921
 
1512
- * Respect temporary option when dropping tables with MySQL.
922
+ Example:
1513
923
 
1514
- Normal DROP TABLE also works, but commits the transaction.
924
+ # Do not swallow errors in after_commit/after_rollback callbacks.
925
+ config.active_record.raise_in_transactional_callbacks = true
1515
926
 
1516
- drop_table :temporary_table, temporary: true
927
+ Fixes #13460.
1517
928
 
1518
- *Cody Cutrer*
929
+ *arthurnn*
1519
930
 
1520
- * Add option to create tables from a query.
931
+ * Fix an issue where custom accessor methods (such as those generated by
932
+ `enum`) with the same name as a global method are incorrectly overridden
933
+ when subclassing.
1521
934
 
1522
- create_table(:long_query, temporary: true,
1523
- as: "SELECT * FROM orders INNER JOIN line_items ON order_id=orders.id")
935
+ Fixes #16288.
1524
936
 
1525
- Generates:
937
+ *Godfrey Chan*
1526
938
 
1527
- CREATE TEMPORARY TABLE long_query AS
1528
- SELECT * FROM orders INNER JOIN line_items ON order_id=orders.id
939
+ * `*_was` and `changes` now work correctly for in-place attribute changes as
940
+ well.
1529
941
 
1530
- *Cody Cutrer*
942
+ *Sean Griffin*
1531
943
 
1532
- * `db:test:clone` and `db:test:prepare` must load Rails environment.
944
+ * Fix regression on `after_commit` that did not fire with nested transactions.
1533
945
 
1534
- `db:test:clone` and `db:test:prepare` use `ActiveRecord::Base`. configurations,
1535
- so we need to load the Rails environment, otherwise the config wont be in place.
946
+ Fixes #16425.
1536
947
 
1537
948
  *arthurnn*
1538
949
 
1539
- * Use the right column to type cast grouped calculations with custom expressions.
950
+ * Do not try to write timestamps when a table has no timestamps columns.
1540
951
 
1541
- Fixes #13230.
952
+ Fixes #8813.
1542
953
 
1543
- Example:
954
+ *Sergey Potapov*
1544
955
 
1545
- # Before
1546
- Account.group(:firm_name).sum('0.01 * credit_limit')
1547
- # => { '37signals' => '0.5' }
956
+ * `index_exists?` with `:name` option does verify specified columns.
1548
957
 
1549
- # After
1550
- Account.group(:firm_name).sum('0.01 * credit_limit')
1551
- # => { '37signals' => 0.5 }
958
+ Example:
1552
959
 
1553
- *Paul Nikitochkin*
960
+ add_index :articles, :title, name: "idx_title"
1554
961
 
1555
- * Polymorphic `belongs_to` associations with the `touch: true` option set update the timestamps of
1556
- the old and new owner correctly when moved between owners of different types.
962
+ # Before:
963
+ index_exists? :articles, :title, name: "idx_title" # => `true`
964
+ index_exists? :articles, :body, name: "idx_title" # => `true`
1557
965
 
1558
- Example:
966
+ # After:
967
+ index_exists? :articles, :title, name: "idx_title" # => `true`
968
+ index_exists? :articles, :body, name: "idx_title" # => `false`
1559
969
 
1560
- class Rating < ActiveRecord::Base
1561
- belongs_to :rateable, polymorphic: true, touch: true
1562
- end
970
+ *Yves Senn*, *Matthew Draper*
1563
971
 
1564
- rating = Rating.create rateable: Song.find(1)
1565
- rating.update_attributes rateable: Book.find(2) # => timestamps of Song(1) and Book(2) are updated
972
+ * `add_timestamps` and `t.timestamps` now require you to pass the `:null` option.
973
+ Not passing the option is deprecated but the default is still `null: true`.
974
+ With Rails 5 this will change to `null: false`.
1566
975
 
1567
- *Severin Schoepke*
976
+ *Sean Griffin*
1568
977
 
1569
- * Improve formatting of migration exception messages: make them easier to read
1570
- with line breaks before/after, and improve the error for pending migrations.
978
+ * When calling `update_columns` on a record that is not persisted, the error
979
+ message now reflects whether that object is a new record or has been
980
+ destroyed.
1571
981
 
1572
- *John Bachir*
982
+ *Lachlan Sylvester*
1573
983
 
1574
- * Fix `last` with `offset` to return the proper record instead of always the last one.
984
+ * Define `id_was` to get the previous value of the primary key.
1575
985
 
1576
- Example:
986
+ Currently when we call `id_was` and we have a custom primary key name,
987
+ Active Record will return the current value of the primary key. This
988
+ makes it impossible to correctly do an update operation if you change the
989
+ id.
1577
990
 
1578
- Model.offset(4).last
1579
- # => returns the 4th record from the end.
991
+ Fixes #16413.
1580
992
 
1581
- Fixes #7441.
993
+ *Rafael Mendonça França*
1582
994
 
1583
- *kostya*, *Lauro Caetano*
995
+ * Deprecate `DatabaseTasks.load_schema` to act on the current connection.
996
+ Use `.load_schema_current` instead. In the future `load_schema` will
997
+ require the `configuration` to act on as an argument.
1584
998
 
1585
- * `type_to_sql` returns a `String` for unmapped columns. This fixes an error
1586
- when using unmapped PostgreSQL array types.
999
+ *Yves Senn*
1587
1000
 
1588
- Example:
1001
+ * Fix automatic maintaining test schema to properly handle sql structure
1002
+ schema format.
1589
1003
 
1590
- change_colum :table, :column, :bigint, array: true
1004
+ Fixes #15394.
1591
1005
 
1592
- Fixes #13146.
1006
+ *Wojciech Wnętrzak*
1593
1007
 
1594
- *Jens Fahnenbruck*, *Yves Senn*
1008
+ * Fix type casting to Decimal from Float with large precision.
1595
1009
 
1596
- * Fix `QueryCache` to work with nested blocks, so that it will only clear the existing cache
1597
- after leaving the outer block instead of clearing it right after the inner block is finished.
1010
+ *Tomohiro Hashidate*
1598
1011
 
1599
- *Vipul A M*
1012
+ * Deprecate `Reflection#source_macro`
1600
1013
 
1601
- * The ERB in fixture files is no longer evaluated in the context of the main
1602
- object. Helper methods used by multiple fixtures should be defined on the
1603
- class object returned by `ActiveRecord::FixtureSet.context_class`.
1014
+ `Reflection#source_macro` is no longer needed in Active Record
1015
+ source so it has been deprecated. Code that used `source_macro`
1016
+ was removed in #16353.
1604
1017
 
1605
- *Victor Costan*
1018
+ *Eileen M. Uchtitelle*, *Aaron Patterson*
1606
1019
 
1607
- * Previously, the `has_one` macro incorrectly accepted the `counter_cache`
1608
- option, but never actually supported it. Now it will raise an `ArgumentError`
1609
- when using `has_one` with `counter_cache`.
1020
+ * No verbose backtrace by `db:drop` when database does not exist.
1610
1021
 
1611
- *Godfrey Chan*
1022
+ Fixes #16295.
1612
1023
 
1613
- * Implement `rename_index` natively for MySQL >= 5.7.
1024
+ *Kenn Ejima*
1614
1025
 
1615
- *Cody Cutrer*
1026
+ * Add support for PostgreSQL JSONB.
1616
1027
 
1617
- * Fix bug when validating the uniqueness of an aliased attribute.
1028
+ Example:
1618
1029
 
1619
- Fixes #12402.
1030
+ create_table :posts do |t|
1031
+ t.jsonb :meta_data
1032
+ end
1620
1033
 
1621
- *Lauro Caetano*
1034
+ *Philippe Creux*, *Chris Teague*
1622
1035
 
1623
- * Update counter cache on a `has_many` relationship regardless of default scope.
1036
+ * `db:purge` with MySQL respects `Rails.env`.
1624
1037
 
1625
- Fixes #12952.
1038
+ *Yves Senn*
1626
1039
 
1627
- *Uku Taht*
1040
+ * `change_column_default :table, :column, nil` with PostgreSQL will issue a
1041
+ `DROP DEFAULT` instead of a `DEFAULT NULL` query.
1628
1042
 
1629
- * `rename_index` adds the new index before removing the old one. This allows to
1630
- rename indexes on columns with a foreign key and prevents the following error:
1043
+ Fixes #16261.
1631
1044
 
1632
- Cannot drop index 'index_engines_on_car_id': needed in a foreign key constraint
1045
+ *Matthew Draper*, *Yves Senn*
1633
1046
 
1634
- *Cody Cutrer*, *Yves Senn*
1047
+ * Allow to specify a type for the foreign key column in `references`
1048
+ and `add_reference`.
1635
1049
 
1636
- * Raise `ActiveRecord::RecordNotDestroyed` when a replaced child
1637
- marked with `dependent: destroy` fails to be destroyed.
1050
+ Example:
1638
1051
 
1639
- Fixes #12812.
1052
+ change_table :vehicle do |t|
1053
+ t.references :station, type: :uuid
1054
+ end
1640
1055
 
1641
- *Brian Thomas Storti*
1056
+ *Andrey Novikov*, *Łukasz Sarnacki*
1642
1057
 
1643
- * Fix validation on uniqueness of empty association.
1058
+ * `create_join_table` removes a common prefix when generating the join table.
1059
+ This matches the existing behavior of HABTM associations.
1644
1060
 
1645
- *Evgeny Li*
1061
+ Fixes #13683.
1646
1062
 
1647
- * Make `ActiveRecord::Relation#unscope` affect relations it is merged in to.
1063
+ *Stefan Kanev*
1648
1064
 
1649
- *Jon Leighton*
1065
+ * Do not swallow errors on `compute_type` when having a bad `alias_method` on
1066
+ a class.
1650
1067
 
1651
- * Use strings to represent non-string `order_values`.
1068
+ *arthurnn*
1652
1069
 
1653
- *Yves Senn*
1070
+ * PostgreSQL invalid `uuid` are convert to nil.
1654
1071
 
1655
- * Checks to see if the record contains the foreign key to set the inverse automatically.
1072
+ *Abdelkader Boudih*
1656
1073
 
1657
- *Edo Balvers*
1074
+ * Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
1658
1075
 
1659
- * Added `ActiveRecord::Base.to_param` for convenient "pretty" URLs derived from a model's attribute or method.
1076
+ With 4.1.x, `serialize` started returning a string when `JSON` was passed as
1077
+ the second attribute. It will now return a hash as per previous versions.
1660
1078
 
1661
1079
  Example:
1662
1080
 
1663
- class User < ActiveRecord::Base
1664
- to_param :name
1081
+ class Post < ActiveRecord::Base
1082
+ serialize :comment, JSON
1665
1083
  end
1666
1084
 
1667
- user = User.find_by(name: 'Fancy Pants')
1668
- user.id # => 123
1669
- user.to_param # => "123-fancy-pants"
1670
-
1671
- *Javan Makhmali*
1672
-
1673
- * Added `ActiveRecord::Base.no_touching`, which allows ignoring touch on models.
1674
-
1675
- Example:
1676
-
1677
- Post.no_touching do
1678
- Post.first.touch
1085
+ class Comment
1086
+ include ActiveModel::Model
1087
+ attr_accessor :category, :text
1679
1088
  end
1680
1089
 
1681
- *Sam Stephenson*, *Damien Mathieu*
1090
+ post = Post.create!
1091
+ post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
1092
+ post.save!
1682
1093
 
1683
- * Prevent the counter cache from being decremented twice when destroying
1684
- a record on a `has_many :through` association.
1094
+ # 4.0
1095
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
1685
1096
 
1686
- Fixes #11079.
1097
+ # 4.1 before
1098
+ post.comment # => "#<Comment:0x007f80ab48ff98>"
1687
1099
 
1688
- *Dmitry Dedov*
1100
+ # 4.1 after
1101
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
1689
1102
 
1690
- * Unify boolean type casting for `MysqlAdapter` and `Mysql2Adapter`.
1691
- `type_cast` will return `1` for `true` and `0` for `false`.
1103
+ When using `JSON` as the coder in `serialize`, Active Record will use the
1104
+ new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
1105
+ `ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
1106
+ correctly using the `#as_json` hook.
1692
1107
 
1693
- Fixes #11119.
1108
+ To keep the previous behaviour, supply a custom coder instead
1109
+ ([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
1694
1110
 
1695
- *Adam Williams*, *Yves Senn*
1111
+ Fixes #15594.
1696
1112
 
1697
- * Fix bug where `has_one` association record update result in crash, when replaced with itself.
1113
+ *Jenn Cooper*
1698
1114
 
1699
- Fixes #12834.
1115
+ * Do not use `RENAME INDEX` syntax for MariaDB 10.0.
1700
1116
 
1701
- *Denis Redozubov*, *Sergio Cambra*
1117
+ Fixes #15931.
1702
1118
 
1703
- * Log bind variables after they are type casted. This makes it more
1704
- transparent what values are actually sent to the database.
1119
+ *Jeff Browning*
1705
1120
 
1706
- irb(main):002:0> Event.find("im-no-integer")
1707
- # Before: ... WHERE "events"."id" = $1 LIMIT 1 [["id", "im-no-integer"]]
1708
- # After: ... WHERE "events"."id" = $1 LIMIT 1 [["id", 0]]
1121
+ * Calling `#empty?` on a `has_many` association would use the value from the
1122
+ counter cache if one exists.
1709
1123
 
1710
- *Yves Senn*
1124
+ *David Verhasselt*
1711
1125
 
1712
- * Fix uninitialized constant `TransactionState` error when `Marshall.load` is used on an Active Record result.
1126
+ * Fix the schema dump generated for tables without constraints and with
1127
+ primary key with default value of custom PostgreSQL function result.
1713
1128
 
1714
- Fixes #12790.
1129
+ Fixes #16111.
1715
1130
 
1716
- *Jason Ayre*
1131
+ *Andrey Novikov*
1717
1132
 
1718
- * `.unscope` now removes conditions specified in `default_scope`.
1133
+ * Fix the SQL generated when a `delete_all` is run on an association to not
1134
+ produce an `IN` statements.
1719
1135
 
1720
- *Jon Leighton*
1136
+ Before:
1721
1137
 
1722
- * Added `ActiveRecord::QueryMethods#rewhere` which will overwrite an existing, named where condition.
1138
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
1139
+ "categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
1723
1140
 
1724
- Examples:
1141
+ After:
1725
1142
 
1726
- Post.where(trashed: true).where(trashed: false) #=> WHERE `trashed` = 1 AND `trashed` = 0
1727
- Post.where(trashed: true).rewhere(trashed: false) #=> WHERE `trashed` = 0
1728
- Post.where(active: true).where(trashed: true).rewhere(trashed: false) #=> WHERE `active` = 1 AND `trashed` = 0
1143
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
1144
+ "categorizations"."category_id" = 1
1729
1145
 
1730
- *DHH*
1146
+ *Eileen M. Uchitelle, Aaron Patterson*
1731
1147
 
1732
- * Extend `ActiveRecord::Base#cache_key` to take an optional list of timestamp attributes of which the highest will be used.
1148
+ * Avoid type casting boolean and `ActiveSupport::Duration` values to numeric
1149
+ values for string columns. Otherwise, in some database, the string column
1150
+ values will be coerced to a numeric allowing false or 0.seconds match any
1151
+ string starting with a non-digit.
1733
1152
 
1734
1153
  Example:
1735
1154
 
1736
- # last_reviewed_at will be used, if that's more recent than updated_at, or vice versa
1737
- Person.find(5).cache_key(:updated_at, :last_reviewed_at)
1155
+ App.where(apikey: false) # => SELECT * FROM users WHERE apikey = '0'
1738
1156
 
1739
- *DHH*
1157
+ *Dylan Thacker-Smith*
1740
1158
 
1741
- * Added `ActiveRecord::Base#enum` for declaring enum attributes where the values map to integers in the database, but can be queried by name.
1159
+ * Add a `:required` option to singular associations, providing a nicer
1160
+ API for presence validations on associations.
1742
1161
 
1743
- Example:
1162
+ *Sean Griffin*
1744
1163
 
1745
- class Conversation < ActiveRecord::Base
1746
- enum status: [:active, :archived]
1747
- end
1164
+ * Fix an error in `reset_counters` when associations have `select` scope.
1165
+ (Call to `count` generated invalid SQL.)
1748
1166
 
1749
- Conversation::STATUS # => { active: 0, archived: 1 }
1167
+ *Cade Truitt*
1750
1168
 
1751
- # conversation.update! status: 0
1752
- conversation.active!
1753
- conversation.active? # => true
1754
- conversation.status # => "active"
1169
+ * After a successful `reload`, `new_record?` is always false.
1755
1170
 
1756
- # conversation.update! status: 1
1757
- conversation.archived!
1758
- conversation.archived? # => true
1759
- conversation.status # => "archived"
1171
+ Fixes #12101.
1760
1172
 
1761
- # conversation.update! status: 1
1762
- conversation.status = :archived
1173
+ *Matthew Draper*
1763
1174
 
1764
- *DHH*
1175
+ * PostgreSQL renaming table doesn't attempt to rename non existent sequences.
1765
1176
 
1766
- * `ActiveRecord::Base#attribute_for_inspect` now truncates long arrays (more than 10 elements).
1177
+ *Abdelkader Boudih*
1767
1178
 
1768
- *Jan Bernacki*
1179
+ * Move 'dependent: :destroy' handling for `belongs_to`
1180
+ from `before_destroy` to `after_destroy` callback chain
1769
1181
 
1770
- * Allow for the name of the `schema_migrations` table to be configured.
1182
+ Fixes #12380.
1771
1183
 
1772
- *Jerad Phelps*
1184
+ *Ivan Antropov*
1773
1185
 
1774
- * Do not add to scope includes values from through associations.
1775
- Fixed bug when providing `includes` in through association scope, and fetching targets.
1186
+ * Detect in-place modifications on String attributes.
1776
1187
 
1777
- Example:
1188
+ Before this change, an attribute modified in-place had to be marked as
1189
+ changed in order for it to be persisted in the database. Now it is no longer
1190
+ required.
1778
1191
 
1779
- class Vendor < ActiveRecord::Base
1780
- has_many :relationships, -> { includes(:user) }
1781
- has_many :users, through: :relationships
1782
- end
1192
+ Before:
1783
1193
 
1784
- vendor = Vendor.first
1194
+ user = User.first
1195
+ user.name << ' Griffin'
1196
+ user.name_will_change!
1197
+ user.save
1198
+ user.reload.name # => "Sean Griffin"
1785
1199
 
1786
- # Before
1200
+ After:
1787
1201
 
1788
- vendor.users.to_a # => Raises exception: not found `:user` for `User`
1202
+ user = User.first
1203
+ user.name << ' Griffin'
1204
+ user.save
1205
+ user.reload.name # => "Sean Griffin"
1789
1206
 
1790
- # After
1207
+ *Sean Griffin*
1791
1208
 
1792
- vendor.users.to_a # => No exception is raised
1209
+ * Add `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the record
1210
+ is invalid.
1793
1211
 
1794
- Fixes #12242, #9517, #10240.
1212
+ *Bogdan Gusiev*, *Marc Schütz*
1795
1213
 
1796
- *Paul Nikitochkin*
1214
+ * Support for adding and removing foreign keys. Foreign keys are now
1215
+ a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter
1216
+ and PostgreSQLAdapter.
1797
1217
 
1798
- * Type cast json values on write, so that the value is consistent
1799
- with reading from the database.
1218
+ Many thanks to *Matthew Higgins* for laying the foundation with his work on
1219
+ [foreigner](https://github.com/matthuhiggins/foreigner).
1800
1220
 
1801
1221
  Example:
1802
1222
 
1803
- x = JsonDataType.new tags: {"string" => "foo", :symbol => :bar}
1223
+ # within your migrations:
1224
+ add_foreign_key :articles, :authors
1225
+ remove_foreign_key :articles, :authors
1804
1226
 
1805
- # Before:
1806
- x.tags # => {"string" => "foo", :symbol => :bar}
1227
+ *Yves Senn*
1807
1228
 
1808
- # After:
1809
- x.tags # => {"string" => "foo", "symbol" => "bar"}
1229
+ * Fix subtle bugs regarding attribute assignment on models with no primary
1230
+ key. `'id'` will no longer be part of the attributes hash.
1810
1231
 
1811
- *Severin Schoepke*
1232
+ *Sean Griffin*
1812
1233
 
1813
- * `ActiveRecord::Store` works together with PostgreSQL `hstore` columns.
1234
+ * Deprecate automatic counter caches on `has_many :through`. The behavior was
1235
+ broken and inconsistent.
1814
1236
 
1815
- Fixes #12452.
1237
+ *Sean Griffin*
1816
1238
 
1817
- *Yves Senn*
1239
+ * `preload` preserves readonly flag for associations.
1818
1240
 
1819
- * Fix bug where `ActiveRecord::Store` used a global `Hash` to keep track of
1820
- all registered `stored_attributes`. Now every subclass of
1821
- `ActiveRecord::Base` has it's own `Hash`.
1241
+ See #15853.
1822
1242
 
1823
1243
  *Yves Senn*
1824
1244
 
1825
- * Save `has_one` association when primary key is manually set.
1245
+ * Assume numeric types have changed if they were assigned to a value that
1246
+ would fail numericality validation, regardless of the old value. Previously
1247
+ this would only occur if the old value was 0.
1826
1248
 
1827
- Fixes #12302.
1249
+ Example:
1828
1250
 
1829
- *Lauro Caetano*
1251
+ model = Model.create!(number: 5)
1252
+ model.number = '5wibble'
1253
+ model.number_changed? # => true
1830
1254
 
1831
- * Allow any version of BCrypt when using `has_secure_password`.
1255
+ Fixes #14731.
1832
1256
 
1833
- *Mike Perham*
1257
+ *Sean Griffin*
1834
1258
 
1835
- * Sub-query generated for `Relation` passed as array condition did not take in account
1836
- bind values and have invalid syntax.
1259
+ * `reload` no longer merges with the existing attributes.
1260
+ The attribute hash is fully replaced. The record is put into the same state
1261
+ as it would be with `Model.find(model.id)`.
1837
1262
 
1838
- Generate sub-query with inline bind values.
1263
+ *Sean Griffin*
1839
1264
 
1840
- Fixes #12586.
1265
+ * The object returned from `select_all` must respond to `column_types`.
1266
+ If this is not the case a `NoMethodError` is raised.
1841
1267
 
1842
- *Paul Nikitochkin*
1268
+ *Sean Griffin*
1843
1269
 
1844
- * Fix a bug where rake db:structure:load crashed when the path contained
1845
- spaces.
1270
+ * Detect in-place modifications of PG array types
1846
1271
 
1847
- *Kevin Mook*
1272
+ *Sean Griffin*
1848
1273
 
1849
- * `ActiveRecord::QueryMethods#unscope` unscopes negative equality
1274
+ * Add `bin/rake db:purge` task to empty the current database.
1850
1275
 
1851
- Allows you to call `#unscope` on a relation with negative equality
1852
- operators, i.e. `Arel::Nodes::NotIn` and `Arel::Nodes::NotEqual` that have
1853
- been generated through the use of `where.not`.
1276
+ *Yves Senn*
1854
1277
 
1855
- *Eric Hankins*
1278
+ * Deprecate `serialized_attributes` without replacement.
1856
1279
 
1857
- * Raise an exception when model without primary key calls `.find_with_ids`.
1280
+ *Sean Griffin*
1858
1281
 
1859
- *Shimpei Makimoto*
1282
+ * Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
1283
+ are part of the URI structure, not the actual host.
1860
1284
 
1861
- * Make `Relation#empty?` use `exists?` instead of `count`.
1285
+ Fixes #15705.
1862
1286
 
1863
- *Szymon Nowak*
1287
+ *Andy Bakun*, *Aaron Stone*
1864
1288
 
1865
- * `rake db:structure:dump` no longer crashes when the port was specified as `Fixnum`.
1289
+ * Ensure both parent IDs are set on join records when both sides of a
1290
+ through association are new.
1866
1291
 
1867
- *Kenta Okamoto*
1292
+ *Sean Griffin*
1868
1293
 
1869
- * `NullRelation#pluck` takes a list of columns
1294
+ * `ActiveRecord::Dirty` now detects in-place changes to mutable values.
1295
+ Serialized attributes on ActiveRecord models will no longer save when
1296
+ unchanged.
1870
1297
 
1871
- The method signature in `NullRelation` was updated to mimic that in
1872
- `Calculations`.
1298
+ Fixes #8328.
1873
1299
 
1874
- *Derek Prior*
1300
+ *Sean Griffin*
1875
1301
 
1876
- * `scope_chain` should not be mutated for other reflections.
1302
+ * `Pluck` now works when selecting columns from different tables with the same
1303
+ name.
1877
1304
 
1878
- Currently `scope_chain` uses same array for building different
1879
- `scope_chain` for different associations. During processing
1880
- these arrays are sometimes mutated and because of in-place
1881
- mutation the changed `scope_chain` impacts other reflections.
1305
+ Fixes #15649.
1882
1306
 
1883
- Fix is to dup the value before adding to the `scope_chain`.
1307
+ *Sean Griffin*
1884
1308
 
1885
- Fixes #3882.
1309
+ * Remove `cache_attributes` and friends. All attributes are cached.
1886
1310
 
1887
- *Neeraj Singh*
1311
+ *Sean Griffin*
1888
1312
 
1889
- * Prevent the inversed association from being reloaded on save.
1313
+ * Remove deprecated method `ActiveRecord::Base.quoted_locking_column`.
1890
1314
 
1891
- Fixes #9499.
1315
+ *Akshay Vishnoi*
1892
1316
 
1893
- *Dmitry Polushkin*
1317
+ * `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
1318
+ `Enumerable#find` does.
1894
1319
 
1895
- * Generate subquery for `Relation` if it passed as array condition for `where`
1896
- method.
1320
+ Fixes #15382.
1897
1321
 
1898
- Example:
1322
+ *James Yang*
1899
1323
 
1900
- # Before
1901
- Blog.where('id in (?)', Blog.where(id: 1))
1902
- # => SELECT "blogs".* FROM "blogs" WHERE "blogs"."id" = 1
1903
- # => SELECT "blogs".* FROM "blogs" WHERE (id IN (1))
1324
+ * Make timezone aware attributes work with PostgreSQL array columns.
1904
1325
 
1905
- # After
1906
- Blog.where('id in (?)', Blog.where(id: 1).select(:id))
1907
- # => SELECT "blogs".* FROM "blogs"
1908
- # WHERE "blogs"."id" IN (SELECT "blogs"."id" FROM "blogs" WHERE "blogs"."id" = 1)
1326
+ Fixes #13402.
1909
1327
 
1910
- Fixes #12415.
1328
+ *Kuldeep Aggarwal*, *Sean Griffin*
1911
1329
 
1912
- *Paul Nikitochkin*
1330
+ * `ActiveRecord::SchemaMigration` has no primary key regardless of the
1331
+ `primary_key_prefix_type` configuration.
1913
1332
 
1914
- * For missed association exception message
1915
- which is raised in `ActiveRecord::Associations::Preloader` class
1916
- added owner record class name in order to simplify to find problem code.
1333
+ Fixes #15051.
1917
1334
 
1918
- *Paul Nikitochkin*
1335
+ *JoseLuis Torres*, *Yves Senn*
1919
1336
 
1920
- * `has_and_belongs_to_many` is now transparently implemented in terms of
1921
- `has_many :through`. Behavior should remain the same, if not, it is a bug.
1337
+ * `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
1922
1338
 
1923
- * `create_savepoint`, `rollback_to_savepoint` and `release_savepoint` accept
1924
- a savepoint name.
1339
+ Fixes #15538.
1925
1340
 
1926
1341
  *Yves Senn*
1927
1342
 
1928
- * Make `next_migration_number` accessible for third party generators.
1343
+ * Baseclass becomes! subclass.
1929
1344
 
1930
- *Yves Senn*
1345
+ Before this change, a record which changed its STI type, could not be
1346
+ updated.
1931
1347
 
1932
- * Objects instantiated using a null relationship will now retain the
1933
- attributes of the where clause.
1348
+ Fixes #14785.
1934
1349
 
1935
- Fixes #11676, #11675, #11376.
1350
+ *Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
1936
1351
 
1937
- *Paul Nikitochkin*, *Peter Brown*, *Nthalk*
1352
+ * Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
1353
+ `proper_table_name` instance method on `ActiveRecord::Migration` instead.
1938
1354
 
1939
- * Fixed `ActiveRecord::Associations::CollectionAssociation#find`
1940
- when using `has_many` association with `:inverse_of` and finding an array of one element,
1941
- it should return an array of one element too.
1355
+ *Akshay Vishnoi*
1942
1356
 
1943
- *arthurnn*
1357
+ * Fix regression on eager loading association based on SQL query rather than
1358
+ existing column.
1944
1359
 
1945
- * Callbacks on has_many should access the in memory parent if a inverse_of is set.
1360
+ Fixes #15480.
1946
1361
 
1947
- *arthurnn*
1362
+ *Lauro Caetano*, *Carlos Antonio da Silva*
1948
1363
 
1949
- * `ActiveRecord::ConnectionAdapters.string_to_time` respects
1950
- string with timezone (e.g. Wed, 04 Sep 2013 20:30:00 JST).
1364
+ * Deprecate returning `nil` from `column_for_attribute` when no column exists.
1365
+ It will return a null object in Rails 5.0
1951
1366
 
1952
- Fixes #12278.
1367
+ *Sean Griffin*
1953
1368
 
1954
- *kennyj*
1369
+ * Implemented `ActiveRecord::Base#pretty_print` to work with PP.
1955
1370
 
1956
- * Calling `update_attributes` will now throw an `ArgumentError` whenever it
1957
- gets a `nil` argument. More specifically, it will throw an error if the
1958
- argument that it gets passed does not respond to to `stringify_keys`.
1371
+ *Ethan*
1959
1372
 
1960
- Example:
1373
+ * Preserve type when dumping PostgreSQL point, bit, bit varying and money
1374
+ columns.
1961
1375
 
1962
- @my_comment.update_attributes(nil) # => raises ArgumentError
1376
+ *Yves Senn*
1963
1377
 
1964
- *John Wang*
1378
+ * New records remain new after YAML serialization.
1965
1379
 
1966
- * Deprecate `quoted_locking_column` method, which isn't used anywhere.
1380
+ *Sean Griffin*
1967
1381
 
1968
- *kennyj*
1382
+ * PostgreSQL support default values for enum types. Fixes #7814.
1969
1383
 
1970
- * Migration dump UUID default functions to schema.rb.
1384
+ *Yves Senn*
1971
1385
 
1972
- Fixes #10751.
1386
+ * PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
1973
1387
 
1974
- *kennyj*
1388
+ *Yves Senn*
1975
1389
 
1976
- * Fixed a bug in `ActiveRecord::Associations::CollectionAssociation#find_by_scan`
1977
- when using `has_many` association with `:inverse_of` option and UUID primary key.
1390
+ * Fix `columns_for_distinct` of PostgreSQL adapter to work correctly
1391
+ with orders without sort direction modifiers.
1978
1392
 
1979
- Fixes #10450.
1393
+ *Nikolay Kondratyev*
1980
1394
 
1981
- *kennyj*
1395
+ * PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
1982
1396
 
1983
- * Fix: joins association, with defined in the scope block constraints by using several
1984
- where constraints and at least of them is not `Arel::Nodes::Equality`,
1985
- generates invalid SQL expression.
1397
+ *Yves Senn*
1986
1398
 
1987
- Fixes #11963.
1399
+ * Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
1400
+ Fixes duplication in combination with `store_accessor`.
1988
1401
 
1989
- *Paul Nikitochkin*
1402
+ Fixes #15369.
1990
1403
 
1991
- * `CollectionAssociation#first`/`#last` (e.g. `has_many`) use a `LIMIT`ed
1992
- query to fetch results rather than loading the entire collection.
1404
+ *Yves Senn*
1993
1405
 
1994
- *Lann Martin*
1406
+ * `rake railties:install:migrations` respects the order of railties.
1995
1407
 
1996
- * Make possible to run SQLite rake tasks without the `Rails` constant defined.
1408
+ *Arun Agrawal*
1997
1409
 
1998
- *Damien Mathieu*
1410
+ * Fix redefine a `has_and_belongs_to_many` inside inherited class
1411
+ Fixing regression case, where redefining the same `has_and_belongs_to_many`
1412
+ definition into a subclass would raise.
1999
1413
 
2000
- * Allow Relation#from to accept other relations with bind values.
1414
+ Fixes #14983.
2001
1415
 
2002
- *Ryan Wallace*
1416
+ *arthurnn*
2003
1417
 
2004
- * Fix inserts with prepared statements disabled.
1418
+ * Fix `has_and_belongs_to_many` public reflection.
1419
+ When defining a `has_and_belongs_to_many`, internally we convert that to two has_many.
1420
+ But as `reflections` is a public API, people expect to see the right macro.
2005
1421
 
2006
- Fixes #12023.
1422
+ Fixes #14682.
2007
1423
 
2008
- *Rafael Mendonça França*
1424
+ *arthurnn*
2009
1425
 
2010
- * Setting a has_one association on a new record no longer causes an empty
2011
- transaction.
1426
+ * Fix serialization for records with an attribute named `format`.
2012
1427
 
2013
- *Dylan Thacker-Smith*
1428
+ Fixes #15188.
2014
1429
 
2015
- * Fix `AR::Relation#merge` sometimes failing to preserve `readonly(false)` flag.
1430
+ *Godfrey Chan*
2016
1431
 
2017
- *thedarkone*
1432
+ * When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
1433
+ on a NullRelation should return a Hash.
2018
1434
 
2019
- * Re-use `order` argument pre-processing for `reorder`.
1435
+ *Kuldeep Aggarwal*
2020
1436
 
2021
- *Paul Nikitochkin*
1437
+ * Fix serialized fields returning serialized data after being updated with
1438
+ `update_column`.
2022
1439
 
2023
- * Fix PredicateBuilder so polymorphic association keys in `where` clause can
2024
- accept objects other than direct descendants of `ActiveRecord::Base` (decorated
2025
- models, for example).
1440
+ *Simon Hørup Eskildsen*
2026
1441
 
2027
- *Mikhail Dieterle*
1442
+ * Fix polymorphic eager loading when using a String as foreign key.
2028
1443
 
2029
- * PostgreSQL adapter recognizes negative money values formatted with
2030
- parentheses (eg. `($1.25) # => -1.25`)).
2031
- Fixes #11899.
1444
+ Fixes #14734.
2032
1445
 
2033
- *Yves Senn*
1446
+ *Lauro Caetano*
2034
1447
 
2035
- * Stop interpreting SQL 'string' columns as :string type because there is no
2036
- common STRING datatype in SQL.
1448
+ * Change belongs_to touch to be consistent with timestamp updates
2037
1449
 
2038
- *Ben Woosley*
1450
+ If a model is set up with a belongs_to: touch relationship the parent
1451
+ record will only be touched if the record was modified. This makes it
1452
+ consistent with timestamp updating on the record itself.
2039
1453
 
2040
- * `ActiveRecord::FinderMethods#exists?` returns `true`/`false` in all cases.
1454
+ *Brock Trappitt*
2041
1455
 
2042
- *Xavier Noria*
1456
+ * Fix the inferred table name of a `has_and_belongs_to_many` auxiliary
1457
+ table inside a schema.
2043
1458
 
2044
- * Assign inet/cidr attribute with `nil` value for invalid address.
1459
+ Fixes #14824.
2045
1460
 
2046
- Example:
1461
+ *Eric Chahin*
2047
1462
 
2048
- record = User.new
2049
- record.logged_in_from_ip # is type of an inet or a cidr
1463
+ * Remove unused `:timestamp` type. Transparently alias it to `:datetime`
1464
+ in all cases. Fixes inconsistencies when column types are sent outside of
1465
+ `ActiveRecord`, such as for XML Serialization.
2050
1466
 
2051
- # Before:
2052
- record.logged_in_from_ip = 'bad ip address' # raise exception
1467
+ *Sean Griffin*
2053
1468
 
2054
- # After:
2055
- record.logged_in_from_ip = 'bad ip address' # do not raise exception
2056
- record.logged_in_from_ip # => nil
2057
- record.logged_in_from_ip_before_type_cast # => 'bad ip address'
1469
+ * Fix bug that added `table_name_prefix` and `table_name_suffix` to
1470
+ extension names in PostgreSQL when migrating.
2058
1471
 
2059
- *Paul Nikitochkin*
1472
+ *Joao Carlos*
2060
1473
 
2061
- * `add_to_target` now accepts a second optional `skip_callbacks` argument
1474
+ * The `:index` option in migrations, which previously was only available for
1475
+ `references`, now works with any column types.
2062
1476
 
2063
- If truthy, it will skip the :before_add and :after_add callbacks.
1477
+ *Marc Schütz*
2064
1478
 
2065
- *Ben Woosley*
1479
+ * Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
2066
1480
 
2067
- * Fix interactions between `:before_add` callbacks and nested attributes
2068
- assignment of `has_many` associations, when the association was not
2069
- yet loaded:
1481
+ *jnormore*
2070
1482
 
2071
- - A `:before_add` callback was being called when a nested attributes
2072
- assignment assigned to an existing record.
1483
+ * Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
1484
+ or `offset`.
2073
1485
 
2074
- - Nested Attributes assignment did not affect the record in the
2075
- association target when a `:before_add` callback triggered the
2076
- loading of the association
1486
+ In these cases the generated query ignored them and that caused unintended
1487
+ records to be deleted.
2077
1488
 
2078
- *Jörg Schray*
1489
+ Fixes #11985.
2079
1490
 
2080
- * Allow enable_extension migration method to be revertible.
1491
+ *Leandro Facchinetti*
2081
1492
 
2082
- *Eric Tipton*
1493
+ * Floats with limit >= 25 that get turned into doubles in MySQL no longer have
1494
+ their limit dropped from the schema.
2083
1495
 
2084
- * Type cast hstore values on write, so that the value is consistent
2085
- with reading from the database.
1496
+ Fixes #14135.
2086
1497
 
2087
- Example:
1498
+ *Aaron Nelson*
2088
1499
 
2089
- x = Hstore.new tags: {"bool" => true, "number" => 5}
1500
+ * Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many`
1501
+ association.
2090
1502
 
2091
- # Before:
2092
- x.tags # => {"bool" => true, "number" => 5}
1503
+ Fixes #14709.
2093
1504
 
2094
- # After:
2095
- x.tags # => {"bool" => "true", "number" => "5"}
1505
+ *Kassio Borges*
2096
1506
 
2097
- *Yves Senn* , *Severin Schoepke*
1507
+ * `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
1508
+ strings in column names as equal.
2098
1509
 
2099
- * Fix multidimensional PostgreSQL arrays containing non-string items.
1510
+ This fixes a rare case in which more bind values are passed than there are
1511
+ placeholders for them in the generated SQL statement, which can make PostgreSQL
1512
+ throw a `StatementInvalid` exception.
2100
1513
 
2101
- *Yves Senn*
1514
+ *Nat Budin*
2102
1515
 
2103
- * Fixes bug when using includes combined with select, the select statement was overwritten.
1516
+ * Fix `stored_attributes` to correctly merge the details of stored
1517
+ attributes defined in parent classes.
2104
1518
 
2105
- Fixes #11773.
1519
+ Fixes #14672.
2106
1520
 
2107
- *Edo Balvers*
1521
+ *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
2108
1522
 
2109
- * Load fixtures from linked folders.
1523
+ * `change_column_default` allows `[]` as argument to `change_column_default`.
2110
1524
 
2111
- *Kassio Borges*
1525
+ Fixes #11586.
2112
1526
 
2113
- * Create a directory for sqlite3 file if not present on the system.
1527
+ *Yves Senn*
2114
1528
 
2115
- *Richard Schneeman*
1529
+ * Handle `name` and `"char"` column types in the PostgreSQL adapter.
2116
1530
 
2117
- * Removed redundant override of `xml` column definition for PostgreSQL,
2118
- in order to use `xml` column type instead of `text`.
1531
+ `name` and `"char"` are special character types used internally by
1532
+ PostgreSQL and are used by internal system catalogs. These field types
1533
+ can sometimes show up in structure-sniffing queries that feature internal system
1534
+ structures or with certain PostgreSQL extensions.
2119
1535
 
2120
- *Paul Nikitochkin*, *Michael Nikitochkin*
1536
+ *J Smith*, *Yves Senn*
2121
1537
 
2122
- * Revert `ActiveRecord::Relation#order` change that make new order
2123
- prepend the old one.
1538
+ * Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
1539
+ NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
2124
1540
 
2125
1541
  Before:
2126
1542
 
2127
- User.order("name asc").order("created_at desc")
2128
- # SELECT * FROM users ORDER BY created_at desc, name asc
1543
+ Point.create(value: 1.0/0)
1544
+ Point.last.value # => 0.0
2129
1545
 
2130
1546
  After:
2131
1547
 
2132
- User.order("name asc").order("created_at desc")
2133
- # SELECT * FROM users ORDER BY name asc, created_at desc
1548
+ Point.create(value: 1.0/0)
1549
+ Point.last.value # => Infinity
2134
1550
 
2135
- This also affects order defined in `default_scope` or any kind of associations.
1551
+ *Innokenty Mikhailov*
2136
1552
 
2137
- * Add ability to define how a class is converted to Arel predicates.
2138
- For example, adding a very vendor specific regex implementation:
1553
+ * Allow the PostgreSQL adapter to handle bigserial primary key types again.
2139
1554
 
2140
- regex_handler = proc do |column, value|
2141
- Arel::Nodes::InfixOperation.new('~', column, value.source)
2142
- end
2143
- ActiveRecord::PredicateBuilder.register_handler(Regexp, regex_handler)
1555
+ Fixes #10410.
2144
1556
 
2145
- *Sean Griffin & @joannecheng*
1557
+ *Patrick Robertson*
2146
1558
 
2147
- * Don't allow `quote_value` to be called without a column.
1559
+ * Deprecate joining, eager loading and preloading of instance dependent
1560
+ associations without replacement. These operations happen before instances
1561
+ are created. The current behavior is unexpected and can result in broken
1562
+ behavior.
2148
1563
 
2149
- Some adapters require column information to do their job properly.
2150
- By enforcing the provision of the column for this internal method
2151
- we ensure that those using adapters that require column information
2152
- will always get the proper behavior.
1564
+ Fixes #15024.
2153
1565
 
2154
- *Ben Woosley*
1566
+ *Yves Senn*
2155
1567
 
2156
- * When using optimistic locking, `update` was not passing the column to `quote_value`
2157
- to allow the connection adapter to properly determine how to quote the value. This was
2158
- affecting certain databases that use specific column types.
1568
+ * Fix `has_and_belongs_to_many` CollectionAssociation size calculations.
2159
1569
 
2160
- Fixes #6763.
1570
+ `has_and_belongs_to_many` should fall back to using the normal CollectionAssociation's
1571
+ size calculation if the collection is not cached or loaded.
2161
1572
 
2162
- *Alfred Wong*
1573
+ Fixes #14913, #14914.
2163
1574
 
2164
- * rescue from all exceptions in `ConnectionManagement#call`
1575
+ *Fred Wu*
2165
1576
 
2166
- Fixes #11497.
1577
+ * Return a non zero status when running `rake db:migrate:status` and migration table does
1578
+ not exist.
2167
1579
 
2168
- As `ActiveRecord::ConnectionAdapters::ConnectionManagement` middleware does
2169
- not rescue from Exception (but only from StandardError), the Connection
2170
- Pool quickly runs out of connections when multiple erroneous Requests come
2171
- in right after each other.
1580
+ *Paul B.*
2172
1581
 
2173
- Rescuing from all exceptions and not just StandardError, fixes this
2174
- behaviour.
1582
+ * Add support for module-level `table_name_suffix` in models.
2175
1583
 
2176
- *Vipul A M*
1584
+ This makes `table_name_suffix` work the same way as `table_name_prefix` when
1585
+ using namespaced models.
2177
1586
 
2178
- * `change_column` for PostgreSQL adapter respects the `:array` option.
1587
+ *Jenner LaFave*
2179
1588
 
2180
- *Yves Senn*
1589
+ * Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
2181
1590
 
2182
- * Remove deprecation warning from `attribute_missing` for attributes that are columns.
1591
+ In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
1592
+ In 4.0 series it is delegated to `Array#join`.
2183
1593
 
2184
- *Arun Agrawal*
1594
+ *Bogdan Gusiev*
2185
1595
 
2186
- * Remove extra decrement of transaction deep level.
1596
+ * Log nil binary column values correctly.
2187
1597
 
2188
- Fixes #4566.
1598
+ When an object with a binary column is updated with a nil value
1599
+ in that column, the SQL logger would throw an exception when trying
1600
+ to log that nil value. This only occurs when updating a record
1601
+ that already has a non-nil value in that column since an initial nil
1602
+ value isn't included in the SQL anyway (at least, when dirty checking
1603
+ is enabled.) The column's new value will now be logged as `<NULL binary data>`
1604
+ to parallel the existing `<N bytes of binary data>` for non-nil values.
2189
1605
 
2190
- *Paul Nikitochkin*
1606
+ *James Coleman*
2191
1607
 
2192
- * Reset @column_defaults when assigning `locking_column`.
2193
- We had a potential problem. For example:
1608
+ * Rails will now pass a custom validation context through to autosave associations
1609
+ in order to validate child associations with the same context.
2194
1610
 
2195
- class Post < ActiveRecord::Base
2196
- self.column_defaults # if we call this unintentionally before setting locking_column ...
2197
- self.locking_column = 'my_locking_column'
2198
- end
1611
+ Fixes #13854.
2199
1612
 
2200
- Post.column_defaults["my_locking_column"]
2201
- => nil # expected value is 0 !
1613
+ *Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
2202
1614
 
2203
- *kennyj*
1615
+ * Stringify all variables keys of MySQL connection configuration.
2204
1616
 
2205
- * Remove extra select and update queries on save/touch/destroy ActiveRecord model
2206
- with belongs to reflection with option `touch: true`.
1617
+ When `sql_mode` variable for MySQL adapters set in configuration as `String`
1618
+ was ignored and overwritten by strict mode option.
2207
1619
 
2208
- Fixes #11288.
1620
+ Fixes #14895.
2209
1621
 
2210
1622
  *Paul Nikitochkin*
2211
1623
 
2212
- * Remove deprecated nil-passing to the following `SchemaCache` methods:
2213
- `primary_keys`, `tables`, `columns` and `columns_hash`.
1624
+ * Ensure SQLite3 statements are closed on errors.
2214
1625
 
2215
- *Yves Senn*
1626
+ Fixes #13631.
2216
1627
 
2217
- * Remove deprecated block filter from `ActiveRecord::Migrator#migrate`.
1628
+ *Timur Alperovich*
2218
1629
 
2219
- *Yves Senn*
1630
+ * Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve.
2220
1631
 
2221
- * Remove deprecated String constructor from `ActiveRecord::Migrator`.
1632
+ *Hector Satre*
2222
1633
 
2223
- *Yves Senn*
1634
+ * When using a custom `join_table` name on a `habtm`, rails was not saving it
1635
+ on Reflections. This causes a problem when rails loads fixtures, because it
1636
+ uses the reflections to set database with fixtures.
2224
1637
 
2225
- * Remove deprecated `scope` use without passing a callable object.
1638
+ Fixes #14845.
2226
1639
 
2227
- *Arun Agrawal*
1640
+ *Kassio Borges*
2228
1641
 
2229
- * Remove deprecated `transaction_joinable=` in favor of `begin_transaction`
2230
- with `:joinable` option.
1642
+ * Reset the cache when modifying a Relation with cached Arel.
1643
+ Additionally display a warning message to make the user aware.
2231
1644
 
2232
- *Arun Agrawal*
1645
+ *Yves Senn*
2233
1646
 
2234
- * Remove deprecated `decrement_open_transactions`.
1647
+ * PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
1648
+ different spellings of timestamps are treated the same.
2235
1649
 
2236
- *Arun Agrawal*
1650
+ Example:
2237
1651
 
2238
- * Remove deprecated `increment_open_transactions`.
1652
+ mytimestamp.simplified_type('timestamp without time zone')
1653
+ # => :datetime
1654
+ mytimestamp.simplified_type('timestamp(6) without time zone')
1655
+ # => also :datetime (previously would be :timestamp)
2239
1656
 
2240
- *Arun Agrawal*
1657
+ See #14513.
2241
1658
 
2242
- * Remove deprecated `PostgreSQLAdapter#outside_transaction?`
2243
- method. You can use `#transaction_open?` instead.
1659
+ *Jefferson Lai*
2244
1660
 
2245
- *Yves Senn*
1661
+ * `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
2246
1662
 
2247
- * Remove deprecated `ActiveRecord::Fixtures.find_table_name` in favor of
2248
- `ActiveRecord::Fixtures.default_fixture_model_name`.
1663
+ Fixes #14841.
1664
+
1665
+ *Lucas Mazza*
2249
1666
 
2250
- *Vipul A M*
1667
+ * Fix name collision with `Array#select!` with `Relation#select!`.
2251
1668
 
2252
- * Removed deprecated `columns_for_remove` from `SchemaStatements`.
1669
+ Fixes #14752.
2253
1670
 
2254
- *Neeraj Singh*
1671
+ *Earl St Sauver*
2255
1672
 
2256
- * Remove deprecated `SchemaStatements#distinct`.
1673
+ * Fix unexpected behavior for `has_many :through` associations going through
1674
+ a scoped `has_many`.
2257
1675
 
2258
- *Francesco Rodriguez*
1676
+ If a `has_many` association is adjusted using a scope, and another
1677
+ `has_many :through` uses this association, then the scope adjustment is
1678
+ unexpectedly neglected.
2259
1679
 
2260
- * Move deprecated `ActiveRecord::TestCase` into the rails test
2261
- suite. The class is no longer public and is only used for internal
2262
- Rails tests.
1680
+ Fixes #14537.
2263
1681
 
2264
- *Yves Senn*
1682
+ *Jan Habermann*
2265
1683
 
2266
- * Removed support for deprecated option `:restrict` for `:dependent`
2267
- in associations.
1684
+ * `@destroyed` should always be set to `false` when an object is duped.
2268
1685
 
2269
- *Neeraj Singh*
1686
+ *Kuldeep Aggarwal*
2270
1687
 
2271
- * Removed support for deprecated `delete_sql` in associations.
1688
+ * Enable `has_many` associations to support irregular inflections.
2272
1689
 
2273
- *Neeraj Singh*
1690
+ Fixes #8928.
2274
1691
 
2275
- * Removed support for deprecated `insert_sql` in associations.
1692
+ *arthurnn*, *Javier Goizueta*
2276
1693
 
2277
- *Neeraj Singh*
1694
+ * Fix `count` used with a grouping not returning a Hash.
2278
1695
 
2279
- * Removed support for deprecated `finder_sql` in associations.
1696
+ Fixes #14721.
2280
1697
 
2281
- *Neeraj Singh*
1698
+ *Eric Chahin*
2282
1699
 
2283
- * Support array as root element in JSON fields.
1700
+ * `sanitize_sql_like` helper method to escape a string for safe use in an SQL
1701
+ LIKE statement.
2284
1702
 
2285
- *Alexey Noskov & Francesco Rodriguez*
1703
+ Example:
2286
1704
 
2287
- * Removed support for deprecated `counter_sql` in associations.
1705
+ class Article
1706
+ def self.search(term)
1707
+ where("title LIKE ?", sanitize_sql_like(term))
1708
+ end
1709
+ end
2288
1710
 
2289
- *Neeraj Singh*
1711
+ Article.search("20% _reduction_")
1712
+ # => Query looks like "... title LIKE '20\% \_reduction\_' ..."
2290
1713
 
2291
- * Do not invoke callbacks when `delete_all` is called on collection.
1714
+ *Rob Gilson*, *Yves Senn*
2292
1715
 
2293
- Method `delete_all` should not be invoking callbacks and this
2294
- feature was deprecated in Rails 4.0. This is being removed.
2295
- `delete_all` will continue to honor the `:dependent` option. However
2296
- if `:dependent` value is `:destroy` then the `:delete_all` deletion
2297
- strategy for that collection will be applied.
1716
+ * Do not quote uuid default value on `change_column`.
2298
1717
 
2299
- User can also force a deletion strategy by passing parameter to
2300
- `delete_all`. For example you can do `@post.comments.delete_all(:nullify)`.
1718
+ Fixes #14604.
2301
1719
 
2302
- *Neeraj Singh*
1720
+ *Eric Chahin*
2303
1721
 
2304
- * Calling default_scope without a proc will now raise `ArgumentError`.
1722
+ * The comparison between `Relation` and `CollectionProxy` should be consistent.
2305
1723
 
2306
- *Neeraj Singh*
1724
+ Example:
2307
1725
 
2308
- * Removed deprecated method `type_cast_code` from Column.
1726
+ author.posts == Post.where(author_id: author.id)
1727
+ # => true
1728
+ Post.where(author_id: author.id) == author.posts
1729
+ # => true
2309
1730
 
2310
- *Neeraj Singh*
1731
+ Fixes #13506.
2311
1732
 
2312
- * Removed deprecated options `delete_sql` and `insert_sql` from HABTM
2313
- association.
1733
+ *Lauro Caetano*
2314
1734
 
2315
- Removed deprecated options `finder_sql` and `counter_sql` from
2316
- collection association.
1735
+ * Calling `delete_all` on an unloaded `CollectionProxy` no longer
1736
+ generates an SQL statement containing each id of the collection:
2317
1737
 
2318
- *Neeraj Singh*
1738
+ Before:
2319
1739
 
2320
- * Remove deprecated `ActiveRecord::Base#connection` method.
2321
- Make sure to access it via the class.
1740
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
1741
+ AND `model`.`id` IN (1, 2, 3...)
2322
1742
 
2323
- *Yves Senn*
1743
+ After:
2324
1744
 
2325
- * Remove deprecation warning for `auto_explain_threshold_in_seconds`.
1745
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
2326
1746
 
2327
- *Yves Senn*
1747
+ *Eileen M. Uchitelle*, *Aaron Patterson*
2328
1748
 
2329
- * Remove deprecated `:distinct` option from `Relation#count`.
1749
+ * Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
1750
+ with `select`.
2330
1751
 
2331
- *Yves Senn*
1752
+ Fixes #13648.
2332
1753
 
2333
- * Removed deprecated methods `partial_updates`, `partial_updates?` and
2334
- `partial_updates=`.
1754
+ *Simon Woker*
2335
1755
 
2336
- *Neeraj Singh*
1756
+ * PostgreSQL adapter only warns once for every missing OID per connection.
2337
1757
 
2338
- * Removed deprecated method `scoped`.
1758
+ Fixes #14275.
2339
1759
 
2340
- *Neeraj Singh*
1760
+ *Matthew Draper*, *Yves Senn*
2341
1761
 
2342
- * Removed deprecated method `default_scopes?`.
1762
+ * PostgreSQL adapter automatically reloads it's type map when encountering
1763
+ unknown OIDs.
2343
1764
 
2344
- *Neeraj Singh*
1765
+ Fixes #14678.
2345
1766
 
2346
- * Remove implicit join references that were deprecated in 4.0.
1767
+ *Matthew Draper*, *Yves Senn*
2347
1768
 
2348
- Example:
1769
+ * Fix insertion of records via `has_many :through` association with scope.
2349
1770
 
2350
- # before with implicit joins
2351
- Comment.where('posts.author_id' => 7)
1771
+ Fixes #3548.
2352
1772
 
2353
- # after
2354
- Comment.references(:posts).where('posts.author_id' => 7)
1773
+ *Ivan Antropov*
2355
1774
 
2356
- *Yves Senn*
1775
+ * Auto-generate stable fixture UUIDs on PostgreSQL.
2357
1776
 
2358
- * Apply default scope when joining associations. For example:
1777
+ Fixes #11524.
2359
1778
 
2360
- class Post < ActiveRecord::Base
2361
- default_scope -> { where published: true }
2362
- end
1779
+ *Roderick van Domburg*
2363
1780
 
2364
- class Comment
2365
- belongs_to :post
2366
- end
1781
+ * Fix a problem where an enum would overwrite values of another enum with the
1782
+ same name in an unrelated class.
2367
1783
 
2368
- When calling `Comment.joins(:post)`, we expect to receive only
2369
- comments on published posts, since that is the default scope for
2370
- posts.
1784
+ Fixes #14607.
2371
1785
 
2372
- Before this change, the default scope from `Post` was not applied,
2373
- so we'd get comments on unpublished posts.
1786
+ *Evan Whalen*
2374
1787
 
2375
- *Jon Leighton*
1788
+ * PostgreSQL and SQLite string columns no longer have a default limit of 255.
2376
1789
 
2377
- * Remove `activerecord-deprecated_finders` as a dependency.
1790
+ Fixes #13435, #9153.
2378
1791
 
2379
- *Łukasz Strzałkowski*
1792
+ *Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
2380
1793
 
2381
- * Remove Oracle / Sqlserver / Firebird database tasks that were deprecated in 4.0.
1794
+ * Make possible to have an association called `records`.
2382
1795
 
2383
- *kennyj*
1796
+ Fixes #11645.
2384
1797
 
2385
- * `find_each` now returns an `Enumerator` when called without a block, so that it
2386
- can be chained with other `Enumerable` methods.
1798
+ *prathamesh-sonpatki*
2387
1799
 
2388
- *Ben Woosley*
1800
+ * `to_sql` on an association now matches the query that is actually executed, where it
1801
+ could previously have incorrectly accrued additional conditions (e.g. as a result of
1802
+ a previous query). `CollectionProxy` now always defers to the association scope's
1803
+ `arel` method so the (incorrect) inherited one should be entirely concealed.
2389
1804
 
2390
- * `ActiveRecord::Result.each` now returns an `Enumerator` when called without
2391
- a block, so that it can be chained with other `Enumerable` methods.
1805
+ Fixes #14003.
2392
1806
 
2393
- *Ben Woosley*
1807
+ *Jefferson Lai*
2394
1808
 
2395
- * Flatten merged join_values before building the joins.
1809
+ * Block a few default Class methods as scope name.
2396
1810
 
2397
- While joining_values special treatment is given to string values.
2398
- By flattening the array it ensures that string values are detected
2399
- as strings and not arrays.
1811
+ For instance, this will raise:
2400
1812
 
2401
- Fixes #10669.
1813
+ scope :public, -> { where(status: 1) }
2402
1814
 
2403
- *Neeraj Singh and iwiznia*
1815
+ *arthurnn*
2404
1816
 
2405
- * Do not load all child records for inverse case.
1817
+ * Fix error when using `with_options` with lambda.
2406
1818
 
2407
- currently `post.comments.find(Comment.first.id)` would load all
2408
- comments for the given post to set the inverse association.
1819
+ Fixes #9805.
2409
1820
 
2410
- This has a huge performance penalty. Because if post has 100k
2411
- records and all these 100k records would be loaded in memory
2412
- even though the comment id was supplied.
1821
+ *Lauro Caetano*
2413
1822
 
2414
- Fix is to use in-memory records only if loaded? is true. Otherwise
2415
- load the records using full sql.
1823
+ * Switch `sqlite3:///` URLs (which were temporarily
1824
+ deprecated in 4.1) from relative to absolute.
2416
1825
 
2417
- Fixes #10509.
1826
+ If you still want the previous interpretation, you should replace
1827
+ `sqlite3:///my/path` with `sqlite3:my/path`.
2418
1828
 
2419
- *Neeraj Singh*
1829
+ *Matthew Draper*
2420
1830
 
2421
- * `inspect` on Active Record model classes does not initiate a
2422
- new connection. This means that calling `inspect`, when the
2423
- database is missing, will no longer raise an exception.
2424
- Fixes #10936.
1831
+ * Treat blank UUID values as `nil`.
2425
1832
 
2426
1833
  Example:
2427
1834
 
2428
- Author.inspect # => "Author(no database connection)"
2429
-
2430
- *Yves Senn*
1835
+ Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
2431
1836
 
2432
- * Handle single quotes in PostgreSQL default column values.
2433
- Fixes #10881.
1837
+ *Dmitry Lavrov*
2434
1838
 
2435
- *Dylan Markow*
1839
+ * Enable support for materialized views on PostgreSQL >= 9.3.
2436
1840
 
2437
- * Log the sql that is actually sent to the database.
1841
+ *Dave Lee*
2438
1842
 
2439
- If I have a query that produces sql
2440
- `WHERE "users"."name" = 'a b'` then in the log all the
2441
- whitespace is being squeezed. So the sql that is printed in the
2442
- log is `WHERE "users"."name" = 'a b'`.
1843
+ * The PostgreSQL adapter supports custom domains. Fixes #14305.
2443
1844
 
2444
- Do not squeeze whitespace out of sql queries. Fixes #10982.
1845
+ *Yves Senn*
2445
1846
 
2446
- *Neeraj Singh*
1847
+ * PostgreSQL `Column#type` is now determined through the corresponding OID.
1848
+ The column types stay the same except for enum columns. They no longer have
1849
+ `nil` as type but `enum`.
2447
1850
 
2448
- * Fixture setup no longer depends on `ActiveRecord::Base.configurations`.
2449
- This is relevant when `ENV["DATABASE_URL"]` is used in place of a `database.yml`.
1851
+ See #7814.
2450
1852
 
2451
1853
  *Yves Senn*
2452
1854
 
2453
- * Fix mysql2 adapter raises the correct exception when executing a query on a
2454
- closed connection.
1855
+ * Fix error when specifying a non-empty default value on a PostgreSQL array
1856
+ column.
2455
1857
 
2456
- *Yves Senn*
1858
+ Fixes #10613.
2457
1859
 
2458
- * Ambiguous reflections are on :through relationships are no longer supported.
2459
- For example, you need to change this:
1860
+ *Luke Steensen*
2460
1861
 
2461
- class Author < ActiveRecord::Base
2462
- has_many :posts
2463
- has_many :taggings, through: :posts
2464
- end
1862
+ * Fix error where `.persisted?` throws SystemStackError for an unsaved model with a
1863
+ custom primary key that did not save due to validation error.
2465
1864
 
2466
- class Post < ActiveRecord::Base
2467
- has_one :tagging
2468
- has_many :taggings
2469
- end
1865
+ Fixes #14393.
2470
1866
 
2471
- class Tagging < ActiveRecord::Base
2472
- end
1867
+ *Chris Finne*
2473
1868
 
2474
- To this:
1869
+ * Introduce `validate` as an alias for `valid?`.
2475
1870
 
2476
- class Author < ActiveRecord::Base
2477
- has_many :posts
2478
- has_many :taggings, through: :posts, source: :tagging
2479
- end
1871
+ This is more intuitive when you want to run validations but don't care about the return value.
2480
1872
 
2481
- class Post < ActiveRecord::Base
2482
- has_one :tagging
2483
- has_many :taggings
2484
- end
1873
+ *Henrik Nyh*
2485
1874
 
2486
- class Tagging < ActiveRecord::Base
2487
- end
1875
+ * Create indexes inline in CREATE TABLE for MySQL.
2488
1876
 
2489
- *Aaron Patterson*
1877
+ This is important, because adding an index on a temporary table after it has been created
1878
+ would commit the transaction.
2490
1879
 
2491
- * Remove column restrictions for `count`, let the database raise if the SQL is
2492
- invalid. The previous behavior was untested and surprising for the user.
2493
- Fixes #5554.
1880
+ It also allows creating and dropping indexed tables with fewer queries and fewer permissions
1881
+ required.
2494
1882
 
2495
1883
  Example:
2496
1884
 
2497
- User.select("name, username").count
2498
- # Before => SELECT count(*) FROM users
2499
- # After => ActiveRecord::StatementInvalid
2500
-
2501
- # you can still use `count(:all)` to perform a query unrelated to the
2502
- # selected columns
2503
- User.select("name, username").count(:all) # => SELECT count(*) FROM users
2504
-
2505
- *Yves Senn*
2506
-
2507
- * Rails now automatically detects inverse associations. If you do not set the
2508
- `:inverse_of` option on the association, then Active Record will guess the
2509
- inverse association based on heuristics.
2510
-
2511
- Note that automatic inverse detection only works on `has_many`, `has_one`,
2512
- and `belongs_to` associations. Extra options on the associations will
2513
- also prevent the association's inverse from being found automatically.
2514
-
2515
- The automatic guessing of the inverse association uses a heuristic based
2516
- on the name of the class, so it may not work for all associations,
2517
- especially the ones with non-standard names.
2518
-
2519
- You can turn off the automatic detection of inverse associations by setting
2520
- the `:inverse_of` option to `false` like so:
2521
-
2522
- class Taggable < ActiveRecord::Base
2523
- belongs_to :tag, inverse_of: false
1885
+ create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t|
1886
+ t.index :zip
2524
1887
  end
1888
+ # => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
2525
1889
 
2526
- *John Wang*
1890
+ *Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
2527
1891
 
2528
- * Fix `add_column` with `array` option when using PostgreSQL. Fixes #10432.
1892
+ * Use singular table name in generated migrations when
1893
+ `ActiveRecord::Base.pluralize_table_names` is `false`.
2529
1894
 
2530
- *Adam Anderson*
1895
+ Fixes #13426.
1896
+
1897
+ *Kuldeep Aggarwal*
2531
1898
 
2532
- * Usage of `implicit_readonly` is being removed`. Please use `readonly` method
2533
- explicitly to mark records as `readonly.
2534
- Fixes #10615.
1899
+ * `touch` accepts many attributes to be touched at once.
2535
1900
 
2536
1901
  Example:
2537
1902
 
2538
- user = User.joins(:todos).select("users.*, todos.title as todos_title").readonly(true).first
2539
- user.todos_title = 'clean pet'
2540
- user.save! # will raise error
1903
+ # touches :signed_at, :sealed_at, and :updated_at/on attributes.
1904
+ Photo.last.touch(:signed_at, :sealed_at)
2541
1905
 
2542
- *Yves Senn*
1906
+ *James Pinto*
2543
1907
 
2544
- * Fix the `:primary_key` option for `has_many` associations.
1908
+ * `rake db:structure:dump` only dumps schema information if the schema
1909
+ migration table exists.
2545
1910
 
2546
- Fixes #10693.
1911
+ Fixes #14217.
2547
1912
 
2548
1913
  *Yves Senn*
2549
1914
 
2550
- * Fix bug where tiny types are incorrectly coerced as boolean when the length is more than 1.
1915
+ * Reap connections that were checked out by now-dead threads, instead
1916
+ of waiting until they disconnect by themselves. Before this change,
1917
+ a suitably constructed series of short-lived threads could starve
1918
+ the connection pool, without ever having more than a couple alive at
1919
+ the same time.
2551
1920
 
2552
- Fixes #10620.
2553
-
2554
- *Aaron Patterson*
1921
+ *Matthew Draper*
2555
1922
 
2556
- * Also support extensions in PostgreSQL 9.1. This feature has been supported since 9.1.
1923
+ * `pk_and_sequence_for` now ensures that only the pg_depend entries
1924
+ pointing to pg_class, and thus only sequence objects, are considered.
2557
1925
 
2558
- *kennyj*
1926
+ *Josh Williams*
2559
1927
 
2560
- * Deprecate `ConnectionAdapters::SchemaStatements#distinct`,
2561
- as it is no longer used by internals.
1928
+ * `where.not` adds `references` for `includes` like normal `where` calls do.
2562
1929
 
2563
- *Ben Woosley*
1930
+ Fixes #14406.
2564
1931
 
2565
- * Fix pending migrations error when loading schema and `ActiveRecord::Base.table_name_prefix`
2566
- is not blank.
1932
+ *Yves Senn*
2567
1933
 
2568
- Call `assume_migrated_upto_version` on connection to prevent it from first
2569
- being picked up in `method_missing`.
1934
+ * Extend fixture `$LABEL` replacement to allow string interpolation.
2570
1935
 
2571
- In the base class, `Migration`, `method_missing` expects the argument to be a
2572
- table name, and calls `proper_table_name` on the arguments before sending to
2573
- `connection`. If `table_name_prefix` or `table_name_suffix` is used, the schema
2574
- version changes to `prefix_version_suffix`, breaking `rake test:prepare`.
1936
+ Example:
2575
1937
 
2576
- Fixes #10411.
1938
+ martin:
1939
+ email: $LABEL@email.com
2577
1940
 
2578
- *Kyle Stevens*
1941
+ users(:martin).email # => martin@email.com
2579
1942
 
2580
- * Method `read_attribute_before_type_cast` should accept input as symbol.
1943
+ *Eric Steele*
2581
1944
 
2582
- *Neeraj Singh*
1945
+ * Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
2583
1946
 
2584
- * Confirm a record has not already been destroyed before decrementing counter cache.
1947
+ Fixes #14361.
2585
1948
 
2586
- *Ben Tucker*
1949
+ *arthurnn*
2587
1950
 
2588
- * Fixed a bug in `ActiveRecord#sanitize_sql_hash_for_conditions` in which
2589
- `self.class` is an argument to `PredicateBuilder#build_from_hash`
2590
- causing `PredicateBuilder` to call non-existent method
2591
- `Class#reflect_on_association`.
1951
+ * Passing an Active Record object to `find` or `exists?` is now deprecated.
1952
+ Call `.id` on the object first.
2592
1953
 
2593
- *Zach Ohlgren*
1954
+ *Aaron Patterson*
2594
1955
 
2595
- * While removing index if column option is missing then raise IrreversibleMigration exception.
1956
+ * Only use BINARY for MySQL case sensitive uniqueness check when column
1957
+ has a case insensitive collation.
2596
1958
 
2597
- Following code should raise `IrreversibleMigration`. But the code was
2598
- failing since options is an array and not a hash.
1959
+ *Ryuta Kamizono*
2599
1960
 
2600
- def change
2601
- change_table :users do |t|
2602
- t.remove_index [:name, :email]
2603
- end
2604
- end
1961
+ * Support for MySQL 5.6 fractional seconds.
2605
1962
 
2606
- Fix was to check if the options is a Hash before operating on it.
1963
+ *arthurnn*, *Tatsuhiko Miyagawa*
2607
1964
 
2608
- Fixes #10419.
1965
+ * Support for PostgreSQL `citext` data type enabling case-insensitive
1966
+ `where` values without needing to wrap in UPPER/LOWER sql functions.
2609
1967
 
2610
- *Neeraj Singh*
1968
+ *Troy Kruthoff*, *Lachlan Sylvester*
2611
1969
 
2612
- * Do not overwrite manually built records during one-to-one nested attribute assignment
1970
+ * Only save has_one associations if record has changes.
1971
+ Previously after save related callbacks, such as `#after_commit`, were triggered when the has_one
1972
+ object did not get saved to the db.
2613
1973
 
2614
- For one-to-one nested associations, if you build the new (in-memory)
2615
- child object yourself before assignment, then the NestedAttributes
2616
- module will not overwrite it, e.g.:
1974
+ *Alan Kennedy*
2617
1975
 
2618
- class Member < ActiveRecord::Base
2619
- has_one :avatar
2620
- accepts_nested_attributes_for :avatar
1976
+ * Allow strings to specify the `#order` value.
2621
1977
 
2622
- def avatar
2623
- super || build_avatar(width: 200)
2624
- end
2625
- end
1978
+ Example:
2626
1979
 
2627
- member = Member.new
2628
- member.avatar_attributes = {icon: 'sad'}
2629
- member.avatar.width # => 200
1980
+ Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
2630
1981
 
2631
- *Olek Janiszewski*
1982
+ *Marcelo Casiraghi*, *Robin Dupret*
2632
1983
 
2633
- * fixes bug introduced by #3329. Now, when autosaving associations,
2634
- deletions happen before inserts and saves. This prevents a 'duplicate
2635
- unique value' database error that would occur if a record being created had
2636
- the same value on a unique indexed field as that of a record being destroyed.
1984
+ * Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
1985
+ warnings on enum columns.
2637
1986
 
2638
- *Johnny Holton*
1987
+ *Dieter Komendera*
2639
1988
 
2640
- * Handle aliased attributes in ActiveRecord::Relation.
1989
+ * `includes` is able to detect the right preloading strategy when string
1990
+ joins are involved.
2641
1991
 
2642
- When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database:
1992
+ Fixes #14109.
2643
1993
 
2644
- With the model
1994
+ *Aaron Patterson*, *Yves Senn*
2645
1995
 
2646
- class Topic
2647
- alias_attribute :heading, :title
2648
- end
1996
+ * Fix error with validation with enum fields for records where the value for
1997
+ any enum attribute is always evaluated as 0 during uniqueness validation.
2649
1998
 
2650
- The call
1999
+ Fixes #14172.
2651
2000
 
2652
- Topic.where(heading: 'The First Topic')
2001
+ *Vilius Luneckas* *Ahmed AbouElhamayed*
2653
2002
 
2654
- should yield the same result as
2003
+ * `before_add` callbacks are fired before the record is saved on
2004
+ `has_and_belongs_to_many` associations *and* on `has_many :through`
2005
+ associations. Before this change, `before_add` callbacks would be fired
2006
+ before the record was saved on `has_and_belongs_to_many` associations, but
2007
+ *not* on `has_many :through` associations.
2655
2008
 
2656
- Topic.where(title: 'The First Topic')
2009
+ Fixes #14144.
2657
2010
 
2658
- This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`.
2011
+ * Fix STI classes not defining an attribute method if there is a conflicting
2012
+ private method defined on its ancestors.
2659
2013
 
2660
- This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`.
2014
+ Fixes #11569.
2661
2015
 
2662
2016
  *Godfrey Chan*
2663
2017
 
2664
- * Mute `psql` output when running rake db:schema:load.
2018
+ * Coerce strings when reading attributes. Fixes #10485.
2665
2019
 
2666
- *Godfrey Chan*
2020
+ Example:
2667
2021
 
2668
- * Trigger a save on `has_one association=(associate)` when the associate contents have changed.
2022
+ book = Book.new(title: 12345)
2023
+ book.save!
2024
+ book.title # => "12345"
2669
2025
 
2670
- Fixes #8856.
2026
+ *Yves Senn*
2671
2027
 
2672
- *Chris Thompson*
2028
+ * Deprecate half-baked support for PostgreSQL range values with excluding beginnings.
2029
+ We currently map PostgreSQL ranges to Ruby ranges. This conversion is not fully
2030
+ possible because the Ruby range does not support excluded beginnings.
2673
2031
 
2674
- * Abort a rake task when missing db/structure.sql like `db:schema:load` task.
2032
+ The current solution of incrementing the beginning is not correct and is now
2033
+ deprecated. For subtypes where we don't know how to increment (e.g. `#succ`
2034
+ is not defined) it will raise an `ArgumentException` for ranges with excluding
2035
+ beginnings.
2675
2036
 
2676
- *kennyj*
2037
+ *Yves Senn*
2677
2038
 
2678
- * rake:db:test:prepare falls back to original environment after execution.
2039
+ * Support for user created range types in PostgreSQL.
2679
2040
 
2680
- *Slava Markevich*
2041
+ *Yves Senn*
2681
2042
 
2682
- Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes.
2043
+ Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activerecord/CHANGELOG.md) for previous changes.