activerecord 4.1.0 → 4.2.0

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 +4 -4
  2. data/CHANGELOG.md +776 -1330
  3. data/README.rdoc +15 -10
  4. data/lib/active_record/aggregations.rb +12 -8
  5. data/lib/active_record/association_relation.rb +4 -0
  6. data/lib/active_record/associations/alias_tracker.rb +14 -13
  7. data/lib/active_record/associations/association.rb +2 -2
  8. data/lib/active_record/associations/association_scope.rb +83 -43
  9. data/lib/active_record/associations/belongs_to_association.rb +15 -5
  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/has_and_belongs_to_many.rb +9 -6
  13. data/lib/active_record/associations/builder/has_many.rb +1 -1
  14. data/lib/active_record/associations/builder/has_one.rb +2 -2
  15. data/lib/active_record/associations/builder/singular_association.rb +8 -1
  16. data/lib/active_record/associations/collection_association.rb +66 -29
  17. data/lib/active_record/associations/collection_proxy.rb +22 -26
  18. data/lib/active_record/associations/has_many_association.rb +65 -18
  19. data/lib/active_record/associations/has_many_through_association.rb +55 -27
  20. data/lib/active_record/associations/has_one_association.rb +0 -1
  21. data/lib/active_record/associations/join_dependency/join_association.rb +19 -15
  22. data/lib/active_record/associations/join_dependency/join_part.rb +0 -1
  23. data/lib/active_record/associations/join_dependency.rb +20 -12
  24. data/lib/active_record/associations/preloader/association.rb +34 -11
  25. data/lib/active_record/associations/preloader/through_association.rb +4 -3
  26. data/lib/active_record/associations/preloader.rb +49 -59
  27. data/lib/active_record/associations/singular_association.rb +25 -4
  28. data/lib/active_record/associations/through_association.rb +23 -14
  29. data/lib/active_record/associations.rb +171 -42
  30. data/lib/active_record/attribute.rb +149 -0
  31. data/lib/active_record/attribute_assignment.rb +18 -10
  32. data/lib/active_record/attribute_decorators.rb +66 -0
  33. data/lib/active_record/attribute_methods/before_type_cast.rb +2 -2
  34. data/lib/active_record/attribute_methods/dirty.rb +98 -44
  35. data/lib/active_record/attribute_methods/primary_key.rb +14 -8
  36. data/lib/active_record/attribute_methods/query.rb +1 -1
  37. data/lib/active_record/attribute_methods/read.rb +22 -59
  38. data/lib/active_record/attribute_methods/serialization.rb +37 -147
  39. data/lib/active_record/attribute_methods/time_zone_conversion.rb +34 -28
  40. data/lib/active_record/attribute_methods/write.rb +14 -21
  41. data/lib/active_record/attribute_methods.rb +67 -94
  42. data/lib/active_record/attribute_set/builder.rb +86 -0
  43. data/lib/active_record/attribute_set.rb +77 -0
  44. data/lib/active_record/attributes.rb +139 -0
  45. data/lib/active_record/autosave_association.rb +45 -38
  46. data/lib/active_record/base.rb +10 -20
  47. data/lib/active_record/callbacks.rb +7 -7
  48. data/lib/active_record/coders/json.rb +13 -0
  49. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +78 -52
  50. data/lib/active_record/connection_adapters/abstract/database_statements.rb +38 -59
  51. data/lib/active_record/connection_adapters/abstract/query_cache.rb +1 -0
  52. data/lib/active_record/connection_adapters/abstract/quoting.rb +59 -55
  53. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +46 -5
  54. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +126 -54
  55. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +14 -34
  56. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +198 -64
  57. data/lib/active_record/connection_adapters/abstract/transaction.rb +126 -114
  58. data/lib/active_record/connection_adapters/abstract_adapter.rb +154 -55
  59. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +240 -135
  60. data/lib/active_record/connection_adapters/column.rb +28 -239
  61. data/lib/active_record/connection_adapters/connection_specification.rb +16 -25
  62. data/lib/active_record/connection_adapters/mysql2_adapter.rb +20 -22
  63. data/lib/active_record/connection_adapters/mysql_adapter.rb +65 -149
  64. data/lib/active_record/connection_adapters/postgresql/array_parser.rb +15 -27
  65. data/lib/active_record/connection_adapters/postgresql/column.rb +20 -0
  66. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +39 -27
  67. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +99 -0
  68. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +52 -0
  69. data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +13 -0
  70. data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +14 -0
  71. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +46 -0
  72. data/lib/active_record/connection_adapters/postgresql/oid/date.rb +11 -0
  73. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +27 -0
  74. data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +13 -0
  75. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +17 -0
  76. data/lib/active_record/connection_adapters/postgresql/oid/float.rb +21 -0
  77. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +59 -0
  78. data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +13 -0
  79. data/lib/active_record/connection_adapters/postgresql/oid/infinity.rb +13 -0
  80. data/lib/active_record/connection_adapters/postgresql/oid/integer.rb +11 -0
  81. data/lib/active_record/connection_adapters/postgresql/oid/json.rb +35 -0
  82. data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +23 -0
  83. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +43 -0
  84. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +43 -0
  85. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +79 -0
  86. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +15 -0
  87. data/lib/active_record/connection_adapters/postgresql/oid/time.rb +11 -0
  88. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +97 -0
  89. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +21 -0
  90. data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +26 -0
  91. data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +28 -0
  92. data/lib/active_record/connection_adapters/postgresql/oid.rb +29 -374
  93. data/lib/active_record/connection_adapters/postgresql/quoting.rb +55 -135
  94. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +4 -4
  95. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +152 -0
  96. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +127 -38
  97. data/lib/active_record/connection_adapters/postgresql/utils.rb +77 -0
  98. data/lib/active_record/connection_adapters/postgresql_adapter.rb +220 -466
  99. data/lib/active_record/connection_adapters/schema_cache.rb +14 -28
  100. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +66 -61
  101. data/lib/active_record/connection_handling.rb +3 -3
  102. data/lib/active_record/core.rb +143 -32
  103. data/lib/active_record/counter_cache.rb +60 -7
  104. data/lib/active_record/enum.rb +10 -11
  105. data/lib/active_record/errors.rb +49 -27
  106. data/lib/active_record/explain.rb +1 -1
  107. data/lib/active_record/fixtures.rb +56 -70
  108. data/lib/active_record/gem_version.rb +2 -2
  109. data/lib/active_record/inheritance.rb +35 -10
  110. data/lib/active_record/integration.rb +4 -4
  111. data/lib/active_record/locking/optimistic.rb +35 -17
  112. data/lib/active_record/log_subscriber.rb +1 -1
  113. data/lib/active_record/migration/command_recorder.rb +19 -2
  114. data/lib/active_record/migration/join_table.rb +1 -1
  115. data/lib/active_record/migration.rb +52 -49
  116. data/lib/active_record/model_schema.rb +49 -57
  117. data/lib/active_record/nested_attributes.rb +7 -7
  118. data/lib/active_record/null_relation.rb +19 -5
  119. data/lib/active_record/persistence.rb +50 -31
  120. data/lib/active_record/query_cache.rb +3 -3
  121. data/lib/active_record/querying.rb +10 -7
  122. data/lib/active_record/railtie.rb +14 -11
  123. data/lib/active_record/railties/databases.rake +56 -54
  124. data/lib/active_record/readonly_attributes.rb +0 -1
  125. data/lib/active_record/reflection.rb +286 -102
  126. data/lib/active_record/relation/batches.rb +0 -1
  127. data/lib/active_record/relation/calculations.rb +39 -31
  128. data/lib/active_record/relation/delegation.rb +2 -2
  129. data/lib/active_record/relation/finder_methods.rb +80 -36
  130. data/lib/active_record/relation/merger.rb +25 -30
  131. data/lib/active_record/relation/predicate_builder/array_handler.rb +31 -13
  132. data/lib/active_record/relation/predicate_builder/relation_handler.rb +1 -1
  133. data/lib/active_record/relation/predicate_builder.rb +11 -10
  134. data/lib/active_record/relation/query_methods.rb +141 -55
  135. data/lib/active_record/relation/spawn_methods.rb +3 -0
  136. data/lib/active_record/relation.rb +69 -30
  137. data/lib/active_record/result.rb +18 -7
  138. data/lib/active_record/sanitization.rb +12 -2
  139. data/lib/active_record/schema.rb +0 -1
  140. data/lib/active_record/schema_dumper.rb +58 -26
  141. data/lib/active_record/schema_migration.rb +11 -0
  142. data/lib/active_record/scoping/default.rb +8 -7
  143. data/lib/active_record/scoping/named.rb +4 -0
  144. data/lib/active_record/serializers/xml_serializer.rb +3 -7
  145. data/lib/active_record/statement_cache.rb +95 -10
  146. data/lib/active_record/store.rb +19 -10
  147. data/lib/active_record/tasks/database_tasks.rb +73 -7
  148. data/lib/active_record/tasks/mysql_database_tasks.rb +3 -2
  149. data/lib/active_record/tasks/postgresql_database_tasks.rb +1 -1
  150. data/lib/active_record/tasks/sqlite_database_tasks.rb +5 -1
  151. data/lib/active_record/timestamp.rb +11 -9
  152. data/lib/active_record/transactions.rb +37 -21
  153. data/lib/active_record/type/big_integer.rb +13 -0
  154. data/lib/active_record/type/binary.rb +50 -0
  155. data/lib/active_record/type/boolean.rb +30 -0
  156. data/lib/active_record/type/date.rb +46 -0
  157. data/lib/active_record/type/date_time.rb +43 -0
  158. data/lib/active_record/type/decimal.rb +40 -0
  159. data/lib/active_record/type/decimal_without_scale.rb +11 -0
  160. data/lib/active_record/type/decorator.rb +14 -0
  161. data/lib/active_record/type/float.rb +19 -0
  162. data/lib/active_record/type/hash_lookup_type_map.rb +17 -0
  163. data/lib/active_record/type/integer.rb +55 -0
  164. data/lib/active_record/type/mutable.rb +16 -0
  165. data/lib/active_record/type/numeric.rb +36 -0
  166. data/lib/active_record/type/serialized.rb +56 -0
  167. data/lib/active_record/type/string.rb +36 -0
  168. data/lib/active_record/type/text.rb +11 -0
  169. data/lib/active_record/type/time.rb +26 -0
  170. data/lib/active_record/type/time_value.rb +38 -0
  171. data/lib/active_record/type/type_map.rb +64 -0
  172. data/lib/active_record/type/unsigned_integer.rb +15 -0
  173. data/lib/active_record/type/value.rb +101 -0
  174. data/lib/active_record/type.rb +23 -0
  175. data/lib/active_record/validations/associated.rb +5 -3
  176. data/lib/active_record/validations/presence.rb +6 -4
  177. data/lib/active_record/validations/uniqueness.rb +11 -17
  178. data/lib/active_record/validations.rb +25 -19
  179. data/lib/active_record.rb +3 -0
  180. data/lib/rails/generators/active_record/migration/migration_generator.rb +8 -4
  181. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +4 -1
  182. data/lib/rails/generators/active_record/migration/templates/migration.rb +6 -0
  183. data/lib/rails/generators/active_record/model/templates/model.rb +1 -1
  184. metadata +65 -10
  185. data/lib/active_record/connection_adapters/postgresql/cast.rb +0 -168
data/CHANGELOG.md CHANGED
@@ -1,1926 +1,1372 @@
1
- * Fixed a problem where an enum would overwrite values of another enum
2
- with the same name in an unrelated class.
1
+ * Introduce `force: :cascade` option for `create_table`. Using this option
2
+ will recreate tables even if they have dependent objects (like foreign keys).
3
+ `db/schema.rb` now uses `force: :cascade`. This makes it possible to
4
+ reload the schema when foreign keys are in place.
3
5
 
4
- Fixes #14607.
5
-
6
- *Evan Whalen*
7
-
8
- * Block a few default Class methods as scope name.
9
-
10
- For instance, this will raise:
11
-
12
- scope :public, -> { where(status: 1) }
13
-
14
- *arthurnn*
15
-
16
- * Deprecate SQLite database URLs containing an
17
- authority.
18
-
19
- The current "correct" spellings for in-memory, relative, and
20
- absolute URLs, respectively, are:
6
+ *Matthew Draper*, *Yves Senn*
21
7
 
22
- sqlite3::memory:
23
- sqlite3:relative/path
24
- sqlite3:/full/path
8
+ * `db:schema:load` and `db:structure:load` no longer purge the database
9
+ before loading the schema. This is left for the user to do.
10
+ `db:test:prepare` will still purge the database.
25
11
 
26
- The previous spelling (`sqlite3:///relative/path`) continues to work
27
- as it did in Rails 4.0, but with a deprecation warning: in the next
28
- release, that spelling will instead be interpreted as an absolute
29
- path.
30
-
31
- *Matthew Draper*
32
-
33
- * `where.not` adds `references` for `includes` like normal `where` calls do.
34
-
35
- Fixes #14406.
12
+ Closes #17945.
36
13
 
37
14
  *Yves Senn*
38
15
 
39
- * `includes` is able to detect the right preloading strategy when string
40
- joins are involved.
41
-
42
- Fixes #14109.
43
-
44
- *Aaron Patterson*, *Yves Senn*
45
-
46
- * Fixed error with validation with enum fields for records where the
47
- value for any enum attribute is always evaluated as 0 during
48
- uniqueness validation.
49
-
50
- Fixes #14172.
51
-
52
- *Vilius Luneckas* *Ahmed AbouElhamayed*
53
-
54
- * `before_add` callbacks are fired before the record is saved on
55
- `has_and_belongs_to_many` assocations *and* on `has_many :through`
56
- associations. Before this change, `before_add` callbacks would be fired
57
- before the record was saved on `has_and_belongs_to_many` associations, but
58
- *not* on `has_many :through` associations.
59
-
60
- Fixes #14144.
61
-
62
- * Fixed STI classes not defining an attribute method if there is a
63
- conflicting private method defined on its ancestors.
64
-
65
- Fixes #11569.
66
-
67
- *Godfrey Chan*
68
-
69
- * Default scopes are no longer overriden by chained conditions.
70
-
71
- Before this change when you defined a `default_scope` in a model
72
- it was overriden by chained conditions in the same field. Now it
73
- is merged like any other scope.
74
-
75
- Before:
76
-
77
- class User < ActiveRecord::Base
78
- default_scope { where state: 'pending' }
79
- scope :active, -> { where state: 'active' }
80
- scope :inactive, -> { where state: 'inactive' }
81
- end
82
-
83
- User.all
84
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
85
-
86
- User.active
87
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
88
-
89
- User.where(state: 'inactive')
90
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
16
+ * Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.
91
17
 
92
- After:
93
-
94
- class User < ActiveRecord::Base
95
- default_scope { where state: 'pending' }
96
- scope :active, -> { where state: 'active' }
97
- scope :inactive, -> { where state: 'inactive' }
98
- end
99
-
100
- User.all
101
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
102
-
103
- User.active
104
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'active'
105
-
106
- User.where(state: 'inactive')
107
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'inactive'
108
-
109
- To get the previous behavior it is needed to explicitly remove the
110
- `default_scope` condition using `unscoped`, `unscope`, `rewhere` or
111
- `except`.
112
-
113
- Example:
114
-
115
- class User < ActiveRecord::Base
116
- default_scope { where state: 'pending' }
117
- scope :active, -> { unscope(where: :state).where(state: 'active') }
118
- scope :inactive, -> { rewhere state: 'inactive' }
119
- end
120
-
121
- User.all
122
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
123
-
124
- User.active
125
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
18
+ *Ryuta Kamizono*
126
19
 
127
- User.inactive
128
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
20
+ * Add `foreign_type` option to `has_one` and `has_many` association macros.
129
21
 
130
- * Perform necessary deeper encoding when hstore is inside an array.
22
+ This option enables to define the column name of associated object's type for polymorphic associations.
131
23
 
132
- Fixes #11135.
24
+ *Ulisses Almeida, Kassio Borges*
133
25
 
134
- *Josh Goodall*, *Genadi Samokovarov*
26
+ * `add_timestamps` and `remove_timestamps` now properly reversible with
27
+ options.
135
28
 
136
- * Properly detect if a connection is still active before using it
137
- in multi-threaded environments.
29
+ *Noam Gagliardi-Rabinovich*
138
30
 
139
- Fixes #12867.
31
+ * Bring back `db:test:prepare` to synchronize the test database schema.
140
32
 
141
- *Kevin Casey*, *Matthew Draper*, *William (B.J.) Snow Orvis*
33
+ Manual synchronization using `bin/rake db:test:prepare` is required
34
+ when a migration is rolled-back, edited and reapplied.
142
35
 
143
- * When inverting add_index use the index name if present instead of
144
- the columns.
36
+ `ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
37
+ to synchronize the schema. Plugins can use this task as a hook to
38
+ provide custom behavior after the schema has been loaded.
145
39
 
146
- If there are two indices with matching columns and one of them is
147
- explicitly named then reverting the migration adding the named one
148
- would instead drop the unnamed one.
40
+ NOTE: `test:prepare` runs before the schema is synchronized.
149
41
 
150
- The inversion of add_index will now drop the index by its name if
151
- it is present.
42
+ Fixes #17171, #15787.
152
43
 
153
- *Hubert Dąbrowski*
154
-
155
- * Add flag to disable schema dump after migration.
156
-
157
- Add a config parameter on Active Record named `dump_schema_after_migration`
158
- which is true by default. Now schema dump does not happen at the
159
- end of migration rake task if `dump_schema_after_migration` is false.
160
-
161
- *Emil Soman*
162
-
163
- * `find_in_batches`, `find_each`, `Result#each` and `Enumerable#index_by` now
164
- return an `Enumerator` that can calculate its size.
44
+ *Yves Senn*
165
45
 
166
- See also #13938.
46
+ * Change `reflections` public api to return the keys as String objects.
167
47
 
168
- *Marc-André Lafortune*
48
+ Fixes #16928.
169
49
 
170
- * Make sure transaction state gets reset after a commit operation on the record.
50
+ *arthurnn*
171
51
 
172
- If a new transaction was open inside a callback, the record was loosing track
173
- of the transaction level state, and it was leaking that state.
52
+ * Renaming a table in pg also renames the primary key index.
174
53
 
175
- Fixes #12566.
54
+ Fixes #12856
176
55
 
177
- *arthurnn*
56
+ *Sean Griffin*
178
57
 
179
- * Pass `has_and_belongs_to_many` `:autosave` option to
180
- the underlying `has_many :through` association.
181
-
182
- Fixes #13923.
58
+ * Make it possible to access fixtures excluded by a `default_scope`.
183
59
 
184
60
  *Yves Senn*
185
61
 
186
- * PostgreSQL implementation of `SchemaStatements#index_name_exists?`.
62
+ * Fix preloading of associations with a scope containing joins along with
63
+ conditions on the joined association.
187
64
 
188
- The database agnostic implementation does not detect with indexes that are
189
- not supported by the ActiveRecord schema dumper. For example, expressions
190
- indexes would not be detected.
65
+ *Siddharth Sharma*
191
66
 
192
- Fixes #11018.
67
+ * Add `Table#name` to match `TableDefinition#name`.
193
68
 
194
- *Jonathan Baudanza*
69
+ *Cody Cutrer*
195
70
 
196
- * Parsing PostgreSQL arrays with empty strings now works correctly.
71
+ * Cache `CollectionAssociation#reader` proxies separately before and after
72
+ the owner has been saved so that the proxy is not cached without the
73
+ owner's id.
197
74
 
198
- Previously, if you tried to parse `{"1","","2","","3"}` the result
199
- would be `["1","2","3"]`, removing the empty strings from the array,
200
- which would be incorrect. Now it will correctly produce `["1","","2","","3"]`
201
- as the result of parsing the above PostgreSQL array.
75
+ *Ben Woosley*
202
76
 
203
- Fixes #13907.
77
+ * `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
204
78
 
205
- *Maurício Linhares*
79
+ *Franky W.*
206
80
 
207
- * Associations now raise `ArgumentError` on name conflicts.
81
+ * Fix preloading of associations which unscope a default scope.
208
82
 
209
- Dangerous association names conflicts include instance or class methods already
210
- defined by `ActiveRecord::Base`.
83
+ Fixes #11036.
211
84
 
212
- Example:
85
+ *Byron Bischoff*
213
86
 
214
- class Car < ActiveRecord::Base
215
- has_many :errors
216
- end
217
- # Will raise ArgumentError.
87
+ * Added SchemaDumper support for tables with jsonb columns.
218
88
 
219
- Fixes #13217.
89
+ *Ted O'Meara*
220
90
 
221
- *Lauro Caetano*
91
+ * Deprecate `sanitize_sql_hash_for_conditions` without replacement. Using a
92
+ `Relation` for performing queries and updates is the prefered API.
222
93
 
223
- * Fix regressions on `select_*` methods.
224
- When `select_*` methods receive a `Relation` object, they should be able to
225
- get the arel/binds from it.
226
- Also fix regressions on `select_rows` that was ignoring the binds.
94
+ *Sean Griffin*
227
95
 
228
- Fixes #7538, #12017, #13731, #12056.
96
+ * Queries now properly type cast values that are part of a join statement,
97
+ even when using type decorators such as `serialize`.
229
98
 
230
- *arthurnn*
99
+ *Melanie Gilman & Sean Griffin*
231
100
 
232
- * Active Record objects can now be correctly dumped, loaded and dumped again
233
- without issues.
101
+ * MySQL enum type lookups, with values matching another type, no longer result
102
+ in an endless loop.
234
103
 
235
- Previously, if you did `YAML.dump`, `YAML.load` and then `YAML.dump` again
236
- in an Active Record model that used serialization it would fail at the last
237
- dump due to the fields not being correctly serialized before being dumped
238
- to YAML. Now it is possible to dump and load the same object as many times
239
- as needed without any issues.
104
+ Fixes #17402.
240
105
 
241
- Fixes #13861.
106
+ *Yves Senn*
242
107
 
243
- *Maurício Linhares*
108
+ * Raise `ArgumentError` when the body of a scope is not callable.
244
109
 
245
- * `find_in_batches` now returns an `Enumerator` when called without a block, so that it
246
- can be chained with other `Enumerable` methods.
110
+ *Mauro George*
247
111
 
248
- *Marc-André Lafortune*
112
+ * Use type column first in multi-column indexes created with `add-reference`.
249
113
 
250
- * `enum` now raises on "dangerous" name conflicts.
114
+ *Derek Prior*
251
115
 
252
- Dangerous name conflicts includes instance or class method conflicts
253
- with methods defined within `ActiveRecord::Base` but not its ancestors,
254
- as well as conflicts with methods generated by other enums on the same
255
- class.
116
+ * Fix `Relation.rewhere` to work with Range values.
256
117
 
257
- Fixes #13389.
118
+ *Dan Olson*
258
119
 
259
- *Godfrey Chan*
120
+ * `AR::UnknownAttributeError` now includes the class name of a record.
260
121
 
261
- * `scope` now raises on "dangerous" name conflicts.
122
+ User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"})
123
+ # => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
262
124
 
263
- Similar to dangerous attribute methods, a scope name conflict is
264
- dangerous if it conflicts with an existing class method defined within
265
- `ActiveRecord::Base` but not its ancestors.
125
+ *Yuki Nishijima*
266
126
 
267
- See also #13389.
127
+ * Fix a regression causing `after_create` callbacks to run before associated
128
+ records are autosaved.
268
129
 
269
- *Godfrey Chan*, *Philippe Creux*
130
+ Fixes #17209.
270
131
 
271
- * Correctly send an user provided statement to a `lock!()` call.
132
+ *Agis Anastasopoulos*
272
133
 
273
- person.lock! 'FOR SHARE NOWAIT'
274
- # Before: SELECT * ... LIMIT 1 FOR UPDATE
275
- # After: SELECT * ... LIMIT 1 FOR SHARE NOWAIT
134
+ * Honor overridden `rack.test` in Rack environment for the connection
135
+ management middleware.
276
136
 
277
- Fixes #13788.
137
+ *Simon Eskildsen*
278
138
 
279
- *Maurício Linhares*
139
+ * Add a truncate method to the connection.
280
140
 
281
- * Handle aliased attributes `select()`, `order()` and `reorder()`.
141
+ *Aaron Patterson*
282
142
 
283
- *Tsutomu Kuroda*
143
+ * Don't autosave unchanged has_one through records.
284
144
 
285
- * Reset the collection association when calling `reset` on it.
145
+ *Alan Kennedy*, *Steve Parrington*
286
146
 
287
- Before:
147
+ * Do not dump foreign keys for ignored tables.
288
148
 
289
- post.comments.loaded? # => true
290
- post.comments.reset
291
- post.comments.loaded? # => true
149
+ *Yves Senn*
292
150
 
293
- After:
151
+ * PostgreSQL adapter correctly dumps foreign keys targeting tables
152
+ outside the schema search path.
294
153
 
295
- post.comments.loaded? # => true
296
- post.comments.reset
297
- post.comments.loaded? # => false
154
+ Fixes #16907.
298
155
 
299
- Fixes #13777.
156
+ *Matthew Draper*, *Yves Senn*
300
157
 
301
- *Kelsey Schlarman*
158
+ * When a thread is killed, rollback the active transaction, instead of
159
+ committing it during the stack unwind. Previously, we could commit half-
160
+ completed work. This fix only works for Ruby 2.0+; on 1.9, we can't
161
+ distinguish a thread kill from an ordinary non-local (block) return, so must
162
+ default to committing.
302
163
 
303
- * Make enum fields work as expected with the `ActiveModel::Dirty` API.
164
+ *Chris Hanks*
304
165
 
305
- Before this change, using the dirty API would have surprising results:
166
+ * A `NullRelation` should represent nothing. This fixes a bug where
167
+ `Comment.where(post_id: Post.none)` returned a non-empty result.
306
168
 
307
- conversation = Conversation.new
308
- conversation.status = :active
309
- conversation.status = :archived
310
- conversation.status_was # => 0
169
+ Fixes #15176.
311
170
 
312
- After this change, the same code would result in:
171
+ *Matthew Draper*, *Yves Senn*
313
172
 
314
- conversation = Conversation.new
315
- conversation.status = :active
316
- conversation.status = :archived
317
- conversation.status_was # => "active"
173
+ * Include default column limits in schema.rb. Allows defaults to be changed
174
+ in the future without affecting old migrations that assumed old defaults.
318
175
 
319
- *Rafael Mendonça França*
176
+ *Jeremy Kemper*
320
177
 
321
- * `has_one` and `belongs_to` accessors don't add ORDER BY to the queries
322
- anymore.
178
+ * MySQL: schema.rb now includes TEXT and BLOB column limits.
323
179
 
324
- Since Rails 4.0, we add an ORDER BY in the `first` method to ensure
325
- consistent results among different database engines. But for singular
326
- associations this behavior is not needed since we will have one record to
327
- return. As this ORDER BY option can lead some performance issues we are
328
- removing it for singular associations accessors.
180
+ *Jeremy Kemper*
329
181
 
330
- Fixes #12623.
182
+ * MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB.
331
183
 
332
- *Rafael Mendonça França*
184
+ *Jeremy Kemper*
333
185
 
334
- * Prepend table name for column names passed to `Relation#select`.
186
+ * SQLite3Adapter now checks for views in `table_exists?`. Fixes #14041.
335
187
 
336
- Example:
188
+ *Girish Sonawane*
337
189
 
338
- Post.select(:id)
339
- # Before: => SELECT id FROM "posts"
340
- # After: => SELECT "posts"."id" FROM "posts"
190
+ * Introduce `connection.supports_views?` to check whether the current adapter
191
+ has support for SQL views. Connection adapters should define this method.
341
192
 
342
193
  *Yves Senn*
343
194
 
344
- * Fail early with "Primary key not included in the custom select clause"
345
- in `find_in_batches`.
346
-
347
- Before this patch, the exception was raised after the first batch was
348
- yielded to the block. This means that you only get it, when you hit the
349
- `batch_size` treshold. This could shadow the issue in development.
350
-
351
- *Alexander Balashov*
195
+ * Allow included modules to override association methods.
352
196
 
353
- * Ensure `second` through `fifth` methods act like the `first` finder.
197
+ Fixes #16684.
354
198
 
355
- The famous ordinal Array instance methods defined in ActiveSupport
356
- (`first`, `second`, `third`, `fourth`, and `fifth`) are now available as
357
- full-fledged finders in ActiveRecord. The biggest benefit of this is ordering
358
- of the records returned now defaults to the table's primary key in ascending order.
359
-
360
- Fixes #13743.
199
+ *Yves Senn*
361
200
 
362
- Example:
201
+ * Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
202
+ the database connection to the current environment.
363
203
 
364
- User.all.second
204
+ Fixes #16757.
365
205
 
366
- # Before
367
- # => 'SELECT "users".* FROM "users"'
206
+ *Joshua Cody*, *Yves Senn*
368
207
 
369
- # After
370
- # => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 1'
208
+ * MySQL: set the connection collation along with the charset.
371
209
 
372
- User.offset(3).second
210
+ Sets the connection collation to the database collation configured in
211
+ database.yml. Otherwise, `SET NAMES utf8mb4` will use the default
212
+ collation for that charset (utf8mb4_general_ci) when you may have chosen
213
+ a different collation, like utf8mb4_unicode_ci.
373
214
 
374
- # Before
375
- # => 'SELECT "users".* FROM "users" LIMIT -1 OFFSET 3' # sqlite3 gem
376
- # => 'SELECT "users".* FROM "users" OFFSET 3' # pg gem
377
- # => 'SELECT `users`.* FROM `users` LIMIT 18446744073709551615 OFFSET 3' # mysql2 gem
215
+ This only applies to literal string comparisons, not column values, so it
216
+ is unlikely to affect you.
378
217
 
379
- # After
380
- # => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 4'
218
+ *Jeremy Kemper*
381
219
 
382
- *Jason Meller*
220
+ * `default_sequence_name` from the PostgreSQL adapter returns a `String`.
383
221
 
384
- * ActiveRecord states are now correctly restored after a rollback for
385
- models that did not define any transactional callbacks (i.e.
386
- `after_commit`, `after_rollback` or `after_create`).
222
+ *Yves Senn*
387
223
 
388
- Fixes #13744.
224
+ * Fix a regression where whitespaces were stripped from DISTINCT queries in
225
+ PostgreSQL.
389
226
 
390
- *Godfrey Chan*
227
+ *Agis Anastasopoulos*
391
228
 
392
- * Make `touch` fire the `after_commit` and `after_rollback` callbacks.
229
+ Fixes #16623.
393
230
 
394
- *Harry Brundage*
231
+ * Fix has_many :through relation merging failing when dynamic conditions are
232
+ passed as a lambda with an arity of one.
395
233
 
396
- * Enable partial indexes for `sqlite >= 3.8.0`.
234
+ Fixes #16128.
397
235
 
398
- See http://www.sqlite.org/partialindex.html
236
+ *Agis Anastasopoulos*
399
237
 
400
- *Cody Cutrer*
238
+ * Fix `Relation#exists?` to work with polymorphic associations.
401
239
 
402
- * Don't try to get the subclass if the inheritance column doesn't exist
240
+ Fixes #15821.
403
241
 
404
- The `subclass_from_attrs` method is called even if the column specified by
405
- the `inheritance_column` setting doesn't exist. This prevents setting associations
406
- via the attributes hash if the association name clashes with the value of the setting,
407
- typically `:type`. This worked previously in Rails 3.2.
242
+ *Kassio Borges*
408
243
 
409
- *Ujjwal Thaakar*
244
+ * Currently, Active Record rescues any errors raised within
245
+ `after_rollback`/`after_create` callbacks and prints them to the logs.
246
+ Future versions of Rails will not rescue these errors anymore and
247
+ just bubble them up like the other callbacks.
410
248
 
411
- * Enum mappings are now exposed via class methods instead of constants.
249
+ This commit adds an opt-in flag to enable not rescuing the errors.
412
250
 
413
251
  Example:
414
252
 
415
- class Conversation < ActiveRecord::Base
416
- enum status: [ :active, :archived ]
417
- end
253
+ # Do not swallow errors in after_commit/after_rollback callbacks.
254
+ config.active_record.raise_in_transactional_callbacks = true
418
255
 
419
- Before:
256
+ Fixes #13460.
420
257
 
421
- Conversation::STATUS # => { "active" => 0, "archived" => 1 }
258
+ *arthurnn*
422
259
 
423
- After:
260
+ * Fix an issue where custom accessor methods (such as those generated by
261
+ `enum`) with the same name as a global method are incorrectly overridden
262
+ when subclassing.
424
263
 
425
- Conversation.statuses # => { "active" => 0, "archived" => 1 }
264
+ Fixes #16288.
426
265
 
427
266
  *Godfrey Chan*
428
267
 
429
- * Set `NameError#name` when STI-class-lookup fails.
430
-
431
- *Chulki Lee*
268
+ * `*_was` and `changes` now work correctly for in-place attribute changes as
269
+ well.
432
270
 
433
- * Fix bug in `becomes!` when changing from the base model to a STI sub-class.
271
+ *Sean Griffin*
434
272
 
435
- Fixes #13272.
273
+ * Fix regression on `after_commit` that did not fire with nested transactions.
436
274
 
437
- *the-web-dev*, *Yves Senn*
275
+ Fixes #16425.
438
276
 
439
- * Currently Active Record can be configured via the environment variable
440
- `DATABASE_URL` or by manually injecting a hash of values which is what Rails does,
441
- reading in `database.yml` and setting Active Record appropriately. Active Record
442
- expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot
443
- rip out this functionality without deprecating. This presents a problem though
444
- when both config is set, and a `DATABASE_URL` is present. Currently the
445
- `DATABASE_URL` should "win" and none of the values in `database.yml` are
446
- used. This is somewhat unexpected, if one were to set values such as
447
- `pool` in the `production:` group of `database.yml` they are ignored.
448
-
449
- There are many ways that Active Record initiates a connection today:
450
-
451
- - Stand Alone (without rails)
452
- - `rake db:<tasks>`
453
- - `ActiveRecord.establish_connection`
454
-
455
- - With Rails
456
- - `rake db:<tasks>`
457
- - `rails <server> | <console>`
458
- - `rails dbconsole`
459
-
460
- Now all of these behave exactly the same way. The best way to do
461
- this is to put all of this logic in one place so it is guaranteed to be used.
462
-
463
- Here is the matrix of how this behavior works:
464
-
465
- ```
466
- No database.yml
467
- No DATABASE_URL
468
- => Error
469
- ```
470
-
471
- ```
472
- database.yml present
473
- No DATABASE_URL
474
- => Use database.yml configuration
475
- ```
476
-
477
- ```
478
- No database.yml
479
- DATABASE_URL present
480
- => use DATABASE_URL configuration
481
- ```
482
-
483
- ```
484
- database.yml present
485
- DATABASE_URL present
486
- => Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url`
487
- sub key "wins". If other paramaters `adapter` or `database` are specified in YAML,
488
- they are discarded as the `url` sub key "wins".
489
- ```
277
+ *arthurnn*
490
278
 
491
- Current implementation uses `ActiveRecord::Base.configurations` to resolve and merge
492
- all connection information before returning. This is achieved through a utility
493
- class: `ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig`.
279
+ * Do not try to write timestamps when a table has no timestamps columns.
494
280
 
495
- To understand the exact behavior of this class, it is best to review the
496
- behavior in `activerecord/test/cases/connection_adapters/connection_handler_test.rb`.
281
+ Fixes #8813.
497
282
 
498
- *Richard Schneeman*
283
+ *Sergey Potapov*
499
284
 
500
- * Make `change_column_null` revertable. Fixes #13576.
285
+ * `index_exists?` with `:name` option does verify specified columns.
501
286
 
502
- *Yves Senn*, *Nishant Modak*, *Prathamesh Sonpatki*
287
+ Example:
503
288
 
504
- * Don't create/drop the test database if RAILS_ENV is specified explicitly.
289
+ add_index :articles, :title, name: "idx_title"
505
290
 
506
- Previously, when the environment was development, we would always
507
- create or drop both the test and development databases.
291
+ # Before:
292
+ index_exists? :articles, :title, name: "idx_title" # => `true`
293
+ index_exists? :articles, :body, name: "idx_title" # => `true`
508
294
 
509
- Now, if RAILS_ENV is explicitly defined as development, we don't create
510
- the test database.
295
+ # After:
296
+ index_exists? :articles, :title, name: "idx_title" # => `true`
297
+ index_exists? :articles, :body, name: "idx_title" # => `false`
511
298
 
512
- *Damien Mathieu*
299
+ *Yves Senn*, *Matthew Draper*
513
300
 
514
- * Initialize version on Migration objects so that it can be used in a migration,
515
- and it will be included in the announce message.
301
+ * `add_timestamps` and `t.timestamps` now require you to pass the `:null` option.
302
+ Not passing the option is deprecated but the default is still `null: true`.
303
+ With Rails 5 this will change to `null: false`.
516
304
 
517
- *Dylan Thacker-Smith*
305
+ *Sean Griffin*
518
306
 
519
- * `change_table` now uses the current adapter's `update_table_definition`
520
- method to retrieve a specific table definition.
521
- This ensures that `change_table` and `create_table` will use
522
- similar objects.
307
+ * When calling `update_columns` on a record that is not persisted, the error
308
+ message now reflects whether that object is a new record or has been
309
+ destroyed.
523
310
 
524
- Fixes #13577, #13503.
311
+ *Lachlan Sylvester*
525
312
 
526
- *Nishant Modak*, *Prathamesh Sonpatki*, *Rafael Mendonça França*
313
+ * Define `id_was` to get the previous value of the primary key.
527
314
 
528
- * Fixed ActiveRecord::Store nil conversion TypeError when using YAML coder.
529
- In case the YAML passed as paramter is nil, uses an empty string.
315
+ Currently when we call `id_was` and we have a custom primary key name,
316
+ Active Record will return the current value of the primary key. This
317
+ makes it impossible to correctly do an update operation if you change the
318
+ id.
530
319
 
531
- Fixes #13570.
320
+ Fixes #16413.
532
321
 
533
- *Thales Oliveira*
322
+ *Rafael Mendonça França*
534
323
 
535
- * Deprecate unused `ActiveRecord::Base.symbolized_base_class`
536
- and `ActiveRecord::Base.symbolized_sti_name` without replacement.
324
+ * Deprecate `DatabaseTasks.load_schema` to act on the current connection.
325
+ Use `.load_schema_current` instead. In the future `load_schema` will
326
+ require the `configuration` to act on as an argument.
537
327
 
538
328
  *Yves Senn*
539
329
 
540
- * Since the `test_help.rb` file in Railties now automatically maintains
541
- your test schema, the `rake db:test:*` tasks are deprecated. This
542
- doesn't stop you manually running other tasks on your test database
543
- if needed:
544
-
545
- rake db:schema:load RAILS_ENV=test
546
-
547
- *Jon Leighton*
548
-
549
- * Fix presence validator for association when the associated record responds to `to_a`.
550
-
551
- *gmarik*
552
-
553
- * Fixed regression on preload/includes with multiple arguments failing in certain conditions,
554
- raising a NoMethodError internally by calling `reflect_on_association` for `NilClass:Class`.
330
+ * Fix automatic maintaining test schema to properly handle sql structure
331
+ schema format.
555
332
 
556
- Fixes #13437.
333
+ Fixes #15394.
557
334
 
558
- *Vipul A M*, *khustochka*
335
+ *Wojciech Wnętrzak*
559
336
 
560
- * Add the ability to nullify the `enum` column.
337
+ * Fix type casting to Decimal from Float with large precision.
561
338
 
562
- Example:
339
+ *Tomohiro Hashidate*
563
340
 
564
- class Conversation < ActiveRecord::Base
565
- enum gender: [:female, :male]
566
- end
341
+ * Deprecate `Reflection#source_macro`
567
342
 
568
- Conversation::GENDER # => { female: 0, male: 1 }
343
+ `Reflection#source_macro` is no longer needed in Active Record
344
+ source so it has been deprecated. Code that used `source_macro`
345
+ was removed in #16353.
569
346
 
570
- # conversation.update! gender: 0
571
- conversation.female!
572
- conversation.female? # => true
573
- conversation.gender # => "female"
347
+ *Eileen M. Uchtitelle*, *Aaron Patterson*
574
348
 
575
- # conversation.update! gender: nil
576
- conversation.gender = nil
577
- conversation.gender.nil? # => true
578
- conversation.gender # => nil
349
+ * No verbose backtrace by `db:drop` when database does not exist.
579
350
 
580
- *Amr Tamimi*
351
+ Fixes #16295.
581
352
 
582
- * Connection specification now accepts a "url" key. The value of this
583
- key is expected to contain a database URL. The database URL will be
584
- expanded into a hash and merged.
353
+ *Kenn Ejima*
585
354
 
586
- *Richard Schneeman*
587
-
588
- * An `ArgumentError` is now raised on a call to `Relation#where.not(nil)`.
355
+ * Add support for PostgreSQL JSONB.
589
356
 
590
357
  Example:
591
358
 
592
- User.where.not(nil)
593
-
594
- # Before
595
- # => 'SELECT `users`.* FROM `users` WHERE (NOT (NULL))'
596
-
597
- # After
598
- # => ArgumentError, 'Invalid argument for .where.not(), got nil.'
599
-
600
- *Kuldeep Aggarwal*
601
-
602
- * Deprecated use of string argument as a configuration lookup in
603
- `ActiveRecord::Base.establish_connection`. Instead, a symbol must be given.
604
-
605
- *José Valim*
606
-
607
- * Fixed `update_column`, `update_columns`, and `update_all` to correctly serialize
608
- values for `array`, `hstore` and `json` column types in PostgreSQL.
609
-
610
- Fixes #12261.
611
-
612
- *Tadas Tamosauskas*, *Carlos Antonio da Silva*
613
-
614
- * Do not consider PostgreSQL array columns as number or text columns.
615
-
616
- The code uses these checks in several places to know what to do with a
617
- particular column, for instance AR attribute query methods has a branch
618
- like this:
619
-
620
- if column.number?
621
- !value.zero?
359
+ create_table :posts do |t|
360
+ t.jsonb :meta_data
622
361
  end
623
362
 
624
- This should never be true for array columns, since it would be the same
625
- as running [].zero?, which results in a NoMethodError exception.
363
+ *Philippe Creux*, *Chris Teague*
626
364
 
627
- Fixing this by ensuring that array columns in PostgreSQL never return
628
- true for number?/text? checks.
365
+ * `db:purge` with MySQL respects `Rails.env`.
629
366
 
630
- *Carlos Antonio da Silva*
631
-
632
- * When connecting to a non-existant database, the error:
633
- `ActiveRecord::NoDatabaseError` will now be raised. When being used with Rails
634
- the error message will include information on how to create a database:
635
- `rake db:create`. Supported adapters: postgresql, mysql, mysql2, sqlite3
636
-
637
- *Richard Schneeman*
638
-
639
- * Do not raise `'cannot touch on a new record object'` exception on destroying
640
- already destroyed `belongs_to` association with `touch: true` option.
641
-
642
- Fixes #13445.
643
-
644
- Example:
367
+ *Yves Senn*
645
368
 
646
- # Given Comment has belongs_to :post, touch: true
647
- comment.post.destroy
648
- comment.destroy # no longer raises an error
369
+ * `change_column_default :table, :column, nil` with PostgreSQL will issue a
370
+ `DROP DEFAULT` instead of a `DEFAULT NULL` query.
649
371
 
650
- *Paul Nikitochkin*
372
+ Fixes #16261.
651
373
 
652
- * Fix a bug when assigning an array containing string numbers to a
653
- PostgreSQL integer array column.
374
+ *Matthew Draper*, *Yves Senn*
654
375
 
655
- Fixes #13444.
376
+ * Allow to specify a type for the foreign key column in `references`
377
+ and `add_reference`.
656
378
 
657
379
  Example:
658
380
 
659
- # Given Book#ratings is of type :integer, array: true
660
- Book.new(ratings: [1, 2]) # worked before
661
- Book.new(ratings: ['1', '2']) # now works as well
381
+ change_table :vehicle do |t|
382
+ t.references :station, type: :uuid
383
+ end
662
384
 
663
- *Damien Mathieu*
385
+ *Andrey Novikov*, *Łukasz Sarnacki*
664
386
 
665
- * Fix `PostgreSQL` insert to properly extract table name from multiline string SQL.
387
+ * `create_join_table` removes a common prefix when generating the join table.
388
+ This matches the existing behavior of HABTM associations.
666
389
 
667
- Previously, executing an insert SQL in `PostgreSQL` with a command like this:
390
+ Fixes #13683.
668
391
 
669
- insert into articles(
670
- number)
671
- values(
672
- 5152
673
- )
392
+ *Stefan Kanev*
674
393
 
675
- would not work because the adapter was unable to extract the correct `articles`
676
- table name.
394
+ * Do not swallow errors on `compute_type` when having a bad `alias_method` on
395
+ a class.
677
396
 
678
- *Kuldeep Aggarwal*
397
+ *arthurnn*
679
398
 
680
- * Correctly escape PostgreSQL arrays.
399
+ * PostgreSQL invalid `uuid` are convert to nil.
681
400
 
682
- Fixes: CVE-2014-0080
401
+ *Abdelkader Boudih*
683
402
 
684
- * `Relation` no longer has mutator methods like `#map!` and `#delete_if`. Convert
685
- to an `Array` by calling `#to_a` before using these methods.
403
+ * Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
686
404
 
687
- It intends to prevent odd bugs and confusion in code that call mutator
688
- methods directly on the `Relation`.
405
+ With 4.1.x, `serialize` started returning a string when `JSON` was passed as
406
+ the second attribute. It will now return a hash as per previous versions.
689
407
 
690
408
  Example:
691
409
 
692
- # Instead of this
693
- Author.where(name: 'Hank Moody').compact!
694
-
695
- # Now you have to do this
696
- authors = Author.where(name: 'Hank Moody').to_a
697
- authors.compact!
698
-
699
- *Lauro Caetano*
700
-
701
- * Better support for `where()` conditions that use a `belongs_to`
702
- association name.
703
-
704
- Using the name of an association in `where` previously worked only
705
- if the value was a single `ActiveRecord::Base` object. e.g.
706
-
707
- Post.where(author: Author.first)
708
-
709
- Any other values, including `nil`, would cause invalid SQL to be
710
- generated. This change supports arguments in the `where` query
711
- conditions where the key is a `belongs_to` association name and the
712
- value is `nil`, an `Array` of `ActiveRecord::Base` objects, or an
713
- `ActiveRecord::Relation` object.
714
-
715
410
  class Post < ActiveRecord::Base
716
- belongs_to :author
411
+ serialize :comment, JSON
717
412
  end
718
413
 
719
- `nil` value finds records where the association is not set:
720
-
721
- Post.where(author: nil)
722
- # SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IS NULL
723
-
724
- `Array` values find records where the association foreign key
725
- matches the ids of the passed ActiveRecord models, resulting
726
- in the same query as `Post.where(author_id: [1,2])`:
727
-
728
- authors_array = [Author.find(1), Author.find(2)]
729
- Post.where(author: authors_array)
730
- # SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IN (1, 2)
731
-
732
- `ActiveRecord::Relation` values find records using the same
733
- query as `Post.where(author_id: Author.where(last_name: "Emde"))`
734
-
735
- Post.where(author: Author.where(last_name: "Emde"))
736
- # SELECT "posts".* FROM "posts"
737
- # WHERE "posts"."author_id" IN (
738
- # SELECT "authors"."id" FROM "authors"
739
- # WHERE "authors"."last_name" = 'Emde')
740
-
741
- Polymorphic `belongs_to` associations will continue to be handled
742
- appropriately, with the polymorphic `association_type` field added
743
- to the query to match the base class of the value. This feature
744
- previously only worked when the value was a single `ActveRecord::Base`.
745
-
746
- class Post < ActiveRecord::Base
747
- belongs_to :author, polymorphic: true
414
+ class Comment
415
+ include ActiveModel::Model
416
+ attr_accessor :category, :text
748
417
  end
749
418
 
750
- Post.where(author: Author.where(last_name: "Emde"))
751
- # Generates a query similar to:
752
- Post.where(author_id: Author.where(last_name: "Emde"), author_type: "Author")
419
+ post = Post.create!
420
+ post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
421
+ post.save!
753
422
 
754
- *Martin Emde*
423
+ # 4.0
424
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
755
425
 
756
- * Respect temporary option when dropping tables with MySQL.
426
+ # 4.1 before
427
+ post.comment # => "#<Comment:0x007f80ab48ff98>"
757
428
 
758
- Normal DROP TABLE also works, but commits the transaction.
429
+ # 4.1 after
430
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
759
431
 
760
- drop_table :temporary_table, temporary: true
432
+ When using `JSON` as the coder in `serialize`, Active Record will use the
433
+ new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
434
+ `ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
435
+ correctly using the `#as_json` hook.
761
436
 
762
- *Cody Cutrer*
763
-
764
- * Add option to create tables from a query.
437
+ To keep the previous behaviour, supply a custom coder instead
438
+ ([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
765
439
 
766
- create_table(:long_query, temporary: true,
767
- as: "SELECT * FROM orders INNER JOIN line_items ON order_id=orders.id")
440
+ Fixes #15594.
768
441
 
769
- Generates:
442
+ *Jenn Cooper*
770
443
 
771
- CREATE TEMPORARY TABLE long_query AS
772
- SELECT * FROM orders INNER JOIN line_items ON order_id=orders.id
444
+ * Do not use `RENAME INDEX` syntax for MariaDB 10.0.
773
445
 
774
- *Cody Cutrer*
775
-
776
- * `db:test:clone` and `db:test:prepare` must load Rails environment.
777
-
778
- `db:test:clone` and `db:test:prepare` use `ActiveRecord::Base`. configurations,
779
- so we need to load the Rails environment, otherwise the config wont be in place.
780
-
781
- *arthurnn*
782
-
783
- * Use the right column to type cast grouped calculations with custom expressions.
784
-
785
- Fixes #13230.
786
-
787
- Example:
788
-
789
- # Before
790
- Account.group(:firm_name).sum('0.01 * credit_limit')
791
- # => { '37signals' => '0.5' }
792
-
793
- # After
794
- Account.group(:firm_name).sum('0.01 * credit_limit')
795
- # => { '37signals' => 0.5 }
796
-
797
- *Paul Nikitochkin*
446
+ Fixes #15931.
798
447
 
799
- * Polymorphic `belongs_to` associations with the `touch: true` option set update the timestamps of
800
- the old and new owner correctly when moved between owners of different types.
448
+ *Jeff Browning*
801
449
 
802
- Example:
450
+ * Calling `#empty?` on a `has_many` association would use the value from the
451
+ counter cache if one exists.
803
452
 
804
- class Rating < ActiveRecord::Base
805
- belongs_to :rateable, polymorphic: true, touch: true
806
- end
453
+ *David Verhasselt*
807
454
 
808
- rating = Rating.create rateable: Song.find(1)
809
- rating.update_attributes rateable: Book.find(2) # => timestamps of Song(1) and Book(2) are updated
455
+ * Fix the schema dump generated for tables without constraints and with
456
+ primary key with default value of custom PostgreSQL function result.
810
457
 
811
- *Severin Schoepke*
458
+ Fixes #16111.
812
459
 
813
- * Improve formatting of migration exception messages: make them easier to read
814
- with line breaks before/after, and improve the error for pending migrations.
460
+ *Andrey Novikov*
815
461
 
816
- *John Bachir*
462
+ * Fix the SQL generated when a `delete_all` is run on an association to not
463
+ produce an `IN` statements.
817
464
 
818
- * Fix `last` with `offset` to return the proper record instead of always the last one.
465
+ Before:
819
466
 
820
- Example:
467
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
468
+ "categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
821
469
 
822
- Model.offset(4).last
823
- # => returns the 4th record from the end.
470
+ After:
824
471
 
825
- Fixes #7441.
472
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
473
+ "categorizations"."category_id" = 1
826
474
 
827
- *kostya*, *Lauro Caetano*
475
+ *Eileen M. Uchitelle, Aaron Patterson*
828
476
 
829
- * `type_to_sql` returns a `String` for unmapped columns. This fixes an error
830
- when using unmapped PostgreSQL array types.
477
+ * Avoid type casting boolean and `ActiveSupport::Duration` values to numeric
478
+ values for string columns. Otherwise, in some database, the string column
479
+ values will be coerced to a numeric allowing false or 0.seconds match any
480
+ string starting with a non-digit.
831
481
 
832
482
  Example:
833
483
 
834
- change_colum :table, :column, :bigint, array: true
484
+ App.where(apikey: false) # => SELECT * FROM users WHERE apikey = '0'
835
485
 
836
- Fixes #13146.
486
+ *Dylan Thacker-Smith*
837
487
 
838
- *Jens Fahnenbruck*, *Yves Senn*
488
+ * Add a `:required` option to singular associations, providing a nicer
489
+ API for presence validations on associations.
839
490
 
840
- * Fix `QueryCache` to work with nested blocks, so that it will only clear the existing cache
841
- after leaving the outer block instead of clearing it right after the inner block is finished.
491
+ *Sean Griffin*
842
492
 
843
- *Vipul A M*
493
+ * Fix an error in `reset_counters` when associations have `select` scope.
494
+ (Call to `count` generated invalid SQL.)
844
495
 
845
- * The ERB in fixture files is no longer evaluated in the context of the main
846
- object. Helper methods used by multiple fixtures should be defined on the
847
- class object returned by `ActiveRecord::FixtureSet.context_class`.
496
+ *Cade Truitt*
848
497
 
849
- *Victor Costan*
498
+ * After a successful `reload`, `new_record?` is always false.
850
499
 
851
- * Previously, the `has_one` macro incorrectly accepted the `counter_cache`
852
- option, but never actually supported it. Now it will raise an `ArgumentError`
853
- when using `has_one` with `counter_cache`.
500
+ Fixes #12101.
854
501
 
855
- *Godfrey Chan*
856
-
857
- * Implement `rename_index` natively for MySQL >= 5.7.
502
+ *Matthew Draper*
858
503
 
859
- *Cody Cutrer*
504
+ * PostgreSQL renaming table doesn't attempt to rename non existent sequences.
860
505
 
861
- * Fix bug when validating the uniqueness of an aliased attribute.
506
+ *Abdelkader Boudih*
862
507
 
863
- Fixes #12402.
508
+ * Move 'dependent: :destroy' handling for `belongs_to`
509
+ from `before_destroy` to `after_destroy` callback chain
864
510
 
865
- *Lauro Caetano*
511
+ Fixes #12380.
866
512
 
867
- * Update counter cache on a `has_many` relationship regardless of default scope.
513
+ *Ivan Antropov*
868
514
 
869
- Fixes #12952.
515
+ * Detect in-place modifications on String attributes.
870
516
 
871
- *Uku Taht*
517
+ Before this change, an attribute modified in-place had to be marked as
518
+ changed in order for it to be persisted in the database. Now it is no longer
519
+ required.
872
520
 
873
- * `rename_index` adds the new index before removing the old one. This allows to
874
- rename indexes on columns with a foreign key and prevents the following error:
521
+ Before:
875
522
 
876
- Cannot drop index 'index_engines_on_car_id': needed in a foreign key constraint
523
+ user = User.first
524
+ user.name << ' Griffin'
525
+ user.name_will_change!
526
+ user.save
527
+ user.reload.name # => "Sean Griffin"
877
528
 
878
- *Cody Cutrer*, *Yves Senn*
529
+ After:
879
530
 
880
- * Raise `ActiveRecord::RecordNotDestroyed` when a replaced child
881
- marked with `dependent: destroy` fails to be destroyed.
531
+ user = User.first
532
+ user.name << ' Griffin'
533
+ user.save
534
+ user.reload.name # => "Sean Griffin"
882
535
 
883
- Fixes #12812.
536
+ *Sean Griffin*
884
537
 
885
- *Brian Thomas Storti*
538
+ * Add `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the record
539
+ is invalid.
886
540
 
887
- * Fix validation on uniqueness of empty association.
541
+ *Bogdan Gusiev*, *Marc Schütz*
888
542
 
889
- *Evgeny Li*
543
+ * Support for adding and removing foreign keys. Foreign keys are now
544
+ a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter
545
+ and PostgreSQLAdapter.
890
546
 
891
- * Make `ActiveRecord::Relation#unscope` affect relations it is merged in to.
547
+ Many thanks to *Matthew Higgins* for laying the foundation with his work on
548
+ [foreigner](https://github.com/matthuhiggins/foreigner).
892
549
 
893
- *Jon Leighton*
550
+ Example:
894
551
 
895
- * Use strings to represent non-string `order_values`.
552
+ # within your migrations:
553
+ add_foreign_key :articles, :authors
554
+ remove_foreign_key :articles, :authors
896
555
 
897
556
  *Yves Senn*
898
557
 
899
- * Checks to see if the record contains the foreign key to set the inverse automatically.
558
+ * Fix subtle bugs regarding attribute assignment on models with no primary
559
+ key. `'id'` will no longer be part of the attributes hash.
900
560
 
901
- *Edo Balvers*
561
+ *Sean Griffin*
902
562
 
903
- * Added `ActiveRecord::Base.to_param` for convenient "pretty" URLs derived from a model's attribute or method.
563
+ * Deprecate automatic counter caches on `has_many :through`. The behavior was
564
+ broken and inconsistent.
904
565
 
905
- Example:
566
+ *Sean Griffin*
906
567
 
907
- class User < ActiveRecord::Base
908
- to_param :name
909
- end
568
+ * `preload` preserves readonly flag for associations.
910
569
 
911
- user = User.find_by(name: 'Fancy Pants')
912
- user.id # => 123
913
- user.to_param # => "123-fancy-pants"
570
+ See #15853.
914
571
 
915
- *Javan Makhmali*
572
+ *Yves Senn*
916
573
 
917
- * Added `ActiveRecord::Base.no_touching`, which allows ignoring touch on models.
574
+ * Assume numeric types have changed if they were assigned to a value that
575
+ would fail numericality validation, regardless of the old value. Previously
576
+ this would only occur if the old value was 0.
918
577
 
919
578
  Example:
920
579
 
921
- Post.no_touching do
922
- Post.first.touch
923
- end
924
-
925
- *Sam Stephenson*, *Damien Mathieu*
580
+ model = Model.create!(number: 5)
581
+ model.number = '5wibble'
582
+ model.number_changed? # => true
926
583
 
927
- * Prevent the counter cache from being decremented twice when destroying
928
- a record on a `has_many :through` association.
584
+ Fixes #14731.
929
585
 
930
- Fixes #11079.
586
+ *Sean Griffin*
931
587
 
932
- *Dmitry Dedov*
588
+ * `reload` no longer merges with the existing attributes.
589
+ The attribute hash is fully replaced. The record is put into the same state
590
+ as it would be with `Model.find(model.id)`.
933
591
 
934
- * Unify boolean type casting for `MysqlAdapter` and `Mysql2Adapter`.
935
- `type_cast` will return `1` for `true` and `0` for `false`.
592
+ *Sean Griffin*
936
593
 
937
- Fixes #11119.
594
+ * The object returned from `select_all` must respond to `column_types`.
595
+ If this is not the case a `NoMethodError` is raised.
938
596
 
939
- *Adam Williams*, *Yves Senn*
597
+ *Sean Griffin*
940
598
 
941
- * Fix bug where `has_one` association record update result in crash, when replaced with itself.
599
+ * Detect in-place modifications of PG array types
942
600
 
943
- Fixes #12834.
601
+ *Sean Griffin*
944
602
 
945
- *Denis Redozubov*, *Sergio Cambra*
946
-
947
- * Log bind variables after they are type casted. This makes it more
948
- transparent what values are actually sent to the database.
949
-
950
- irb(main):002:0> Event.find("im-no-integer")
951
- # Before: ... WHERE "events"."id" = $1 LIMIT 1 [["id", "im-no-integer"]]
952
- # After: ... WHERE "events"."id" = $1 LIMIT 1 [["id", 0]]
603
+ * Add `bin/rake db:purge` task to empty the current database.
953
604
 
954
605
  *Yves Senn*
955
606
 
956
- * Fix uninitialized constant `TransactionState` error when `Marshall.load` is used on an Active Record result.
957
-
958
- Fixes #12790.
959
-
960
- *Jason Ayre*
961
-
962
- * `.unscope` now removes conditions specified in `default_scope`.
963
-
964
- *Jon Leighton*
607
+ * Deprecate `serialized_attributes` without replacement.
965
608
 
966
- * Added `ActiveRecord::QueryMethods#rewhere` which will overwrite an existing, named where condition.
609
+ *Sean Griffin*
967
610
 
968
- Examples:
611
+ * Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
612
+ are part of the URI structure, not the actual host.
969
613
 
970
- Post.where(trashed: true).where(trashed: false) #=> WHERE `trashed` = 1 AND `trashed` = 0
971
- Post.where(trashed: true).rewhere(trashed: false) #=> WHERE `trashed` = 0
972
- Post.where(active: true).where(trashed: true).rewhere(trashed: false) #=> WHERE `active` = 1 AND `trashed` = 0
614
+ Fixes #15705.
973
615
 
974
- *DHH*
616
+ *Andy Bakun*, *Aaron Stone*
975
617
 
976
- * Extend `ActiveRecord::Base#cache_key` to take an optional list of timestamp attributes of which the highest will be used.
618
+ * Ensure both parent IDs are set on join records when both sides of a
619
+ through association are new.
977
620
 
978
- Example:
979
-
980
- # last_reviewed_at will be used, if that's more recent than updated_at, or vice versa
981
- Person.find(5).cache_key(:updated_at, :last_reviewed_at)
982
-
983
- *DHH*
984
-
985
- * Added `ActiveRecord::Base#enum` for declaring enum attributes where the values map to integers in the database, but can be queried by name.
986
-
987
- Example:
988
-
989
- class Conversation < ActiveRecord::Base
990
- enum status: [:active, :archived]
991
- end
992
-
993
- Conversation::STATUS # => { active: 0, archived: 1 }
994
-
995
- # conversation.update! status: 0
996
- conversation.active!
997
- conversation.active? # => true
998
- conversation.status # => "active"
999
-
1000
- # conversation.update! status: 1
1001
- conversation.archived!
1002
- conversation.archived? # => true
1003
- conversation.status # => "archived"
1004
-
1005
- # conversation.update! status: 1
1006
- conversation.status = :archived
1007
-
1008
- *DHH*
621
+ *Sean Griffin*
1009
622
 
1010
- * `ActiveRecord::Base#attribute_for_inspect` now truncates long arrays (more than 10 elements).
623
+ * `ActiveRecord::Dirty` now detects in-place changes to mutable values.
624
+ Serialized attributes on ActiveRecord models will no longer save when
625
+ unchanged.
1011
626
 
1012
- *Jan Bernacki*
627
+ Fixes #8328.
1013
628
 
1014
- * Allow for the name of the `schema_migrations` table to be configured.
629
+ *Sean Griffin*
1015
630
 
1016
- *Jerad Phelps*
631
+ * `Pluck` now works when selecting columns from different tables with the same
632
+ name.
1017
633
 
1018
- * Do not add to scope includes values from through associations.
1019
- Fixed bug when providing `includes` in through association scope, and fetching targets.
634
+ Fixes #15649.
1020
635
 
1021
- Example:
636
+ *Sean Griffin*
1022
637
 
1023
- class Vendor < ActiveRecord::Base
1024
- has_many :relationships, -> { includes(:user) }
1025
- has_many :users, through: :relationships
1026
- end
638
+ * Remove `cache_attributes` and friends. All attributes are cached.
1027
639
 
1028
- vendor = Vendor.first
640
+ *Sean Griffin*
1029
641
 
1030
- # Before
642
+ * Remove deprecated method `ActiveRecord::Base.quoted_locking_column`.
1031
643
 
1032
- vendor.users.to_a # => Raises exception: not found `:user` for `User`
644
+ *Akshay Vishnoi*
1033
645
 
1034
- # After
646
+ * `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
647
+ `Enumerable#find` does.
1035
648
 
1036
- vendor.users.to_a # => No exception is raised
649
+ Fixes #15382.
1037
650
 
1038
- Fixes #12242, #9517, #10240.
651
+ *James Yang*
1039
652
 
1040
- *Paul Nikitochkin*
653
+ * Make timezone aware attributes work with PostgreSQL array columns.
1041
654
 
1042
- * Type cast json values on write, so that the value is consistent
1043
- with reading from the database.
655
+ Fixes #13402.
1044
656
 
1045
- Example:
657
+ *Kuldeep Aggarwal*, *Sean Griffin*
1046
658
 
1047
- x = JsonDataType.new tags: {"string" => "foo", :symbol => :bar}
659
+ * `ActiveRecord::SchemaMigration` has no primary key regardless of the
660
+ `primary_key_prefix_type` configuration.
1048
661
 
1049
- # Before:
1050
- x.tags # => {"string" => "foo", :symbol => :bar}
1051
-
1052
- # After:
1053
- x.tags # => {"string" => "foo", "symbol" => "bar"}
662
+ Fixes #15051.
1054
663
 
1055
- *Severin Schoepke*
664
+ *JoseLuis Torres*, *Yves Senn*
1056
665
 
1057
- * `ActiveRecord::Store` works together with PostgreSQL `hstore` columns.
666
+ * `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
1058
667
 
1059
- Fixes #12452.
668
+ Fixes #15538.
1060
669
 
1061
670
  *Yves Senn*
1062
671
 
1063
- * Fix bug where `ActiveRecord::Store` used a global `Hash` to keep track of
1064
- all registered `stored_attributes`. Now every subclass of
1065
- `ActiveRecord::Base` has it's own `Hash`.
1066
-
1067
- *Yves Senn*
1068
-
1069
- * Save `has_one` association when primary key is manually set.
1070
-
1071
- Fixes #12302.
1072
-
1073
- *Lauro Caetano*
672
+ * Baseclass becomes! subclass.
1074
673
 
1075
- * Allow any version of BCrypt when using `has_secure_password`.
674
+ Before this change, a record which changed its STI type, could not be
675
+ updated.
1076
676
 
1077
- *Mike Perham*
677
+ Fixes #14785.
1078
678
 
1079
- * Sub-query generated for `Relation` passed as array condition did not take in account
1080
- bind values and have invalid syntax.
679
+ *Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
1081
680
 
1082
- Generate sub-query with inline bind values.
681
+ * Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
682
+ `proper_table_name` instance method on `ActiveRecord::Migration` instead.
1083
683
 
1084
- Fixes #12586.
684
+ *Akshay Vishnoi*
1085
685
 
1086
- *Paul Nikitochkin*
686
+ * Fix regression on eager loading association based on SQL query rather than
687
+ existing column.
1087
688
 
1088
- * Fix a bug where rake db:structure:load crashed when the path contained
1089
- spaces.
689
+ Fixes #15480.
1090
690
 
1091
- *Kevin Mook*
691
+ *Lauro Caetano*, *Carlos Antonio da Silva*
1092
692
 
1093
- * `ActiveRecord::QueryMethods#unscope` unscopes negative equality
693
+ * Deprecate returning `nil` from `column_for_attribute` when no column exists.
694
+ It will return a null object in Rails 5.0
1094
695
 
1095
- Allows you to call `#unscope` on a relation with negative equality
1096
- operators, i.e. `Arel::Nodes::NotIn` and `Arel::Nodes::NotEqual` that have
1097
- been generated through the use of `where.not`.
696
+ *Sean Griffin*
1098
697
 
1099
- *Eric Hankins*
698
+ * Implemented `ActiveRecord::Base#pretty_print` to work with PP.
1100
699
 
1101
- * Raise an exception when model without primary key calls `.find_with_ids`.
700
+ *Ethan*
1102
701
 
1103
- *Shimpei Makimoto*
702
+ * Preserve type when dumping PostgreSQL point, bit, bit varying and money
703
+ columns.
1104
704
 
1105
- * Make `Relation#empty?` use `exists?` instead of `count`.
1106
-
1107
- *Szymon Nowak*
1108
-
1109
- * `rake db:structure:dump` no longer crashes when the port was specified as `Fixnum`.
1110
-
1111
- *Kenta Okamoto*
1112
-
1113
- * `NullRelation#pluck` takes a list of columns
1114
-
1115
- The method signature in `NullRelation` was updated to mimic that in
1116
- `Calculations`.
1117
-
1118
- *Derek Prior*
1119
-
1120
- * `scope_chain` should not be mutated for other reflections.
1121
-
1122
- Currently `scope_chain` uses same array for building different
1123
- `scope_chain` for different associations. During processing
1124
- these arrays are sometimes mutated and because of in-place
1125
- mutation the changed `scope_chain` impacts other reflections.
1126
-
1127
- Fix is to dup the value before adding to the `scope_chain`.
1128
-
1129
- Fixes #3882.
1130
-
1131
- *Neeraj Singh*
1132
-
1133
- * Prevent the inversed association from being reloaded on save.
1134
-
1135
- Fixes #9499.
1136
-
1137
- *Dmitry Polushkin*
1138
-
1139
- * Generate subquery for `Relation` if it passed as array condition for `where`
1140
- method.
1141
-
1142
- Example:
1143
-
1144
- # Before
1145
- Blog.where('id in (?)', Blog.where(id: 1))
1146
- # => SELECT "blogs".* FROM "blogs" WHERE "blogs"."id" = 1
1147
- # => SELECT "blogs".* FROM "blogs" WHERE (id IN (1))
1148
-
1149
- # After
1150
- Blog.where('id in (?)', Blog.where(id: 1).select(:id))
1151
- # => SELECT "blogs".* FROM "blogs"
1152
- # WHERE "blogs"."id" IN (SELECT "blogs"."id" FROM "blogs" WHERE "blogs"."id" = 1)
1153
-
1154
- Fixes #12415.
1155
-
1156
- *Paul Nikitochkin*
1157
-
1158
- * For missed association exception message
1159
- which is raised in `ActiveRecord::Associations::Preloader` class
1160
- added owner record class name in order to simplify to find problem code.
705
+ *Yves Senn*
1161
706
 
1162
- *Paul Nikitochkin*
707
+ * New records remain new after YAML serialization.
1163
708
 
1164
- * `has_and_belongs_to_many` is now transparently implemented in terms of
1165
- `has_many :through`. Behavior should remain the same, if not, it is a bug.
709
+ *Sean Griffin*
1166
710
 
1167
- * `create_savepoint`, `rollback_to_savepoint` and `release_savepoint` accept
1168
- a savepoint name.
711
+ * PostgreSQL support default values for enum types. Fixes #7814.
1169
712
 
1170
713
  *Yves Senn*
1171
714
 
1172
- * Make `next_migration_number` accessible for third party generators.
715
+ * PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
1173
716
 
1174
717
  *Yves Senn*
1175
718
 
1176
- * Objects instantiated using a null relationship will now retain the
1177
- attributes of the where clause.
1178
-
1179
- Fixes #11676, #11675, #11376.
1180
-
1181
- *Paul Nikitochkin*, *Peter Brown*, *Nthalk*
1182
-
1183
- * Fixed `ActiveRecord::Associations::CollectionAssociation#find`
1184
- when using `has_many` association with `:inverse_of` and finding an array of one element,
1185
- it should return an array of one element too.
1186
-
1187
- *arthurnn*
1188
-
1189
- * Callbacks on has_many should access the in memory parent if a inverse_of is set.
1190
-
1191
- *arthurnn*
1192
-
1193
- * `ActiveRecord::ConnectionAdapters.string_to_time` respects
1194
- string with timezone (e.g. Wed, 04 Sep 2013 20:30:00 JST).
1195
-
1196
- Fixes #12278.
1197
-
1198
- *kennyj*
1199
-
1200
- * Calling `update_attributes` will now throw an `ArgumentError` whenever it
1201
- gets a `nil` argument. More specifically, it will throw an error if the
1202
- argument that it gets passed does not respond to to `stringify_keys`.
719
+ * Fix `columns_for_distinct` of PostgreSQL adapter to work correctly
720
+ with orders without sort direction modifiers.
1203
721
 
1204
- Example:
1205
-
1206
- @my_comment.update_attributes(nil) # => raises ArgumentError
722
+ *Nikolay Kondratyev*
1207
723
 
1208
- *John Wang*
724
+ * PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
1209
725
 
1210
- * Deprecate `quoted_locking_column` method, which isn't used anywhere.
726
+ *Yves Senn*
1211
727
 
1212
- *kennyj*
728
+ * Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
729
+ Fixes duplication in combination with `store_accessor`.
1213
730
 
1214
- * Migration dump UUID default functions to schema.rb.
731
+ Fixes #15369.
1215
732
 
1216
- Fixes #10751.
733
+ *Yves Senn*
1217
734
 
1218
- *kennyj*
735
+ * `rake railties:install:migrations` respects the order of railties.
1219
736
 
1220
- * Fixed a bug in `ActiveRecord::Associations::CollectionAssociation#find_by_scan`
1221
- when using `has_many` association with `:inverse_of` option and UUID primary key.
737
+ *Arun Agrawal*
1222
738
 
1223
- Fixes #10450.
739
+ * Fix redefine a `has_and_belongs_to_many` inside inherited class
740
+ Fixing regression case, where redefining the same `has_and_belongs_to_many`
741
+ definition into a subclass would raise.
1224
742
 
1225
- *kennyj*
743
+ Fixes #14983.
1226
744
 
1227
- * Fix: joins association, with defined in the scope block constraints by using several
1228
- where constraints and at least of them is not `Arel::Nodes::Equality`,
1229
- generates invalid SQL expression.
745
+ *arthurnn*
1230
746
 
1231
- Fixes #11963.
747
+ * Fix `has_and_belongs_to_many` public reflection.
748
+ When defining a `has_and_belongs_to_many`, internally we convert that to two has_many.
749
+ But as `reflections` is a public API, people expect to see the right macro.
1232
750
 
1233
- *Paul Nikitochkin*
751
+ Fixes #14682.
1234
752
 
1235
- * `CollectionAssociation#first`/`#last` (e.g. `has_many`) use a `LIMIT`ed
1236
- query to fetch results rather than loading the entire collection.
1237
-
1238
- *Lann Martin*
753
+ *arthurnn*
1239
754
 
1240
- * Make possible to run SQLite rake tasks without the `Rails` constant defined.
755
+ * Fix serialization for records with an attribute named `format`.
1241
756
 
1242
- *Damien Mathieu*
757
+ Fixes #15188.
1243
758
 
1244
- * Allow Relation#from to accept other relations with bind values.
759
+ *Godfrey Chan*
1245
760
 
1246
- *Ryan Wallace*
761
+ * When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
762
+ on a NullRelation should return a Hash.
1247
763
 
1248
- * Fix inserts with prepared statements disabled.
764
+ *Kuldeep Aggarwal*
1249
765
 
1250
- Fixes #12023.
766
+ * Fix serialized fields returning serialized data after being updated with
767
+ `update_column`.
1251
768
 
1252
- *Rafael Mendonça França*
769
+ *Simon Hørup Eskildsen*
1253
770
 
1254
- * Setting a has_one association on a new record no longer causes an empty
1255
- transaction.
771
+ * Fix polymorphic eager loading when using a String as foreign key.
1256
772
 
1257
- *Dylan Thacker-Smith*
773
+ Fixes #14734.
1258
774
 
1259
- * Fix `AR::Relation#merge` sometimes failing to preserve `readonly(false)` flag.
775
+ *Lauro Caetano*
1260
776
 
1261
- *thedarkone*
777
+ * Change belongs_to touch to be consistent with timestamp updates
1262
778
 
1263
- * Re-use `order` argument pre-processing for `reorder`.
779
+ If a model is set up with a belongs_to: touch relationship the parent
780
+ record will only be touched if the record was modified. This makes it
781
+ consistent with timestamp updating on the record itself.
1264
782
 
1265
- *Paul Nikitochkin*
783
+ *Brock Trappitt*
1266
784
 
1267
- * Fix PredicateBuilder so polymorphic association keys in `where` clause can
1268
- accept objects other than direct descendants of `ActiveRecord::Base` (decorated
1269
- models, for example).
785
+ * Fix the inferred table name of a `has_and_belongs_to_many` auxiliary
786
+ table inside a schema.
1270
787
 
1271
- *Mikhail Dieterle*
788
+ Fixes #14824.
1272
789
 
1273
- * PostgreSQL adapter recognizes negative money values formatted with
1274
- parentheses (eg. `($1.25) # => -1.25`)).
1275
- Fixes #11899.
790
+ *Eric Chahin*
1276
791
 
1277
- *Yves Senn*
792
+ * Remove unused `:timestamp` type. Transparently alias it to `:datetime`
793
+ in all cases. Fixes inconsistencies when column types are sent outside of
794
+ `ActiveRecord`, such as for XML Serialization.
1278
795
 
1279
- * Stop interpreting SQL 'string' columns as :string type because there is no
1280
- common STRING datatype in SQL.
796
+ *Sean Griffin*
1281
797
 
1282
- *Ben Woosley*
798
+ * Fix bug that added `table_name_prefix` and `table_name_suffix` to
799
+ extension names in PostgreSQL when migrating.
1283
800
 
1284
- * `ActiveRecord::FinderMethods#exists?` returns `true`/`false` in all cases.
801
+ *Joao Carlos*
1285
802
 
1286
- *Xavier Noria*
803
+ * The `:index` option in migrations, which previously was only available for
804
+ `references`, now works with any column types.
1287
805
 
1288
- * Assign inet/cidr attribute with `nil` value for invalid address.
806
+ *Marc Schütz*
1289
807
 
1290
- Example:
808
+ * Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
1291
809
 
1292
- record = User.new
1293
- record.logged_in_from_ip # is type of an inet or a cidr
810
+ *jnormore*
1294
811
 
1295
- # Before:
1296
- record.logged_in_from_ip = 'bad ip address' # raise exception
812
+ * Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
813
+ or `offset`.
1297
814
 
1298
- # After:
1299
- record.logged_in_from_ip = 'bad ip address' # do not raise exception
1300
- record.logged_in_from_ip # => nil
1301
- record.logged_in_from_ip_before_type_cast # => 'bad ip address'
815
+ In these cases the generated query ignored them and that caused unintended
816
+ records to be deleted.
1302
817
 
1303
- *Paul Nikitochkin*
818
+ Fixes #11985.
1304
819
 
1305
- * `add_to_target` now accepts a second optional `skip_callbacks` argument
820
+ *Leandro Facchinetti*
1306
821
 
1307
- If truthy, it will skip the :before_add and :after_add callbacks.
822
+ * Floats with limit >= 25 that get turned into doubles in MySQL no longer have
823
+ their limit dropped from the schema.
1308
824
 
1309
- *Ben Woosley*
825
+ Fixes #14135.
1310
826
 
1311
- * Fix interactions between `:before_add` callbacks and nested attributes
1312
- assignment of `has_many` associations, when the association was not
1313
- yet loaded:
827
+ *Aaron Nelson*
1314
828
 
1315
- - A `:before_add` callback was being called when a nested attributes
1316
- assignment assigned to an existing record.
829
+ * Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many`
830
+ association.
1317
831
 
1318
- - Nested Attributes assignment did not affect the record in the
1319
- association target when a `:before_add` callback triggered the
1320
- loading of the association
832
+ Fixes #14709.
1321
833
 
1322
- *Jörg Schray*
834
+ *Kassio Borges*
1323
835
 
1324
- * Allow enable_extension migration method to be revertible.
836
+ * `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
837
+ strings in column names as equal.
1325
838
 
1326
- *Eric Tipton*
839
+ This fixes a rare case in which more bind values are passed than there are
840
+ placeholders for them in the generated SQL statement, which can make PostgreSQL
841
+ throw a `StatementInvalid` exception.
1327
842
 
1328
- * Type cast hstore values on write, so that the value is consistent
1329
- with reading from the database.
843
+ *Nat Budin*
1330
844
 
1331
- Example:
845
+ * Fix `stored_attributes` to correctly merge the details of stored
846
+ attributes defined in parent classes.
1332
847
 
1333
- x = Hstore.new tags: {"bool" => true, "number" => 5}
848
+ Fixes #14672.
1334
849
 
1335
- # Before:
1336
- x.tags # => {"bool" => true, "number" => 5}
850
+ *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
1337
851
 
1338
- # After:
1339
- x.tags # => {"bool" => "true", "number" => "5"}
1340
-
1341
- *Yves Senn* , *Severin Schoepke*
852
+ * `change_column_default` allows `[]` as argument to `change_column_default`.
1342
853
 
1343
- * Fix multidimensional PostgreSQL arrays containing non-string items.
854
+ Fixes #11586.
1344
855
 
1345
856
  *Yves Senn*
1346
857
 
1347
- * Fixes bug when using includes combined with select, the select statement was overwritten.
1348
-
1349
- Fixes #11773.
1350
-
1351
- *Edo Balvers*
1352
-
1353
- * Load fixtures from linked folders.
1354
-
1355
- *Kassio Borges*
1356
-
1357
- * Create a directory for sqlite3 file if not present on the system.
1358
-
1359
- *Richard Schneeman*
858
+ * Handle `name` and `"char"` column types in the PostgreSQL adapter.
1360
859
 
1361
- * Removed redundant override of `xml` column definition for PostgreSQL,
1362
- in order to use `xml` column type instead of `text`.
860
+ `name` and `"char"` are special character types used internally by
861
+ PostgreSQL and are used by internal system catalogs. These field types
862
+ can sometimes show up in structure-sniffing queries that feature internal system
863
+ structures or with certain PostgreSQL extensions.
1363
864
 
1364
- *Paul Nikitochkin*, *Michael Nikitochkin*
865
+ *J Smith*, *Yves Senn*
1365
866
 
1366
- * Revert `ActiveRecord::Relation#order` change that make new order
1367
- prepend the old one.
867
+ * Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
868
+ NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
1368
869
 
1369
870
  Before:
1370
871
 
1371
- User.order("name asc").order("created_at desc")
1372
- # SELECT * FROM users ORDER BY created_at desc, name asc
872
+ Point.create(value: 1.0/0)
873
+ Point.last.value # => 0.0
1373
874
 
1374
875
  After:
1375
876
 
1376
- User.order("name asc").order("created_at desc")
1377
- # SELECT * FROM users ORDER BY name asc, created_at desc
877
+ Point.create(value: 1.0/0)
878
+ Point.last.value # => Infinity
1378
879
 
1379
- This also affects order defined in `default_scope` or any kind of associations.
880
+ *Innokenty Mikhailov*
1380
881
 
1381
- * Add ability to define how a class is converted to Arel predicates.
1382
- For example, adding a very vendor specific regex implementation:
882
+ * Allow the PostgreSQL adapter to handle bigserial primary key types again.
1383
883
 
1384
- regex_handler = proc do |column, value|
1385
- Arel::Nodes::InfixOperation.new('~', column, value.source)
1386
- end
1387
- ActiveRecord::PredicateBuilder.register_handler(Regexp, regex_handler)
884
+ Fixes #10410.
1388
885
 
1389
- *Sean Griffin & @joannecheng*
886
+ *Patrick Robertson*
1390
887
 
1391
- * Don't allow `quote_value` to be called without a column.
888
+ * Deprecate joining, eager loading and preloading of instance dependent
889
+ associations without replacement. These operations happen before instances
890
+ are created. The current behavior is unexpected and can result in broken
891
+ behavior.
1392
892
 
1393
- Some adapters require column information to do their job properly.
1394
- By enforcing the provision of the column for this internal method
1395
- we ensure that those using adapters that require column information
1396
- will always get the proper behavior.
893
+ Fixes #15024.
1397
894
 
1398
- *Ben Woosley*
895
+ *Yves Senn*
1399
896
 
1400
- * When using optimistic locking, `update` was not passing the column to `quote_value`
1401
- to allow the connection adapter to properly determine how to quote the value. This was
1402
- affecting certain databases that use specific column types.
897
+ * Fix `has_and_belongs_to_many` CollectionAssociation size calculations.
1403
898
 
1404
- Fixes #6763.
899
+ `has_and_belongs_to_many` should fall back to using the normal CollectionAssociation's
900
+ size calculation if the collection is not cached or loaded.
1405
901
 
1406
- *Alfred Wong*
902
+ Fixes #14913, #14914.
1407
903
 
1408
- * rescue from all exceptions in `ConnectionManagement#call`
904
+ *Fred Wu*
1409
905
 
1410
- Fixes #11497.
906
+ * Return a non zero status when running `rake db:migrate:status` and migration table does
907
+ not exist.
1411
908
 
1412
- As `ActiveRecord::ConnectionAdapters::ConnectionManagement` middleware does
1413
- not rescue from Exception (but only from StandardError), the Connection
1414
- Pool quickly runs out of connections when multiple erroneous Requests come
1415
- in right after each other.
909
+ *Paul B.*
1416
910
 
1417
- Rescuing from all exceptions and not just StandardError, fixes this
1418
- behaviour.
911
+ * Add support for module-level `table_name_suffix` in models.
1419
912
 
1420
- *Vipul A M*
913
+ This makes `table_name_suffix` work the same way as `table_name_prefix` when
914
+ using namespaced models.
1421
915
 
1422
- * `change_column` for PostgreSQL adapter respects the `:array` option.
916
+ *Jenner LaFave*
1423
917
 
1424
- *Yves Senn*
918
+ * Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
1425
919
 
1426
- * Remove deprecation warning from `attribute_missing` for attributes that are columns.
920
+ In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
921
+ In 4.0 series it is delegated to `Array#join`.
1427
922
 
1428
- *Arun Agrawal*
923
+ *Bogdan Gusiev*
1429
924
 
1430
- * Remove extra decrement of transaction deep level.
925
+ * Log nil binary column values correctly.
1431
926
 
1432
- Fixes #4566.
927
+ When an object with a binary column is updated with a nil value
928
+ in that column, the SQL logger would throw an exception when trying
929
+ to log that nil value. This only occurs when updating a record
930
+ that already has a non-nil value in that column since an initial nil
931
+ value isn't included in the SQL anyway (at least, when dirty checking
932
+ is enabled.) The column's new value will now be logged as `<NULL binary data>`
933
+ to parallel the existing `<N bytes of binary data>` for non-nil values.
1433
934
 
1434
- *Paul Nikitochkin*
935
+ *James Coleman*
1435
936
 
1436
- * Reset @column_defaults when assigning `locking_column`.
1437
- We had a potential problem. For example:
937
+ * Rails will now pass a custom validation context through to autosave associations
938
+ in order to validate child associations with the same context.
1438
939
 
1439
- class Post < ActiveRecord::Base
1440
- self.column_defaults # if we call this unintentionally before setting locking_column ...
1441
- self.locking_column = 'my_locking_column'
1442
- end
940
+ Fixes #13854.
1443
941
 
1444
- Post.column_defaults["my_locking_column"]
1445
- => nil # expected value is 0 !
942
+ *Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
1446
943
 
1447
- *kennyj*
944
+ * Stringify all variables keys of MySQL connection configuration.
1448
945
 
1449
- * Remove extra select and update queries on save/touch/destroy ActiveRecord model
1450
- with belongs to reflection with option `touch: true`.
946
+ When `sql_mode` variable for MySQL adapters set in configuration as `String`
947
+ was ignored and overwritten by strict mode option.
1451
948
 
1452
- Fixes #11288.
949
+ Fixes #14895.
1453
950
 
1454
951
  *Paul Nikitochkin*
1455
952
 
1456
- * Remove deprecated nil-passing to the following `SchemaCache` methods:
1457
- `primary_keys`, `tables`, `columns` and `columns_hash`.
953
+ * Ensure SQLite3 statements are closed on errors.
1458
954
 
1459
- *Yves Senn*
955
+ Fixes #13631.
1460
956
 
1461
- * Remove deprecated block filter from `ActiveRecord::Migrator#migrate`.
957
+ *Timur Alperovich*
1462
958
 
1463
- *Yves Senn*
959
+ * Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve.
1464
960
 
1465
- * Remove deprecated String constructor from `ActiveRecord::Migrator`.
961
+ *Hector Satre*
1466
962
 
1467
- *Yves Senn*
963
+ * When using a custom `join_table` name on a `habtm`, rails was not saving it
964
+ on Reflections. This causes a problem when rails loads fixtures, because it
965
+ uses the reflections to set database with fixtures.
1468
966
 
1469
- * Remove deprecated `scope` use without passing a callable object.
967
+ Fixes #14845.
1470
968
 
1471
- *Arun Agrawal*
969
+ *Kassio Borges*
1472
970
 
1473
- * Remove deprecated `transaction_joinable=` in favor of `begin_transaction`
1474
- with `:joinable` option.
971
+ * Reset the cache when modifying a Relation with cached Arel.
972
+ Additionally display a warning message to make the user aware.
1475
973
 
1476
- *Arun Agrawal*
974
+ *Yves Senn*
1477
975
 
1478
- * Remove deprecated `decrement_open_transactions`.
976
+ * PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
977
+ different spellings of timestamps are treated the same.
1479
978
 
1480
- *Arun Agrawal*
979
+ Example:
1481
980
 
1482
- * Remove deprecated `increment_open_transactions`.
981
+ mytimestamp.simplified_type('timestamp without time zone')
982
+ # => :datetime
983
+ mytimestamp.simplified_type('timestamp(6) without time zone')
984
+ # => also :datetime (previously would be :timestamp)
1483
985
 
1484
- *Arun Agrawal*
986
+ See #14513.
1485
987
 
1486
- * Remove deprecated `PostgreSQLAdapter#outside_transaction?`
1487
- method. You can use `#transaction_open?` instead.
988
+ *Jefferson Lai*
1488
989
 
1489
- *Yves Senn*
990
+ * `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
1490
991
 
1491
- * Remove deprecated `ActiveRecord::Fixtures.find_table_name` in favor of
1492
- `ActiveRecord::Fixtures.default_fixture_model_name`.
992
+ Fixes #14841.
1493
993
 
1494
- *Vipul A M*
994
+ *Lucas Mazza*
1495
995
 
1496
- * Removed deprecated `columns_for_remove` from `SchemaStatements`.
996
+ * Fix name collision with `Array#select!` with `Relation#select!`.
1497
997
 
1498
- *Neeraj Singh*
998
+ Fixes #14752.
1499
999
 
1500
- * Remove deprecated `SchemaStatements#distinct`.
1000
+ *Earl St Sauver*
1501
1001
 
1502
- *Francesco Rodriguez*
1002
+ * Fix unexpected behavior for `has_many :through` associations going through
1003
+ a scoped `has_many`.
1503
1004
 
1504
- * Move deprecated `ActiveRecord::TestCase` into the rails test
1505
- suite. The class is no longer public and is only used for internal
1506
- Rails tests.
1005
+ If a `has_many` association is adjusted using a scope, and another
1006
+ `has_many :through` uses this association, then the scope adjustment is
1007
+ unexpectedly neglected.
1507
1008
 
1508
- *Yves Senn*
1009
+ Fixes #14537.
1509
1010
 
1510
- * Removed support for deprecated option `:restrict` for `:dependent`
1511
- in associations.
1011
+ *Jan Habermann*
1512
1012
 
1513
- *Neeraj Singh*
1013
+ * `@destroyed` should always be set to `false` when an object is duped.
1514
1014
 
1515
- * Removed support for deprecated `delete_sql` in associations.
1015
+ *Kuldeep Aggarwal*
1516
1016
 
1517
- *Neeraj Singh*
1017
+ * Enable `has_many` associations to support irregular inflections.
1518
1018
 
1519
- * Removed support for deprecated `insert_sql` in associations.
1019
+ Fixes #8928.
1520
1020
 
1521
- *Neeraj Singh*
1021
+ *arthurnn*, *Javier Goizueta*
1522
1022
 
1523
- * Removed support for deprecated `finder_sql` in associations.
1023
+ * Fix `count` used with a grouping not returning a Hash.
1524
1024
 
1525
- *Neeraj Singh*
1025
+ Fixes #14721.
1526
1026
 
1527
- * Support array as root element in JSON fields.
1027
+ *Eric Chahin*
1528
1028
 
1529
- *Alexey Noskov & Francesco Rodriguez*
1029
+ * `sanitize_sql_like` helper method to escape a string for safe use in an SQL
1030
+ LIKE statement.
1530
1031
 
1531
- * Removed support for deprecated `counter_sql` in associations.
1032
+ Example:
1532
1033
 
1533
- *Neeraj Singh*
1034
+ class Article
1035
+ def self.search(term)
1036
+ where("title LIKE ?", sanitize_sql_like(term))
1037
+ end
1038
+ end
1534
1039
 
1535
- * Do not invoke callbacks when `delete_all` is called on collection.
1040
+ Article.search("20% _reduction_")
1041
+ # => Query looks like "... title LIKE '20\% \_reduction\_' ..."
1536
1042
 
1537
- Method `delete_all` should not be invoking callbacks and this
1538
- feature was deprecated in Rails 4.0. This is being removed.
1539
- `delete_all` will continue to honor the `:dependent` option. However
1540
- if `:dependent` value is `:destroy` then the `:delete_all` deletion
1541
- strategy for that collection will be applied.
1043
+ *Rob Gilson*, *Yves Senn*
1542
1044
 
1543
- User can also force a deletion strategy by passing parameter to
1544
- `delete_all`. For example you can do `@post.comments.delete_all(:nullify)`.
1045
+ * Do not quote uuid default value on `change_column`.
1545
1046
 
1546
- *Neeraj Singh*
1047
+ Fixes #14604.
1547
1048
 
1548
- * Calling default_scope without a proc will now raise `ArgumentError`.
1049
+ *Eric Chahin*
1549
1050
 
1550
- *Neeraj Singh*
1051
+ * The comparison between `Relation` and `CollectionProxy` should be consistent.
1551
1052
 
1552
- * Removed deprecated method `type_cast_code` from Column.
1053
+ Example:
1553
1054
 
1554
- *Neeraj Singh*
1055
+ author.posts == Post.where(author_id: author.id)
1056
+ # => true
1057
+ Post.where(author_id: author.id) == author.posts
1058
+ # => true
1555
1059
 
1556
- * Removed deprecated options `delete_sql` and `insert_sql` from HABTM
1557
- association.
1060
+ Fixes #13506.
1558
1061
 
1559
- Removed deprecated options `finder_sql` and `counter_sql` from
1560
- collection association.
1062
+ *Lauro Caetano*
1561
1063
 
1562
- *Neeraj Singh*
1064
+ * Calling `delete_all` on an unloaded `CollectionProxy` no longer
1065
+ generates an SQL statement containing each id of the collection:
1563
1066
 
1564
- * Remove deprecated `ActiveRecord::Base#connection` method.
1565
- Make sure to access it via the class.
1067
+ Before:
1566
1068
 
1567
- *Yves Senn*
1069
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
1070
+ AND `model`.`id` IN (1, 2, 3...)
1568
1071
 
1569
- * Remove deprecation warning for `auto_explain_threshold_in_seconds`.
1072
+ After:
1570
1073
 
1571
- *Yves Senn*
1074
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
1572
1075
 
1573
- * Remove deprecated `:distinct` option from `Relation#count`.
1076
+ *Eileen M. Uchitelle*, *Aaron Patterson*
1574
1077
 
1575
- *Yves Senn*
1078
+ * Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
1079
+ with `select`.
1576
1080
 
1577
- * Removed deprecated methods `partial_updates`, `partial_updates?` and
1578
- `partial_updates=`.
1081
+ Fixes #13648.
1579
1082
 
1580
- *Neeraj Singh*
1083
+ *Simon Woker*
1581
1084
 
1582
- * Removed deprecated method `scoped`.
1085
+ * PostgreSQL adapter only warns once for every missing OID per connection.
1583
1086
 
1584
- *Neeraj Singh*
1087
+ Fixes #14275.
1585
1088
 
1586
- * Removed deprecated method `default_scopes?`.
1089
+ *Matthew Draper*, *Yves Senn*
1587
1090
 
1588
- *Neeraj Singh*
1091
+ * PostgreSQL adapter automatically reloads it's type map when encountering
1092
+ unknown OIDs.
1589
1093
 
1590
- * Remove implicit join references that were deprecated in 4.0.
1094
+ Fixes #14678.
1591
1095
 
1592
- Example:
1096
+ *Matthew Draper*, *Yves Senn*
1593
1097
 
1594
- # before with implicit joins
1595
- Comment.where('posts.author_id' => 7)
1098
+ * Fix insertion of records via `has_many :through` association with scope.
1596
1099
 
1597
- # after
1598
- Comment.references(:posts).where('posts.author_id' => 7)
1100
+ Fixes #3548.
1599
1101
 
1600
- *Yves Senn*
1102
+ *Ivan Antropov*
1601
1103
 
1602
- * Apply default scope when joining associations. For example:
1104
+ * Auto-generate stable fixture UUIDs on PostgreSQL.
1603
1105
 
1604
- class Post < ActiveRecord::Base
1605
- default_scope -> { where published: true }
1606
- end
1106
+ Fixes #11524.
1607
1107
 
1608
- class Comment
1609
- belongs_to :post
1610
- end
1108
+ *Roderick van Domburg*
1611
1109
 
1612
- When calling `Comment.joins(:post)`, we expect to receive only
1613
- comments on published posts, since that is the default scope for
1614
- posts.
1110
+ * Fix a problem where an enum would overwrite values of another enum with the
1111
+ same name in an unrelated class.
1615
1112
 
1616
- Before this change, the default scope from `Post` was not applied,
1617
- so we'd get comments on unpublished posts.
1113
+ Fixes #14607.
1618
1114
 
1619
- *Jon Leighton*
1115
+ *Evan Whalen*
1620
1116
 
1621
- * Remove `activerecord-deprecated_finders` as a dependency.
1117
+ * PostgreSQL and SQLite string columns no longer have a default limit of 255.
1622
1118
 
1623
- *Łukasz Strzałkowski*
1119
+ Fixes #13435, #9153.
1624
1120
 
1625
- * Remove Oracle / Sqlserver / Firebird database tasks that were deprecated in 4.0.
1121
+ *Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
1626
1122
 
1627
- *kennyj*
1123
+ * Make possible to have an association called `records`.
1628
1124
 
1629
- * `find_each` now returns an `Enumerator` when called without a block, so that it
1630
- can be chained with other `Enumerable` methods.
1125
+ Fixes #11645.
1631
1126
 
1632
- *Ben Woosley*
1127
+ *prathamesh-sonpatki*
1633
1128
 
1634
- * `ActiveRecord::Result.each` now returns an `Enumerator` when called without
1635
- a block, so that it can be chained with other `Enumerable` methods.
1129
+ * `to_sql` on an association now matches the query that is actually executed, where it
1130
+ could previously have incorrectly accrued additional conditions (e.g. as a result of
1131
+ a previous query). `CollectionProxy` now always defers to the association scope's
1132
+ `arel` method so the (incorrect) inherited one should be entirely concealed.
1636
1133
 
1637
- *Ben Woosley*
1134
+ Fixes #14003.
1638
1135
 
1639
- * Flatten merged join_values before building the joins.
1136
+ *Jefferson Lai*
1640
1137
 
1641
- While joining_values special treatment is given to string values.
1642
- By flattening the array it ensures that string values are detected
1643
- as strings and not arrays.
1138
+ * Block a few default Class methods as scope name.
1644
1139
 
1645
- Fixes #10669.
1140
+ For instance, this will raise:
1646
1141
 
1647
- *Neeraj Singh and iwiznia*
1142
+ scope :public, -> { where(status: 1) }
1143
+
1144
+ *arthurnn*
1648
1145
 
1649
- * Do not load all child records for inverse case.
1146
+ * Fix error when using `with_options` with lambda.
1650
1147
 
1651
- currently `post.comments.find(Comment.first.id)` would load all
1652
- comments for the given post to set the inverse association.
1148
+ Fixes #9805.
1653
1149
 
1654
- This has a huge performance penalty. Because if post has 100k
1655
- records and all these 100k records would be loaded in memory
1656
- even though the comment id was supplied.
1150
+ *Lauro Caetano*
1657
1151
 
1658
- Fix is to use in-memory records only if loaded? is true. Otherwise
1659
- load the records using full sql.
1152
+ * Switch `sqlite3:///` URLs (which were temporarily
1153
+ deprecated in 4.1) from relative to absolute.
1660
1154
 
1661
- Fixes #10509.
1155
+ If you still want the previous interpretation, you should replace
1156
+ `sqlite3:///my/path` with `sqlite3:my/path`.
1662
1157
 
1663
- *Neeraj Singh*
1158
+ *Matthew Draper*
1664
1159
 
1665
- * `inspect` on Active Record model classes does not initiate a
1666
- new connection. This means that calling `inspect`, when the
1667
- database is missing, will no longer raise an exception.
1668
- Fixes #10936.
1160
+ * Treat blank UUID values as `nil`.
1669
1161
 
1670
1162
  Example:
1671
1163
 
1672
- Author.inspect # => "Author(no database connection)"
1673
-
1674
- *Yves Senn*
1164
+ Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
1675
1165
 
1676
- * Handle single quotes in PostgreSQL default column values.
1677
- Fixes #10881.
1166
+ *Dmitry Lavrov*
1678
1167
 
1679
- *Dylan Markow*
1168
+ * Enable support for materialized views on PostgreSQL >= 9.3.
1680
1169
 
1681
- * Log the sql that is actually sent to the database.
1170
+ *Dave Lee*
1682
1171
 
1683
- If I have a query that produces sql
1684
- `WHERE "users"."name" = 'a b'` then in the log all the
1685
- whitespace is being squeezed. So the sql that is printed in the
1686
- log is `WHERE "users"."name" = 'a b'`.
1172
+ * The PostgreSQL adapter supports custom domains. Fixes #14305.
1687
1173
 
1688
- Do not squeeze whitespace out of sql queries. Fixes #10982.
1174
+ *Yves Senn*
1689
1175
 
1690
- *Neeraj Singh*
1176
+ * PostgreSQL `Column#type` is now determined through the corresponding OID.
1177
+ The column types stay the same except for enum columns. They no longer have
1178
+ `nil` as type but `enum`.
1691
1179
 
1692
- * Fixture setup no longer depends on `ActiveRecord::Base.configurations`.
1693
- This is relevant when `ENV["DATABASE_URL"]` is used in place of a `database.yml`.
1180
+ See #7814.
1694
1181
 
1695
1182
  *Yves Senn*
1696
1183
 
1697
- * Fix mysql2 adapter raises the correct exception when executing a query on a
1698
- closed connection.
1184
+ * Fix error when specifying a non-empty default value on a PostgreSQL array
1185
+ column.
1699
1186
 
1700
- *Yves Senn*
1187
+ Fixes #10613.
1701
1188
 
1702
- * Ambiguous reflections are on :through relationships are no longer supported.
1703
- For example, you need to change this:
1189
+ *Luke Steensen*
1704
1190
 
1705
- class Author < ActiveRecord::Base
1706
- has_many :posts
1707
- has_many :taggings, through: :posts
1708
- end
1191
+ * Fix error where `.persisted?` throws SystemStackError for an unsaved model with a
1192
+ custom primary key that did not save due to validation error.
1709
1193
 
1710
- class Post < ActiveRecord::Base
1711
- has_one :tagging
1712
- has_many :taggings
1713
- end
1194
+ Fixes #14393.
1714
1195
 
1715
- class Tagging < ActiveRecord::Base
1716
- end
1196
+ *Chris Finne*
1717
1197
 
1718
- To this:
1198
+ * Introduce `validate` as an alias for `valid?`.
1719
1199
 
1720
- class Author < ActiveRecord::Base
1721
- has_many :posts
1722
- has_many :taggings, through: :posts, source: :tagging
1723
- end
1200
+ This is more intuitive when you want to run validations but don't care about the return value.
1724
1201
 
1725
- class Post < ActiveRecord::Base
1726
- has_one :tagging
1727
- has_many :taggings
1728
- end
1202
+ *Henrik Nyh*
1729
1203
 
1730
- class Tagging < ActiveRecord::Base
1731
- end
1204
+ * Create indexes inline in CREATE TABLE for MySQL.
1732
1205
 
1733
- *Aaron Patterson*
1206
+ This is important, because adding an index on a temporary table after it has been created
1207
+ would commit the transaction.
1734
1208
 
1735
- * Remove column restrictions for `count`, let the database raise if the SQL is
1736
- invalid. The previous behavior was untested and surprising for the user.
1737
- Fixes #5554.
1209
+ It also allows creating and dropping indexed tables with fewer queries and fewer permissions
1210
+ required.
1738
1211
 
1739
1212
  Example:
1740
1213
 
1741
- User.select("name, username").count
1742
- # Before => SELECT count(*) FROM users
1743
- # After => ActiveRecord::StatementInvalid
1744
-
1745
- # you can still use `count(:all)` to perform a query unrelated to the
1746
- # selected columns
1747
- User.select("name, username").count(:all) # => SELECT count(*) FROM users
1748
-
1749
- *Yves Senn*
1750
-
1751
- * Rails now automatically detects inverse associations. If you do not set the
1752
- `:inverse_of` option on the association, then Active Record will guess the
1753
- inverse association based on heuristics.
1754
-
1755
- Note that automatic inverse detection only works on `has_many`, `has_one`,
1756
- and `belongs_to` associations. Extra options on the associations will
1757
- also prevent the association's inverse from being found automatically.
1758
-
1759
- The automatic guessing of the inverse association uses a heuristic based
1760
- on the name of the class, so it may not work for all associations,
1761
- especially the ones with non-standard names.
1762
-
1763
- You can turn off the automatic detection of inverse associations by setting
1764
- the `:inverse_of` option to `false` like so:
1765
-
1766
- class Taggable < ActiveRecord::Base
1767
- belongs_to :tag, inverse_of: false
1214
+ create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t|
1215
+ t.index :zip
1768
1216
  end
1217
+ # => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
1218
+
1219
+ *Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
1769
1220
 
1770
- *John Wang*
1221
+ * Use singular table name in generated migrations when
1222
+ `ActiveRecord::Base.pluralize_table_names` is `false`.
1771
1223
 
1772
- * Fix `add_column` with `array` option when using PostgreSQL. Fixes #10432.
1224
+ Fixes #13426.
1773
1225
 
1774
- *Adam Anderson*
1226
+ *Kuldeep Aggarwal*
1775
1227
 
1776
- * Usage of `implicit_readonly` is being removed`. Please use `readonly` method
1777
- explicitly to mark records as `readonly.
1778
- Fixes #10615.
1228
+ * `touch` accepts many attributes to be touched at once.
1779
1229
 
1780
1230
  Example:
1781
1231
 
1782
- user = User.joins(:todos).select("users.*, todos.title as todos_title").readonly(true).first
1783
- user.todos_title = 'clean pet'
1784
- user.save! # will raise error
1232
+ # touches :signed_at, :sealed_at, and :updated_at/on attributes.
1233
+ Photo.last.touch(:signed_at, :sealed_at)
1785
1234
 
1786
- *Yves Senn*
1235
+ *James Pinto*
1787
1236
 
1788
- * Fix the `:primary_key` option for `has_many` associations.
1237
+ * `rake db:structure:dump` only dumps schema information if the schema
1238
+ migration table exists.
1789
1239
 
1790
- Fixes #10693.
1240
+ Fixes #14217.
1791
1241
 
1792
1242
  *Yves Senn*
1793
1243
 
1794
- * Fix bug where tiny types are incorrectly coerced as boolean when the length is more than 1.
1795
-
1796
- Fixes #10620.
1244
+ * Reap connections that were checked out by now-dead threads, instead
1245
+ of waiting until they disconnect by themselves. Before this change,
1246
+ a suitably constructed series of short-lived threads could starve
1247
+ the connection pool, without ever having more than a couple alive at
1248
+ the same time.
1797
1249
 
1798
- *Aaron Patterson*
1250
+ *Matthew Draper*
1799
1251
 
1800
- * Also support extensions in PostgreSQL 9.1. This feature has been supported since 9.1.
1252
+ * `pk_and_sequence_for` now ensures that only the pg_depend entries
1253
+ pointing to pg_class, and thus only sequence objects, are considered.
1801
1254
 
1802
- *kennyj*
1255
+ *Josh Williams*
1803
1256
 
1804
- * Deprecate `ConnectionAdapters::SchemaStatements#distinct`,
1805
- as it is no longer used by internals.
1257
+ * `where.not` adds `references` for `includes` like normal `where` calls do.
1806
1258
 
1807
- *Ben Woosley*
1259
+ Fixes #14406.
1808
1260
 
1809
- * Fix pending migrations error when loading schema and `ActiveRecord::Base.table_name_prefix`
1810
- is not blank.
1261
+ *Yves Senn*
1811
1262
 
1812
- Call `assume_migrated_upto_version` on connection to prevent it from first
1813
- being picked up in `method_missing`.
1263
+ * Extend fixture `$LABEL` replacement to allow string interpolation.
1814
1264
 
1815
- In the base class, `Migration`, `method_missing` expects the argument to be a
1816
- table name, and calls `proper_table_name` on the arguments before sending to
1817
- `connection`. If `table_name_prefix` or `table_name_suffix` is used, the schema
1818
- version changes to `prefix_version_suffix`, breaking `rake test:prepare`.
1265
+ Example:
1819
1266
 
1820
- Fixes #10411.
1267
+ martin:
1268
+ email: $LABEL@email.com
1821
1269
 
1822
- *Kyle Stevens*
1270
+ users(:martin).email # => martin@email.com
1823
1271
 
1824
- * Method `read_attribute_before_type_cast` should accept input as symbol.
1272
+ *Eric Steele*
1825
1273
 
1826
- *Neeraj Singh*
1274
+ * Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
1827
1275
 
1828
- * Confirm a record has not already been destroyed before decrementing counter cache.
1276
+ Fixes #14361.
1829
1277
 
1830
- *Ben Tucker*
1278
+ *arthurnn*
1831
1279
 
1832
- * Fixed a bug in `ActiveRecord#sanitize_sql_hash_for_conditions` in which
1833
- `self.class` is an argument to `PredicateBuilder#build_from_hash`
1834
- causing `PredicateBuilder` to call non-existent method
1835
- `Class#reflect_on_association`.
1280
+ * Passing an Active Record object to `find` or `exists?` is now deprecated.
1281
+ Call `.id` on the object first.
1836
1282
 
1837
- *Zach Ohlgren*
1283
+ *Aaron Patterson*
1838
1284
 
1839
- * While removing index if column option is missing then raise IrreversibleMigration exception.
1285
+ * Only use BINARY for MySQL case sensitive uniqueness check when column
1286
+ has a case insensitive collation.
1840
1287
 
1841
- Following code should raise `IrreversibleMigration`. But the code was
1842
- failing since options is an array and not a hash.
1288
+ *Ryuta Kamizono*
1843
1289
 
1844
- def change
1845
- change_table :users do |t|
1846
- t.remove_index [:name, :email]
1847
- end
1848
- end
1290
+ * Support for MySQL 5.6 fractional seconds.
1849
1291
 
1850
- Fix was to check if the options is a Hash before operating on it.
1292
+ *arthurnn*, *Tatsuhiko Miyagawa*
1851
1293
 
1852
- Fixes #10419.
1294
+ * Support for PostgreSQL `citext` data type enabling case-insensitive
1295
+ `where` values without needing to wrap in UPPER/LOWER sql functions.
1853
1296
 
1854
- *Neeraj Singh*
1297
+ *Troy Kruthoff*, *Lachlan Sylvester*
1855
1298
 
1856
- * Do not overwrite manually built records during one-to-one nested attribute assignment
1299
+ * Only save has_one associations if record has changes.
1300
+ Previously after save related callbacks, such as `#after_commit`, were triggered when the has_one
1301
+ object did not get saved to the db.
1857
1302
 
1858
- For one-to-one nested associations, if you build the new (in-memory)
1859
- child object yourself before assignment, then the NestedAttributes
1860
- module will not overwrite it, e.g.:
1303
+ *Alan Kennedy*
1861
1304
 
1862
- class Member < ActiveRecord::Base
1863
- has_one :avatar
1864
- accepts_nested_attributes_for :avatar
1305
+ * Allow strings to specify the `#order` value.
1865
1306
 
1866
- def avatar
1867
- super || build_avatar(width: 200)
1868
- end
1869
- end
1307
+ Example:
1870
1308
 
1871
- member = Member.new
1872
- member.avatar_attributes = {icon: 'sad'}
1873
- member.avatar.width # => 200
1309
+ Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
1874
1310
 
1875
- *Olek Janiszewski*
1311
+ *Marcelo Casiraghi*, *Robin Dupret*
1876
1312
 
1877
- * fixes bug introduced by #3329. Now, when autosaving associations,
1878
- deletions happen before inserts and saves. This prevents a 'duplicate
1879
- unique value' database error that would occur if a record being created had
1880
- the same value on a unique indexed field as that of a record being destroyed.
1313
+ * Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
1314
+ warnings on enum columns.
1881
1315
 
1882
- *Johnny Holton*
1316
+ *Dieter Komendera*
1883
1317
 
1884
- * Handle aliased attributes in ActiveRecord::Relation.
1318
+ * `includes` is able to detect the right preloading strategy when string
1319
+ joins are involved.
1885
1320
 
1886
- When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database:
1321
+ Fixes #14109.
1887
1322
 
1888
- With the model
1323
+ *Aaron Patterson*, *Yves Senn*
1889
1324
 
1890
- class Topic
1891
- alias_attribute :heading, :title
1892
- end
1325
+ * Fix error with validation with enum fields for records where the value for
1326
+ any enum attribute is always evaluated as 0 during uniqueness validation.
1893
1327
 
1894
- The call
1328
+ Fixes #14172.
1895
1329
 
1896
- Topic.where(heading: 'The First Topic')
1330
+ *Vilius Luneckas* *Ahmed AbouElhamayed*
1897
1331
 
1898
- should yield the same result as
1332
+ * `before_add` callbacks are fired before the record is saved on
1333
+ `has_and_belongs_to_many` associations *and* on `has_many :through`
1334
+ associations. Before this change, `before_add` callbacks would be fired
1335
+ before the record was saved on `has_and_belongs_to_many` associations, but
1336
+ *not* on `has_many :through` associations.
1899
1337
 
1900
- Topic.where(title: 'The First Topic')
1338
+ Fixes #14144.
1901
1339
 
1902
- This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`.
1340
+ * Fix STI classes not defining an attribute method if there is a conflicting
1341
+ private method defined on its ancestors.
1903
1342
 
1904
- This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`.
1343
+ Fixes #11569.
1905
1344
 
1906
1345
  *Godfrey Chan*
1907
1346
 
1908
- * Mute `psql` output when running rake db:schema:load.
1347
+ * Coerce strings when reading attributes. Fixes #10485.
1909
1348
 
1910
- *Godfrey Chan*
1349
+ Example:
1911
1350
 
1912
- * Trigger a save on `has_one association=(associate)` when the associate contents have changed.
1351
+ book = Book.new(title: 12345)
1352
+ book.save!
1353
+ book.title # => "12345"
1913
1354
 
1914
- Fixes #8856.
1355
+ *Yves Senn*
1915
1356
 
1916
- *Chris Thompson*
1357
+ * Deprecate half-baked support for PostgreSQL range values with excluding beginnings.
1358
+ We currently map PostgreSQL ranges to Ruby ranges. This conversion is not fully
1359
+ possible because the Ruby range does not support excluded beginnings.
1917
1360
 
1918
- * Abort a rake task when missing db/structure.sql like `db:schema:load` task.
1361
+ The current solution of incrementing the beginning is not correct and is now
1362
+ deprecated. For subtypes where we don't know how to increment (e.g. `#succ`
1363
+ is not defined) it will raise an `ArgumentException` for ranges with excluding
1364
+ beginnings.
1919
1365
 
1920
- *kennyj*
1366
+ *Yves Senn*
1921
1367
 
1922
- * rake:db:test:prepare falls back to original environment after execution.
1368
+ * Support for user created range types in PostgreSQL.
1923
1369
 
1924
- *Slava Markevich*
1370
+ *Yves Senn*
1925
1371
 
1926
- Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes.
1372
+ Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activerecord/CHANGELOG.md) for previous changes.