activerecord 5.0.7 → 5.1.7

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 (219) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +657 -2080
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/examples/performance.rb +28 -28
  6. data/examples/simple.rb +3 -3
  7. data/lib/active_record/aggregations.rb +244 -244
  8. data/lib/active_record/association_relation.rb +5 -5
  9. data/lib/active_record/associations/alias_tracker.rb +10 -11
  10. data/lib/active_record/associations/association.rb +23 -5
  11. data/lib/active_record/associations/association_scope.rb +95 -81
  12. data/lib/active_record/associations/belongs_to_association.rb +7 -4
  13. data/lib/active_record/associations/builder/belongs_to.rb +30 -16
  14. data/lib/active_record/associations/builder/collection_association.rb +1 -2
  15. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +27 -27
  16. data/lib/active_record/associations/collection_association.rb +36 -205
  17. data/lib/active_record/associations/collection_proxy.rb +132 -63
  18. data/lib/active_record/associations/has_many_association.rb +10 -19
  19. data/lib/active_record/associations/has_many_through_association.rb +12 -4
  20. data/lib/active_record/associations/has_one_association.rb +24 -28
  21. data/lib/active_record/associations/has_one_through_association.rb +5 -1
  22. data/lib/active_record/associations/join_dependency/join_association.rb +4 -28
  23. data/lib/active_record/associations/join_dependency/join_base.rb +1 -1
  24. data/lib/active_record/associations/join_dependency/join_part.rb +1 -1
  25. data/lib/active_record/associations/join_dependency.rb +121 -118
  26. data/lib/active_record/associations/preloader/association.rb +64 -64
  27. data/lib/active_record/associations/preloader/belongs_to.rb +0 -2
  28. data/lib/active_record/associations/preloader/collection_association.rb +6 -6
  29. data/lib/active_record/associations/preloader/has_many.rb +0 -2
  30. data/lib/active_record/associations/preloader/singular_association.rb +6 -8
  31. data/lib/active_record/associations/preloader/through_association.rb +41 -41
  32. data/lib/active_record/associations/preloader.rb +94 -94
  33. data/lib/active_record/associations/singular_association.rb +8 -25
  34. data/lib/active_record/associations/through_association.rb +2 -5
  35. data/lib/active_record/associations.rb +1591 -1562
  36. data/lib/active_record/attribute/user_provided_default.rb +4 -2
  37. data/lib/active_record/attribute.rb +98 -71
  38. data/lib/active_record/attribute_assignment.rb +61 -61
  39. data/lib/active_record/attribute_decorators.rb +35 -13
  40. data/lib/active_record/attribute_methods/before_type_cast.rb +7 -7
  41. data/lib/active_record/attribute_methods/dirty.rb +229 -46
  42. data/lib/active_record/attribute_methods/primary_key.rb +74 -73
  43. data/lib/active_record/attribute_methods/read.rb +39 -35
  44. data/lib/active_record/attribute_methods/serialization.rb +7 -7
  45. data/lib/active_record/attribute_methods/time_zone_conversion.rb +35 -58
  46. data/lib/active_record/attribute_methods/write.rb +30 -33
  47. data/lib/active_record/attribute_methods.rb +56 -65
  48. data/lib/active_record/attribute_mutation_tracker.rb +63 -11
  49. data/lib/active_record/attribute_set/builder.rb +27 -33
  50. data/lib/active_record/attribute_set/yaml_encoder.rb +41 -0
  51. data/lib/active_record/attribute_set.rb +9 -6
  52. data/lib/active_record/attributes.rb +22 -22
  53. data/lib/active_record/autosave_association.rb +18 -13
  54. data/lib/active_record/base.rb +24 -22
  55. data/lib/active_record/callbacks.rb +56 -14
  56. data/lib/active_record/coders/yaml_column.rb +9 -11
  57. data/lib/active_record/collection_cache_key.rb +3 -4
  58. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +330 -284
  59. data/lib/active_record/connection_adapters/abstract/database_limits.rb +1 -3
  60. data/lib/active_record/connection_adapters/abstract/database_statements.rb +39 -37
  61. data/lib/active_record/connection_adapters/abstract/query_cache.rb +32 -27
  62. data/lib/active_record/connection_adapters/abstract/quoting.rb +62 -51
  63. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +10 -20
  64. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +74 -79
  65. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +53 -41
  66. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +120 -100
  67. data/lib/active_record/connection_adapters/abstract/transaction.rb +49 -43
  68. data/lib/active_record/connection_adapters/abstract_adapter.rb +165 -135
  69. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +404 -424
  70. data/lib/active_record/connection_adapters/column.rb +26 -4
  71. data/lib/active_record/connection_adapters/connection_specification.rb +128 -118
  72. data/lib/active_record/connection_adapters/mysql/column.rb +6 -31
  73. data/lib/active_record/connection_adapters/mysql/database_statements.rb +36 -49
  74. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +22 -22
  75. data/lib/active_record/connection_adapters/mysql/quoting.rb +6 -12
  76. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +49 -45
  77. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +16 -19
  78. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +54 -28
  79. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +43 -0
  80. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +7 -6
  81. data/lib/active_record/connection_adapters/mysql2_adapter.rb +23 -27
  82. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +32 -53
  83. data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +3 -3
  84. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +19 -9
  85. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +5 -3
  86. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +1 -1
  87. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +2 -2
  88. data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +1 -1
  89. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +3 -3
  90. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +16 -16
  91. data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +0 -10
  92. data/lib/active_record/connection_adapters/postgresql/oid/{rails_5_1_point.rb → legacy_point.rb} +9 -16
  93. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
  94. data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +13 -0
  95. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +28 -8
  96. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +32 -30
  97. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +2 -1
  98. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +51 -51
  99. data/lib/active_record/connection_adapters/postgresql/oid.rb +22 -21
  100. data/lib/active_record/connection_adapters/postgresql/quoting.rb +40 -35
  101. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +15 -0
  102. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +37 -24
  103. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +19 -23
  104. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +182 -222
  105. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +6 -4
  106. data/lib/active_record/connection_adapters/postgresql/utils.rb +7 -5
  107. data/lib/active_record/connection_adapters/postgresql_adapter.rb +198 -167
  108. data/lib/active_record/connection_adapters/schema_cache.rb +16 -7
  109. data/lib/active_record/connection_adapters/sql_type_metadata.rb +3 -3
  110. data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +1 -1
  111. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +16 -19
  112. data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +1 -8
  113. data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +28 -0
  114. data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +17 -0
  115. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +32 -0
  116. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +184 -167
  117. data/lib/active_record/connection_adapters/statement_pool.rb +7 -7
  118. data/lib/active_record/connection_handling.rb +14 -26
  119. data/lib/active_record/core.rb +109 -93
  120. data/lib/active_record/counter_cache.rb +60 -13
  121. data/lib/active_record/define_callbacks.rb +20 -0
  122. data/lib/active_record/dynamic_matchers.rb +80 -79
  123. data/lib/active_record/enum.rb +8 -6
  124. data/lib/active_record/errors.rb +64 -15
  125. data/lib/active_record/explain.rb +1 -2
  126. data/lib/active_record/explain_registry.rb +1 -1
  127. data/lib/active_record/explain_subscriber.rb +7 -4
  128. data/lib/active_record/fixture_set/file.rb +11 -8
  129. data/lib/active_record/fixtures.rb +66 -53
  130. data/lib/active_record/gem_version.rb +1 -1
  131. data/lib/active_record/inheritance.rb +93 -79
  132. data/lib/active_record/integration.rb +7 -7
  133. data/lib/active_record/internal_metadata.rb +3 -16
  134. data/lib/active_record/legacy_yaml_adapter.rb +1 -1
  135. data/lib/active_record/locking/optimistic.rb +69 -74
  136. data/lib/active_record/locking/pessimistic.rb +10 -1
  137. data/lib/active_record/log_subscriber.rb +23 -28
  138. data/lib/active_record/migration/command_recorder.rb +94 -94
  139. data/lib/active_record/migration/compatibility.rb +100 -47
  140. data/lib/active_record/migration/join_table.rb +6 -6
  141. data/lib/active_record/migration.rb +153 -155
  142. data/lib/active_record/model_schema.rb +94 -107
  143. data/lib/active_record/nested_attributes.rb +200 -199
  144. data/lib/active_record/null_relation.rb +11 -34
  145. data/lib/active_record/persistence.rb +65 -50
  146. data/lib/active_record/query_cache.rb +2 -6
  147. data/lib/active_record/querying.rb +3 -4
  148. data/lib/active_record/railtie.rb +16 -17
  149. data/lib/active_record/railties/controller_runtime.rb +6 -2
  150. data/lib/active_record/railties/databases.rake +105 -133
  151. data/lib/active_record/railties/jdbcmysql_error.rb +1 -1
  152. data/lib/active_record/readonly_attributes.rb +2 -2
  153. data/lib/active_record/reflection.rb +154 -108
  154. data/lib/active_record/relation/batches/batch_enumerator.rb +1 -1
  155. data/lib/active_record/relation/batches.rb +80 -51
  156. data/lib/active_record/relation/calculations.rb +169 -162
  157. data/lib/active_record/relation/delegation.rb +32 -31
  158. data/lib/active_record/relation/finder_methods.rb +197 -231
  159. data/lib/active_record/relation/merger.rb +58 -62
  160. data/lib/active_record/relation/predicate_builder/array_handler.rb +7 -5
  161. data/lib/active_record/relation/predicate_builder/association_query_handler.rb +23 -23
  162. data/lib/active_record/relation/predicate_builder/base_handler.rb +3 -1
  163. data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +0 -8
  164. data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +12 -10
  165. data/lib/active_record/relation/predicate_builder/range_handler.rb +0 -8
  166. data/lib/active_record/relation/predicate_builder.rb +92 -89
  167. data/lib/active_record/relation/query_attribute.rb +1 -1
  168. data/lib/active_record/relation/query_methods.rb +255 -293
  169. data/lib/active_record/relation/record_fetch_warning.rb +3 -3
  170. data/lib/active_record/relation/spawn_methods.rb +4 -5
  171. data/lib/active_record/relation/where_clause.rb +80 -65
  172. data/lib/active_record/relation/where_clause_factory.rb +47 -8
  173. data/lib/active_record/relation.rb +93 -119
  174. data/lib/active_record/result.rb +41 -32
  175. data/lib/active_record/runtime_registry.rb +3 -3
  176. data/lib/active_record/sanitization.rb +176 -192
  177. data/lib/active_record/schema.rb +3 -3
  178. data/lib/active_record/schema_dumper.rb +15 -38
  179. data/lib/active_record/schema_migration.rb +8 -4
  180. data/lib/active_record/scoping/default.rb +90 -90
  181. data/lib/active_record/scoping/named.rb +11 -11
  182. data/lib/active_record/scoping.rb +6 -6
  183. data/lib/active_record/secure_token.rb +2 -2
  184. data/lib/active_record/statement_cache.rb +13 -15
  185. data/lib/active_record/store.rb +31 -32
  186. data/lib/active_record/suppressor.rb +2 -1
  187. data/lib/active_record/table_metadata.rb +9 -5
  188. data/lib/active_record/tasks/database_tasks.rb +65 -55
  189. data/lib/active_record/tasks/mysql_database_tasks.rb +76 -73
  190. data/lib/active_record/tasks/postgresql_database_tasks.rb +72 -47
  191. data/lib/active_record/tasks/sqlite_database_tasks.rb +18 -16
  192. data/lib/active_record/timestamp.rb +46 -25
  193. data/lib/active_record/touch_later.rb +1 -2
  194. data/lib/active_record/transactions.rb +97 -109
  195. data/lib/active_record/type/adapter_specific_registry.rb +46 -42
  196. data/lib/active_record/type/decimal_without_scale.rb +13 -0
  197. data/lib/active_record/type/hash_lookup_type_map.rb +3 -3
  198. data/lib/active_record/type/internal/abstract_json.rb +4 -0
  199. data/lib/active_record/type/serialized.rb +14 -8
  200. data/lib/active_record/type/text.rb +9 -0
  201. data/lib/active_record/type/time.rb +0 -1
  202. data/lib/active_record/type/type_map.rb +11 -15
  203. data/lib/active_record/type/unsigned_integer.rb +15 -0
  204. data/lib/active_record/type.rb +17 -13
  205. data/lib/active_record/type_caster/connection.rb +8 -6
  206. data/lib/active_record/type_caster/map.rb +3 -1
  207. data/lib/active_record/type_caster.rb +2 -2
  208. data/lib/active_record/validations/associated.rb +1 -1
  209. data/lib/active_record/validations/presence.rb +2 -2
  210. data/lib/active_record/validations/uniqueness.rb +8 -39
  211. data/lib/active_record/validations.rb +4 -4
  212. data/lib/active_record/version.rb +1 -1
  213. data/lib/active_record.rb +20 -20
  214. data/lib/rails/generators/active_record/migration/migration_generator.rb +37 -34
  215. data/lib/rails/generators/active_record/migration.rb +1 -1
  216. data/lib/rails/generators/active_record/model/model_generator.rb +9 -9
  217. data/lib/rails/generators/active_record.rb +4 -4
  218. metadata +24 -13
  219. data/lib/active_record/relation/predicate_builder/class_handler.rb +0 -27
data/CHANGELOG.md CHANGED
@@ -1,2539 +1,1116 @@
1
- ## Rails 5.0.7 (March 29, 2018) ##
1
+ ## Rails 5.1.7 (March 27, 2019) ##
2
2
 
3
- * Apply time column precision on assignment.
4
-
5
- PR #20317 changed the behavior of datetime columns so that when they
6
- have a specified precision then on assignment the value is rounded to
7
- that precision. This behavior is now applied to time columns as well.
8
-
9
- Fixes #30301.
10
-
11
- *Andrew White*
12
-
13
- * Normalize time column values for SQLite database.
14
-
15
- For legacy reasons, time columns in SQLite are stored as full datetimes
16
- because until #24542 the quoting for time columns didn't remove the date
17
- component. To ensure that values are consistent we now normalize the
18
- date component to 2001-01-01 on reading and writing.
19
-
20
- *Andrew White*
21
-
22
- * Ensure that the date component is removed when quoting times.
23
-
24
- PR #24542 altered the quoting for time columns so that the date component
25
- was removed however it only removed it when it was 2001-01-01. Now the
26
- date component is removed irrespective of what the date is.
27
-
28
- *Andrew White*
29
-
30
- * Query cache was unavailable when entering the `ActiveRecord::Base.cache` block
31
- without being connected.
32
-
33
- *Tsukasa Oishi*
34
-
35
- * Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong
36
- ar_internal_metadata's data for a test database.
37
-
38
- Before:
39
- ```
40
- $ RAILS_ENV=test rails dbconsole
41
- > SELECT * FROM ar_internal_metadata;
42
- key|value|created_at|updated_at
43
- environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
44
- ```
45
-
46
- After:
47
- ```
48
- $ RAILS_ENV=test rails dbconsole
49
- > SELECT * FROM ar_internal_metadata;
50
- key|value|created_at|updated_at
51
- environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
52
- ```
53
-
54
- Fixes #26731.
55
-
56
- *bogdanvlviv*
57
-
58
- * Fix longer sequence name detection for serial columns.
59
-
60
- Fixes #28332.
61
-
62
- *Ryuta Kamizono*
63
-
64
- * Use `max_identifier_length` for `index_name_length` in PostgreSQL adapter.
65
-
66
- *Ryuta Kamizono*
67
-
68
-
69
- ## Rails 5.0.6 (September 07, 2017) ##
70
-
71
- * No changes.
72
-
73
-
74
- ## Rails 5.0.6.rc1 (August 24, 2017) ##
75
-
76
- * Ensure `sum` honors `distinct` on `has_many :through` associations
77
-
78
- Fixes #16791
79
-
80
- *Aaron Wortham
81
-
82
-
83
- ## Rails 5.0.5 (July 31, 2017) ##
84
-
85
- * No changes.
86
-
87
-
88
- ## Rails 5.0.5.rc2 (July 25, 2017) ##
89
-
90
- * No changes.
91
-
92
-
93
- ## Rails 5.0.5.rc1 (July 19, 2017) ##
94
-
95
- * `Relation#joins` is no longer affected by the target model's
96
- `current_scope`, with the exception of `unscoped`.
97
-
98
- Fixes #29338.
99
-
100
- *Sean Griffin*
101
-
102
-
103
- ## Rails 5.0.4 (June 19, 2017) ##
104
-
105
- * Restore previous behavior of collection proxies: their values can have
106
- methods stubbed, and they respect extension modules applied by a default
107
- scope.
108
-
109
- *Ryuta Kamizono*
110
-
111
- * Loading model schema from database is now thread-safe.
112
-
113
- Fixes #28589.
114
-
115
- *Vikrant Chaudhary*, *David Abdemoulaie*
116
-
117
-
118
- ## Rails 5.0.3 (May 12, 2017) ##
119
-
120
- * Check whether `Rails.application` defined before calling it
121
-
122
- In #27674 we changed the migration generator to generate migrations at the
123
- path defined in `Rails.application.config.paths` however the code checked
124
- for the presence of the `Rails` constant but not the `Rails.application`
125
- method which caused problems when using Active Record and generators outside
126
- of the context of a Rails application.
127
-
128
- Fixes #28325.
129
-
130
- * Fix `deserialize` with JSON array.
131
-
132
- Fixes #28285.
133
-
134
- *Ryuta Kamizono*
135
-
136
- * Fix `rake db:schema:load` with subdirectories.
137
-
138
- *Ryuta Kamizono*
139
-
140
- * Fix `rake db:migrate:status` with subdirectories.
141
-
142
- *Ryuta Kamizono*
143
-
144
- * Don't share options between reference id and type columns
145
-
146
- When using a polymorphic reference column in a migration, sharing options
147
- between the two columns doesn't make sense since they are different types.
148
- The `reference_id` column is usually an integer and the `reference_type`
149
- column a string so options like `unsigned: true` will result in an invalid
150
- table definition.
151
-
152
- *Ryuta Kamizono*
153
-
154
- * Fix regression of #1969 with SELECT aliases in HAVING clause.
155
-
156
- *Eugene Kenny*
157
-
158
-
159
- ## Rails 5.0.2 (March 01, 2017) ##
160
-
161
- * Fix `wait_timeout` to configurable for mysql2 adapter.
162
-
163
- Fixes #26556.
164
-
165
- *Ryuta Kamizono*
166
-
167
- * Make `table_name=` reset current statement cache,
168
- so queries are not run against the previous table name.
169
-
170
- *namusyaka*
171
-
172
- * Allow ActiveRecord::Base#as_json to be passed a frozen Hash.
173
-
174
- *Isaac Betesh*
175
-
176
- * Fix inspection behavior when the :id column is not primary key.
177
-
178
- *namusyaka*
179
-
180
- * Fix `association_primary_key_type` for reflections with symbol primary key
181
-
182
- Fixes #27864
183
-
184
- *Daniel Colson*
185
-
186
- * Place generated migrations into the path set by `config.paths["db/migrate"]`
187
-
188
- *Kevin Glowacz*
189
-
190
- * Compare deserialized values for `PostgreSQL::OID::Hstore` types when
191
- calling `ActiveRecord::Dirty#changed_in_place?`
192
-
193
- Fixes #27502.
194
-
195
- *Jon Moss*
196
-
197
- * Respect precision option for arrays of timestamps.
198
-
199
- Fixes #27514.
200
-
201
- *Sean Griffin*
202
-
203
-
204
- ## Rails 5.0.1 (December 21, 2016) ##
205
-
206
- * No changes.
207
-
208
-
209
- ## Rails 5.0.1.rc2 (December 10, 2016) ##
210
-
211
- * Correct resolution of associated class in `has_many :through`
212
- associations' `*_ids` setters.
213
-
214
- Fixes #27297.
215
-
216
- *Matthew Draper*
217
-
218
- * Support index length and order options using both string and symbol
219
- column names.
220
-
221
- Fixes #27243.
222
-
223
- *Ryuta Kamizono*
224
-
225
-
226
- ## Rails 5.0.1.rc1 (December 01, 2016) ##
227
-
228
- * Fix that unsigned with zerofill is treated as signed.
229
-
230
- Fixes #27125.
231
-
232
- *Ryuta Kamizono*
233
-
234
- * Fix the uniqueness validation scope with a polymorphic association.
235
-
236
- *Sergey Alekseev*
237
-
238
- * Raise ActiveRecord::RecordNotFound from collection `*_ids` setters
239
- for unknown IDs with a better error message.
240
-
241
- Changes the collection `*_ids` setters to cast provided IDs the data
242
- type of the primary key set in the association, not the model
243
- primary key.
244
-
245
- *Dominic Cleal*
246
-
247
- * Introduce `Model#reload_<association>` to bring back the behavior
248
- of `Article.category(true)` where `category` is a singular
249
- association.
250
-
251
- The force reloading of the association reader was deprecated
252
- in #20888. Unfortunately the suggested alternative of
253
- `article.reload.category` does not expose the same behavior.
254
-
255
- This patch adds a reader method with the prefix `reload_` for
256
- singular associations. This method has the same semantics as
257
- passing true to the association reader used to have.
258
-
259
- *Yves Senn*
260
-
261
- * Make sure eager loading `ActiveRecord::Associations` also loads
262
- constants defined in `ActiveRecord::Associations::Preloader`.
263
-
264
- *Yves Senn*
265
-
266
- * Allow `ActionController::Parameters`-like objects to be passed as
267
- values for Postgres HStore columns.
268
-
269
- Fixes #26904.
270
-
271
- *Jon Moss*
272
-
273
- * Configure query caching (per thread) on the connection pool.
274
-
275
- Moving the configuration to the pool means we don't allocate a connection
276
- until it's actually needed.
277
-
278
- Applications that manually interact with the connection pool and/or query
279
- cache may notice that the connection's cache is now cleared and disabled
280
- when it gets returned to the pool, even if the request is not yet completed.
281
-
282
- *Samuel Cochran*, *Matthew Draper*
283
-
284
- * Fixed support for case insensitive comparisons of `text` columns in
285
- PostgreSQL.
286
-
287
- *Edho Arief*
288
-
289
- * Return `true` from `update_attribute` when the value of the attribute
290
- to be updated is unchanged.
291
-
292
- Fixes #26593.
293
-
294
- *Prathamesh Sonpatki*
295
-
296
- * Serialize JSON attribute value `nil` as SQL `NULL`, not JSON `null`
297
-
298
- *Trung Duc Tran*
299
-
300
- * Always store errors details information with symbols.
301
-
302
- When the association is autosaved we were storing the details with
303
- string keys. This was creating inconsistency with other details that are
304
- added using the `Errors#add` method. It was also inconsistent with the
305
- `Errors#messages` storage.
306
-
307
- To fix this inconsistency we are always storing with symbols. This will
308
- cause a small breaking change because in those cases the details could
309
- be accessed as strings keys but now it can not.
310
-
311
- Fix #26499.
312
-
313
- *Rafael Mendonça França*, *Marcus Vieira*
314
-
315
- * Using a mysql2 connection after it fails to reconnect will now have an error message
316
- saying the connection is closed rather than an undefined method error message.
317
-
318
- *Dylan Thacker-Smith*
319
-
320
- * Remove unnecessarily association load when a `belongs_to` association has already been
321
- loaded then the foreign key is changed directly and the record saved.
322
-
323
- *James Coleman*
324
-
325
- * PostgreSQL array columns will now respect the encoding of strings contained
326
- in the array.
327
-
328
- Fixes #26326.
329
-
330
- *Sean Griffin*
331
-
332
- * Inverse association instances will now be set before `after_find` or
333
- `after_initialize` callbacks are run.
334
-
335
- Fixes #26320.
336
-
337
- *Sean Griffin*
338
-
339
- * Avoid loading records from database when they are already loaded using
340
- the `pluck` method on a collection.
341
-
342
- Fixes #25921.
343
-
344
- *Ryuta Kamizono*
345
-
346
- * Sqlite3 migrations to add a column to an existing table can now be
347
- successfully rolled back when the column was given and invalid column
348
- type.
349
-
350
- Fixes #26087
351
-
352
- *Travis O'Neill*
353
-
354
- * Hashes can once again be passed to setters of `composed_of`, if all of the
355
- mapping methods are methods implemented on `Hash`.
356
-
357
- Fixes #25978.
358
-
359
- *Sean Griffin*
360
-
361
- * Doing count on relations that contain LEFT OUTER JOIN Arel node no longer
362
- force a DISTINCT. This solves issues when using count after a left_joins.
363
-
364
- *Maxime Handfield Lapointe*
365
-
366
- * RecordNotFound raised by association.find exposes `id`, `primary_key` and
367
- `model` methods to be consistent with RecordNotFound raised by Record.find.
368
-
369
- *Michel Pigassou*
370
-
371
- * Fix the SELECT statement in `#table_comment` for MySQL.
372
-
373
- *Takeshi Akima*
374
-
375
- * Virtual attributes will no longer raise when read on models loaded from the
376
- database
377
-
378
- *Sean Griffin*
379
-
380
- * Fixes multi-parameter attributes conversion with invalid params.
381
-
382
- *Hiroyuki Ishii*
383
-
384
- * Add newline between each migration in `structure.sql`.
385
-
386
- Keeps schema migration inserts as a single commit, but allows for easier
387
- git diff-ing. Fixes #25504.
388
-
389
- *Grey Baker*, *Norberto Lopes*
390
-
391
- * Using `group` with an attribute that has a custom type will properly cast
392
- the hash keys after calling a calculation method like `count`.
393
-
394
- Fixes #25595.
395
-
396
- *Sean Griffin*
397
-
398
- * Ensure concurrent invocations of the connection reaper cannot allocate the
399
- same connection to two threads.
400
-
401
- Fixes #25585.
402
-
403
- *Matthew Draper*
404
-
405
- * Fixed dumping of foreign key's referential actions when MySQL connection
406
- uses `sql_mode = ANSI_QUOTES`.
407
-
408
- Fixes #25300.
409
-
410
- *Ryuta Kamizono*
411
-
412
-
413
- ## Rails 5.0.0 (June 30, 2016) ##
414
-
415
- * Inspecting an object with an associated array of over 10 elements no longer
416
- truncates the array, preventing `inspect` from looping infinitely in some
417
- cases.
418
-
419
- *Kevin McPhillips*
420
-
421
- * Ensure hashes can be assigned to attributes created using `composed_of`.
422
-
423
- Fixes #25210.
424
-
425
- *Sean Griffin*
426
-
427
- * Fix logging edge case where if an attribute was of the binary type and
428
- was provided as a Hash.
429
-
430
- *Jon Moss*
431
-
432
- * Handle JSON deserialization correctly if the column default from database
433
- adapter returns `''` instead of `nil`.
434
-
435
- *Johannes Opper*
436
-
437
- * PostgreSQL: Support Expression Indexes and Operator Classes.
438
-
439
- Example:
440
-
441
- create_table :users do |t|
442
- t.string :name
443
- t.index 'lower(name) varchar_pattern_ops'
444
- end
445
-
446
- Fixes #19090, #21765, #21819, #24359.
447
-
448
- *Ryuta Kamizono*
449
-
450
- * MySQL: Prepared statements support.
451
-
452
- To enable, set `prepared_statements: true` in config/database.yml.
453
- Requires mysql2 0.4.4+.
454
-
455
- *Ryuta Kamizono*
456
-
457
- * Schema dumper: Indexes are now included in the `create_table` block
458
- instead of listed afterward as separate `add_index` lines.
459
-
460
- This tidies up schema.rb and makes it easy to read as a list of tables.
461
-
462
- Bonus: Allows databases that support it (MySQL) to perform as single
463
- `CREATE TABLE` query, no additional query per index.
464
-
465
- *Ryuta Kamizono*
466
-
467
- * SQLite: Fix uniqueness validation when values exceed the column limit.
468
-
469
- SQLite doesn't impose length restrictions on strings, BLOBs, or numeric
470
- values. It treats them as helpful metadata. When we truncate strings
471
- before checking uniqueness, we'd miss values that exceed the column limit.
472
-
473
- Other databases enforce length limits. A large value will pass uniqueness
474
- validation since the column limit guarantees no value that long exists.
475
- When we insert the row, it'll raise `ActiveRecord::ValueTooLong` as we
476
- expect.
477
-
478
- This fixes edge-case incorrect validation failures for values that exceed
479
- the column limit but are identical to an existing value *when truncated*.
480
- Now these will pass validation and raise an exception.
481
-
482
- *Ryuta Kamizono*
483
-
484
- * Raise `ActiveRecord::ValueTooLong` when column limits are exceeded.
485
- Supported by MySQL and PostgreSQL adapters.
486
-
487
- *Ryuta Kamizono*
488
-
489
- * Migrations: `#foreign_key` respects `table_name_prefix` and `_suffix`.
490
-
491
- *Ryuta Kamizono*
492
-
493
- * SQLite: Force NOT NULL primary keys.
494
-
495
- From SQLite docs: https://www.sqlite.org/lang_createtable.html
496
- According to the SQL standard, PRIMARY KEY should always imply NOT
497
- NULL. Unfortunately, due to a bug in some early versions, this is not
498
- the case in SQLite. Unless the column is an INTEGER PRIMARY KEY or the
499
- table is a WITHOUT ROWID table or the column is declared NOT NULL,
500
- SQLite allows NULL values in a PRIMARY KEY column. SQLite could be
501
- fixed to conform to the standard, but doing so might break legacy
502
- applications. Hence, it has been decided to merely document the fact
503
- that SQLite allowing NULLs in most PRIMARY KEY columns.
504
-
505
- Now we override column options to explicitly set NOT NULL rather than rely
506
- on implicit NOT NULL like MySQL and PostgreSQL adapters.
507
-
508
- *Ryuta Kamizono*
509
-
510
- * Added notice when a database is successfully created or dropped.
511
-
512
- Example:
513
-
514
- $ bin/rails db:create
515
- Created database 'blog_development'
516
- Created database 'blog_test'
517
-
518
- $ bin/rails db:drop
519
- Dropped database 'blog_development'
520
- Dropped database 'blog_test'
521
-
522
- Changed older notices
523
- `blog_development already exists` to `Database 'blog_development' already exists`.
524
- and
525
- `Couldn't drop blog_development` to `Couldn't drop database 'blog_development'`.
526
-
527
- *bogdanvlviv*
528
-
529
- * Database comments. Annotate database objects (tables, columns, indexes)
530
- with comments stored in database metadata. PostgreSQL & MySQL support.
531
-
532
- create_table :pages, force: :cascade, comment: 'CMS content pages' do |t|
533
- t.string :path, comment: 'Path fragment of page URL used for routing'
534
- t.string :locale, comment: 'RFC 3066 locale code of website language section'
535
- t.index [:path, :locale], comment: 'Look up pages by URI'
536
- end
537
-
538
- *Andrey Novikov*
539
-
540
- * Add `quoted_time` for truncating the date part of a TIME column value.
541
- This fixes queries on TIME column on MariaDB, as it doesn't ignore the
542
- date part of the string when it coerces to time.
543
-
544
- *Ryuta Kamizono*
545
-
546
- * Properly accept all valid JSON primitives in the JSON data type.
547
-
548
- Fixes #24234
549
-
550
- *Sean Griffin*
551
-
552
- * MariaDB 5.3+ supports microsecond datetime precision.
553
-
554
- *Jeremy Daer*
555
-
556
- * Delegate `none?` and `one?`. Now they can be invoked as model class methods.
557
-
558
- Example:
559
-
560
- # When no record is found on the table
561
- Topic.none? # => true
562
-
563
- # When only one record is found on the table
564
- Topic.one? # => true
565
-
566
- *Kenta Shirai*
567
-
568
- * The form builder now properly displays values when passing a proc form
569
- default to the attributes API.
570
-
571
- Fixes #24249.
572
-
573
- *Sean Griffin*
574
-
575
- * The schema cache is now cleared after the `db:migrate` task is run.
576
-
577
- Closes #24273.
578
-
579
- *Chris Arcand*
580
-
581
- * MySQL: strict mode respects other SQL modes rather than overwriting them.
582
- Setting `strict: true` adds `STRICT_ALL_TABLES` to `sql_mode`. Setting
583
- `strict: false` removes `STRICT_TRANS_TABLES`, `STRICT_ALL_TABLES`, and
584
- `TRADITIONAL` from `sql_mode`.
585
-
586
- *Ryuta Kamizono*
587
-
588
- * Execute default_scope defined by abstract class in the context of subclass.
589
-
590
- Fixes #23413.
591
- Fixes #10658.
592
-
593
- *Mehmet Emin İNAÇ*
594
-
595
- * Fix an issue when preloading associations with extensions.
596
- Previously every association with extension methods was transformed into an
597
- instance dependent scope. This is no longer the case.
598
-
599
- Fixes #23934.
600
-
601
- *Yves Senn*
602
-
603
- * Deprecate `{insert|update|delete}_sql` in `DatabaseStatements`.
604
- Use the `{insert|update|delete}` public methods instead.
605
-
606
- *Ryuta Kamizono*
607
-
608
- * Added a configuration option to have active record raise an ArgumentError
609
- if the order or limit is ignored in a batch query, rather than logging a
610
- warning message.
611
-
612
- *Scott Ringwelski*
613
-
614
- * Honour the order of the joining model in a `has_many :through` association when eager loading.
615
-
616
- Example:
617
-
618
- The below will now follow the order of `by_lines` when eager loading `authors`.
619
-
620
- class Article < ActiveRecord::Base
621
- has_many :by_lines, -> { order(:position) }
622
- has_many :authors, through: :by_lines
623
- end
624
-
625
- Fixes #17864.
626
-
627
- *Yasyf Mohamedali*, *Joel Turkel*
628
-
629
- * Ensure that the Suppressor runs before validations.
630
-
631
- This moves the suppressor up to be run before validations rather than after
632
- validations. There's no reason to validate a record you aren't planning on saving.
633
-
634
- *Eileen M. Uchitelle*
635
-
636
- * Save many-to-many objects based on association primary key.
637
-
638
- Fixes #20995.
639
-
640
- *himesh-r*
641
-
642
- * Ensure that mutations of the array returned from `ActiveRecord::Relation#to_a`
643
- do not affect the original relation, by returning a duplicate array each time.
644
-
645
- This brings the behavior in line with `CollectionProxy#to_a`, which was
646
- already more careful.
647
-
648
- *Matthew Draper*
649
-
650
- * Fixed `where` for polymorphic associations when passed an array containing different types.
651
-
652
- Fixes #17011.
653
-
654
- Example:
655
-
656
- PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)])
657
- # => SELECT "price_estimates".* FROM "price_estimates"
658
- WHERE (("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" = 1)
659
- OR ("price_estimates"."estimate_of_type" = 'Car' AND "price_estimates"."estimate_of_id" = 2))
660
-
661
- *Philippe Huibonhoa*
662
-
663
- * Fix a bug where using `t.foreign_key` twice with the same `to_table` within
664
- the same table definition would only create one foreign key.
665
-
666
- *George Millo*
667
-
668
- * Fix a regression on has many association, where calling a child from parent in child's callback
669
- results in same child records getting added repeatedly to target.
670
-
671
- Fixes #13387.
672
-
673
- *Bogdan Gusiev*, *Jon Hinson*
674
-
675
- * Rework `ActiveRecord::Relation#last`.
676
-
677
- 1. Never perform additional SQL on loaded relation
678
- 2. Use SQL reverse order instead of loading relation if relation doesn't have limit
679
- 3. Deprecated relation loading when SQL order can not be automatically reversed
680
-
681
- Topic.order("title").load.last(3)
682
- # before: SELECT ...
683
- # after: No SQL
684
-
685
- Topic.order("title").last
686
- # before: SELECT * FROM `topics`
687
- # after: SELECT * FROM `topics` ORDER BY `topics`.`title` DESC LIMIT 1
688
-
689
- Topic.order("coalesce(author, title)").last
690
- # before: SELECT * FROM `topics`
691
- # after: Deprecation Warning for irreversible order
692
-
693
- *Bogdan Gusiev*
694
-
695
- * Allow `joins` to be unscoped.
696
-
697
- Fixes #13775.
698
-
699
- *Takashi Kokubun*
700
-
701
- * Add `#second_to_last` and `#third_to_last` finder methods.
702
-
703
- *Brian Christian*
704
-
705
- * Added `numeric` helper into migrations.
706
-
707
- Example:
708
-
709
- create_table(:numeric_types) do |t|
710
- t.numeric :numeric_type, precision: 10, scale: 2
711
- end
712
-
713
- *Mehmet Emin İNAÇ*
714
-
715
- * Bumped the minimum supported version of PostgreSQL to >= 9.1.
716
- Both PG 9.0 and 8.4 are past their end of life date:
717
- http://www.postgresql.org/support/versioning/
718
-
719
- *Remo Mueller*
720
-
721
- * `ActiveRecord::Relation#reverse_order` throws `ActiveRecord::IrreversibleOrderError`
722
- when the order can not be reversed using current trivial algorithm.
723
- Also raises the same error when `#reverse_order` is called on
724
- relation without any order and table has no primary key:
725
-
726
- Topic.order("concat(author_name, title)").reverse_order
727
- # Before: SELECT `topics`.* FROM `topics` ORDER BY concat(author_name DESC, title) DESC
728
- # After: raises ActiveRecord::IrreversibleOrderError
729
- Edge.all.reverse_order
730
- # Before: SELECT `edges`.* FROM `edges` ORDER BY `edges`.`` DESC
731
- # After: raises ActiveRecord::IrreversibleOrderError
732
-
733
- *Bogdan Gusiev*
734
-
735
- * Improve schema_migrations insertion performance by inserting all versions
736
- in one INSERT SQL.
737
-
738
- *Akira Matsuda*, *Naoto Koshikawa*
739
-
740
- * Using `references` or `belongs_to` in migrations will always add index
741
- for the referenced column by default, without adding `index: true` option
742
- to generated migration file. Users can opt out of this by passing
743
- `index: false`.
744
-
745
- Fixes #18146.
746
-
747
- *Matthew Draper*, *Prathamesh Sonpatki*
748
-
749
- * Run `type` attributes through attributes API type-casting before
750
- instantiating the corresponding subclass. This makes it possible to define
751
- custom STI mappings.
752
-
753
- Fixes #21986.
754
-
755
- *Yves Senn*
756
-
757
- * Don't try to quote functions or expressions passed to `:default` option if
758
- they are passed as procs.
759
-
760
- This will generate proper query with the passed function or expression for
761
- the default option, instead of trying to quote it in incorrect fashion.
762
-
763
- Example:
764
-
765
- create_table :posts do |t|
766
- t.datetime :published_at, default: -> { 'NOW()' }
767
- end
768
-
769
- *Ryuta Kamizono*
770
-
771
- * Fix regression when loading fixture files with symbol keys.
772
-
773
- Fixes #22584.
774
-
775
- *Yves Senn*
776
-
777
- * Use `version` column as primary key for schema_migrations table because
778
- `schema_migrations` versions are guaranteed to be unique.
779
-
780
- This makes it possible to use `update_attributes` on models that do
781
- not have a primary key.
782
-
783
- *Richard Schneeman*
784
-
785
- * Add short-hand methods for text and blob types in MySQL.
786
-
787
- In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length.
788
- But in MySQL, these have limited length for each types (ref #21591, #21619).
789
- This change adds short-hand methods for each text and blob types.
790
-
791
- Example:
792
-
793
- create_table :foos do |t|
794
- t.tinyblob :tiny_blob
795
- t.mediumblob :medium_blob
796
- t.longblob :long_blob
797
- t.tinytext :tiny_text
798
- t.mediumtext :medium_text
799
- t.longtext :long_text
800
- end
801
-
802
- *Ryuta Kamizono*
803
-
804
- * Take into account UTC offset when assigning string representation of
805
- timestamp with offset specified to attribute of time type.
806
-
807
- *Andrey Novikov*
808
-
809
- * When calling `first` with a `limit` argument, return directly from the
810
- `loaded?` records if available.
811
-
812
- *Ben Woosley*
813
-
814
- * Deprecate sending the `offset` argument to `find_nth`. Please use the
815
- `offset` method on relation instead.
816
-
817
- *Ben Woosley*
818
-
819
- * Limit record touching to once per transaction.
820
-
821
- If you have a parent/grand-parent relation like:
822
-
823
- Comment belongs_to :message, touch: true
824
- Message belongs_to :project, touch: true
825
- Project belongs_to :account, touch: true
826
-
827
- When the lowest entry(`Comment`) is saved, now, it won't repeat the touch
828
- call multiple times for the parent records.
829
-
830
- Related #18606.
831
-
832
- *arthurnn*
833
-
834
- * Order the result of `find(ids)` to match the passed array, if the relation
835
- has no explicit order defined.
836
-
837
- Fixes #20338.
838
-
839
- *Miguel Grazziotin*, *Matthew Draper*
840
-
841
- * Omit default limit values in dumped schema. It's tidier, and if the defaults
842
- change in the future, we can address that via Migration API Versioning.
843
-
844
- *Jean Boussier*
845
-
846
- * Support passing the schema name as a prefix to table name in
847
- `ConnectionAdapters::SchemaStatements#indexes`. Previously the prefix would
848
- be considered a full part of the index name, and only the schema in the
849
- current search path would be considered.
850
-
851
- *Grey Baker*
852
-
853
- * Ignore index name in `index_exists?` and `remove_index` when not passed a
854
- name to check for.
855
-
856
- *Grey Baker*
857
-
858
- * Extract support for the legacy `mysql` database adapter from core. It will
859
- live on in a separate gem for now, but most users should just use `mysql2`.
860
-
861
- *Abdelkader Boudih*
862
-
863
- * ApplicationRecord is a new superclass for all app models, analogous to app
864
- controllers subclassing ApplicationController instead of
865
- ActionController::Base. This gives apps a single spot to configure app-wide
866
- model behavior.
867
-
868
- Newly generated applications have `app/models/application_record.rb`
869
- present by default.
870
-
871
- *Genadi Samokovarov*
872
-
873
- * Version the API presented to migration classes, so we can change parameter
874
- defaults without breaking existing migrations, or forcing them to be
875
- rewritten through a deprecation cycle.
876
-
877
- New migrations specify the Rails version they were written for:
878
-
879
- class AddStatusToOrders < ActiveRecord::Migration[5.0]
880
- def change
881
- # ...
882
- end
883
- end
884
-
885
- *Matthew Draper*, *Ravil Bayramgalin*
886
-
887
- * Use bind params for `limit` and `offset`. This will generate significantly
888
- fewer prepared statements for common tasks like pagination. To support this
889
- change, passing a string containing a comma to `limit` has been deprecated,
890
- and passing an Arel node to `limit` is no longer supported.
891
-
892
- Fixes #22250.
893
-
894
- *Sean Griffin*
895
-
896
- * Introduce after_{create,update,delete}_commit callbacks.
897
-
898
- Before:
899
-
900
- after_commit :add_to_index_later, on: :create
901
- after_commit :update_in_index_later, on: :update
902
- after_commit :remove_from_index_later, on: :destroy
903
-
904
- After:
905
-
906
- after_create_commit :add_to_index_later
907
- after_update_commit :update_in_index_later
908
- after_destroy_commit :remove_from_index_later
909
-
910
- Fixes #22515.
911
-
912
- *Genadi Samokovarov*
913
-
914
- * Respect the column default values for `inheritance_column` when
915
- instantiating records through the base class.
916
-
917
- Fixes #17121.
918
-
919
- Example:
920
-
921
- # The schema of BaseModel has `t.string :type, default: 'SubType'`
922
- subtype = BaseModel.new
923
- assert_equals SubType, subtype.class
924
-
925
- *Kuldeep Aggarwal*
926
-
927
- * Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
928
-
929
- Fixes #22346.
930
-
931
- *Nick Muerdter*, *ckoenig*
932
-
933
- * Add schema dumping support for PostgreSQL geometric data types.
934
-
935
- *Ryuta Kamizono*
936
-
937
- * Except keys of `build_record`'s argument from `create_scope` in `initialize_attributes`.
938
-
939
- Fixes #21893.
940
-
941
- *Yuichiro Kaneko*
942
-
943
- * Deprecate `connection.tables` on the SQLite3 and MySQL adapters.
944
- Also deprecate passing arguments to `#tables`.
945
- And deprecate `table_exists?`.
946
-
947
- The `#tables` method of some adapters (mysql, mysql2, sqlite3) would return
948
- both tables and views while others (postgresql) just return tables. To make
949
- their behavior consistent, `#tables` will return only tables in the future.
950
-
951
- The `#table_exists?` method would check both tables and views. To make
952
- their behavior consistent with `#tables`, `#table_exists?` will check only
953
- tables in the future.
954
-
955
- *Yuichiro Kaneko*
956
-
957
- * Improve support for non Active Record objects on `validates_associated`
958
-
959
- Skipping `marked_for_destruction?` when the associated object does not responds
960
- to it make easier to validate virtual associations built on top of Active Model
961
- objects and/or serialized objects that implement a `valid?` instance method.
962
-
963
- *Kassio Borges*, *Lucas Mazza*
964
-
965
- * Change connection management middleware to return a new response with
966
- a body proxy, rather than mutating the original.
967
-
968
- *Kevin Buchanan*
969
-
970
- * Make `db:migrate:status` to render `1_some.rb` format migrate files.
971
-
972
- These files are in `db/migrate`:
973
-
974
- * 1_valid_people_have_last_names.rb
975
- * 20150819202140_irreversible_migration.rb
976
- * 20150823202140_add_admin_flag_to_users.rb
977
- * 20150823202141_migration_tests.rb
978
- * 2_we_need_reminders.rb
979
- * 3_innocent_jointable.rb
980
-
981
- Before:
982
-
983
- $ bundle exec rake db:migrate:status
984
- ...
985
-
986
- Status Migration ID Migration Name
987
- --------------------------------------------------
988
- up 001 ********** NO FILE **********
989
- up 002 ********** NO FILE **********
990
- up 003 ********** NO FILE **********
991
- up 20150819202140 Irreversible migration
992
- up 20150823202140 Add admin flag to users
993
- up 20150823202141 Migration tests
994
-
995
- After:
996
-
997
- $ bundle exec rake db:migrate:status
998
- ...
999
-
1000
- Status Migration ID Migration Name
1001
- --------------------------------------------------
1002
- up 001 Valid people have last names
1003
- up 002 We need reminders
1004
- up 003 Innocent jointable
1005
- up 20150819202140 Irreversible migration
1006
- up 20150823202140 Add admin flag to users
1007
- up 20150823202141 Migration tests
1008
-
1009
- *Yuichiro Kaneko*
1010
-
1011
- * Define `ActiveRecord::Sanitization.sanitize_sql_for_order` and use it inside
1012
- `preprocess_order_args`.
1013
-
1014
- *Yuichiro Kaneko*
1015
-
1016
- * Allow bigint with default nil for avoiding auto increment primary key.
1017
-
1018
- *Ryuta Kamizono*
1019
-
1020
- * Remove `DEFAULT_CHARSET` and `DEFAULT_COLLATION` in `MySQLDatabaseTasks`.
1021
-
1022
- We should omit the collation entirely rather than providing a default.
1023
- Then the choice is the responsibility of the server and MySQL distribution.
1024
-
1025
- *Ryuta Kamizono*
1026
-
1027
- * Alias `ActiveRecord::Relation#left_joins` to
1028
- `ActiveRecord::Relation#left_outer_joins`.
1029
-
1030
- *Takashi Kokubun*
1031
-
1032
- * Use advisory locking to raise a `ConcurrentMigrationError` instead of
1033
- attempting to migrate when another migration is currently running.
1034
-
1035
- *Sam Davies*
1036
-
1037
- * Added `ActiveRecord::Relation#left_outer_joins`.
1038
-
1039
- Example:
1040
-
1041
- User.left_outer_joins(:posts)
1042
- # => SELECT "users".* FROM "users" LEFT OUTER JOIN "posts" ON
1043
- "posts"."user_id" = "users"."id"
1044
-
1045
- *Florian Thomas*
1046
-
1047
- * Support passing an array to `order` for SQL parameter sanitization.
1048
-
1049
- *Aaron Suggs*
1050
-
1051
- * Avoid disabling errors on the PostgreSQL connection when enabling the
1052
- `standard_conforming_strings` setting. Errors were previously disabled because
1053
- the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
1054
- versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
1055
- setting exists. Disabling errors caused problems when using a connection
1056
- pooling tool like PgBouncer because it's not guaranteed to have the same
1057
- connection between calls to `execute` and it could leave the connection
1058
- with errors disabled.
1059
-
1060
- Fixes #22101.
1061
-
1062
- *Harry Marr*
1063
-
1064
- * Set `scope.reordering_value` to `true` if `:reordering`-values are specified.
1065
-
1066
- Fixes #21886.
1067
-
1068
- *Hiroaki Izu*
1069
-
1070
- * Add support for bidirectional destroy dependencies.
1071
-
1072
- Fixes #13609.
1073
-
1074
- Example:
1075
-
1076
- class Content < ActiveRecord::Base
1077
- has_one :position, dependent: :destroy
1078
- end
1079
-
1080
- class Position < ActiveRecord::Base
1081
- belongs_to :content, dependent: :destroy
1082
- end
1083
-
1084
- *Seb Jacobs*
1085
-
1086
- * Includes HABTM returns correct size now. It's caused by the join dependency
1087
- only instantiates one HABTM object because the join table hasn't a primary key.
1088
-
1089
- Fixes #16032.
1090
-
1091
- Examples:
1092
-
1093
- before:
1094
-
1095
- Project.first.salaried_developers.size # => 3
1096
- Project.includes(:salaried_developers).first.salaried_developers.size # => 1
1097
-
1098
- after:
1099
-
1100
- Project.first.salaried_developers.size # => 3
1101
- Project.includes(:salaried_developers).first.salaried_developers.size # => 3
1102
-
1103
- *Bigxiang*
1104
-
1105
- * Add option to index errors in nested attributes.
1106
-
1107
- For models which have nested attributes, errors within those models will
1108
- now be indexed if `:index_errors` option is set to true when defining a
1109
- `has_many` relationship or by setting the configuration option
1110
- `config.active_record.index_nested_attribute_errors` to true.
1111
-
1112
- Example:
1113
-
1114
- class Guitar < ActiveRecord::Base
1115
- has_many :tuning_pegs, index_errors: true
1116
- accepts_nested_attributes_for :tuning_pegs
1117
- end
1118
-
1119
- class TuningPeg < ActiveRecord::Base
1120
- belongs_to :guitar
1121
- validates_numericality_of :pitch
1122
- end
1123
-
1124
- # Before
1125
- guitar.errors["tuning_pegs.pitch"] = ["is not a number"]
1126
-
1127
- # After
1128
- guitar.errors["tuning_pegs[1].pitch"] = ["is not a number"]
1129
-
1130
- *Michael Probber*, *Terence Sun*
1131
-
1132
- * Exit with non-zero status for failed database rake tasks.
1133
-
1134
- *Jay Hayes*
1135
-
1136
- * Queries such as `Computer.joins(:monitor).group(:status).count` will now be
1137
- interpreted as `Computer.joins(:monitor).group('computers.status').count`
1138
- so that when `Computer` and `Monitor` have both `status` columns we don't
1139
- have conflicts in projection.
1140
-
1141
- *Rafael Sales*
1142
-
1143
- * Add ability to default to `uuid` as primary key when generating database migrations.
1144
-
1145
- Example:
1146
-
1147
- config.generators do |g|
1148
- g.orm :active_record, primary_key_type: :uuid
1149
- end
1150
-
1151
- *Jon McCartie*
1152
-
1153
- * Don't cache arguments in `#find_by` if they are an `ActiveRecord::Relation`.
1154
-
1155
- Fixes #20817.
1156
-
1157
- *Hiroaki Izu*
1158
-
1159
- * Qualify column name inserted by `group` in calculation.
1160
-
1161
- Giving `group` an unqualified column name now works, even if the relation
1162
- has `JOIN` with another table which also has a column of the name.
1163
-
1164
- *Soutaro Matsumoto*
1165
-
1166
- * Don't cache prepared statements containing an IN clause or a SQL literal, as
1167
- these queries will change often and are unlikely to have a cache hit.
1168
-
1169
- *Sean Griffin*
1170
-
1171
- * Fix `rewhere` in a `has_many` association.
1172
-
1173
- Fixes #21955.
1174
-
1175
- *Josh Branchaud*, *Kal*
1176
-
1177
- * `where` raises ArgumentError on unsupported types.
1178
-
1179
- Fixes #20473.
1180
-
1181
- *Jake Worth*
1182
-
1183
- * Add an immutable string type to help reduce memory usage for apps which do
1184
- not need mutation detection on strings.
1185
-
1186
- *Sean Griffin*
1187
-
1188
- * Give `ActiveRecord::Relation#update` its own deprecation warning when
1189
- passed an `ActiveRecord::Base` instance.
1190
-
1191
- Fixes #21945.
1192
-
1193
- *Ted Johansson*
1194
-
1195
- * Make it possible to pass `:to_table` when adding a foreign key through
1196
- `add_reference`.
1197
-
1198
- Fixes #21563.
1199
-
1200
- *Yves Senn*
1201
-
1202
- * No longer pass deprecated option `-i` to `pg_dump`.
1203
-
1204
- *Paul Sadauskas*
1205
-
1206
- * Concurrent `AR::Base#increment!` and `#decrement!` on the same record
1207
- are all reflected in the database rather than overwriting each other.
1208
-
1209
- *Bogdan Gusiev*
1210
-
1211
- * Avoid leaking the first relation we call `first` on, per model.
1212
-
1213
- Fixes #21921.
1214
-
1215
- *Matthew Draper*, *Jean Boussier*
1216
-
1217
- * Remove unused `pk_and_sequence_for` in `AbstractMysqlAdapter`.
1218
-
1219
- *Ryuta Kamizono*
1220
-
1221
- * Allow fixtures files to set the model class in the YAML file itself.
1222
-
1223
- To load the fixtures file `accounts.yml` as the `User` model, use:
1224
-
1225
- _fixture:
1226
- model_class: User
1227
- david:
1228
- name: David
1229
-
1230
- Fixes #9516.
1231
-
1232
- *Roque Pinel*
1233
-
1234
- * Don't require a database connection to load a class which uses acceptance
1235
- validations.
1236
-
1237
- *Sean Griffin*
1238
-
1239
- * Correctly apply `unscope` when preloading through associations.
1240
-
1241
- *Jimmy Bourassa*
1242
-
1243
- * Fixed taking precision into count when assigning a value to timestamp attribute.
1244
-
1245
- Timestamp column can have less precision than ruby timestamp
1246
- In result in how big a fraction of a second can be stored in the
1247
- database.
1248
-
1249
-
1250
- m = Model.create!
1251
- m.created_at.usec == m.reload.created_at.usec # => false
1252
- # due to different precision in Time.now and database column
1253
-
1254
- If the precision is low enough, (mysql default is 0, so it is always low
1255
- enough by default) the value changes when model is reloaded from the
1256
- database. This patch fixes that issue ensuring that any timestamp
1257
- assigned as an attribute is converted to column precision under the
1258
- attribute.
1259
-
1260
- *Bogdan Gusiev*
1261
-
1262
- * Introduce `connection.data_sources` and `connection.data_source_exists?`.
1263
- These methods determine what relations can be used to back Active Record
1264
- models (usually tables and views).
1265
-
1266
- Also deprecate `SchemaCache#tables`, `SchemaCache#table_exists?` and
1267
- `SchemaCache#clear_table_cache!` in favor of their new data source
1268
- counterparts.
1269
-
1270
- *Yves Senn*, *Matthew Draper*
1271
-
1272
- * Add `ActiveRecord::Base.ignored_columns` to make some columns
1273
- invisible from Active Record.
1274
-
1275
- *Jean Boussier*
1276
-
1277
- * `ActiveRecord::Tasks::MySQLDatabaseTasks` fails if shellout to
1278
- mysql commands (like `mysqldump`) is not successful.
1279
-
1280
- *Steve Mitchell*
1281
-
1282
- * Ensure `select` quotes aliased attributes, even when using `from`.
1283
-
1284
- Fixes #21488.
1285
-
1286
- *Sean Griffin*, *@johanlunds*
1287
-
1288
- * MySQL: support `unsigned` numeric data types.
1289
-
1290
- Example:
1291
-
1292
- create_table :foos do |t|
1293
- t.unsigned_integer :quantity
1294
- t.unsigned_bigint :total
1295
- t.unsigned_float :percentage
1296
- t.unsigned_decimal :price, precision: 10, scale: 2
1297
- end
1298
-
1299
- The `unsigned: true` option may be used for the primary key:
1300
-
1301
- create_table :foos, id: :bigint, unsigned: true do |t|
1302
-
1303
- end
3
+ * Fix `touch` option to behave consistently with `Persistence#touch` method.
1304
4
 
1305
5
  *Ryuta Kamizono*
1306
6
 
1307
- * Add `#views` and `#view_exists?` methods on connection adapters.
1308
-
1309
- *Ryuta Kamizono*
7
+ * Back port Rails 5.2 `reverse_order` Arel SQL literal fix.
1310
8
 
1311
- * Correctly dump composite primary key.
9
+ *Matt Jones*, *Brooke Kuhlmann*
1312
10
 
1313
- Example:
11
+ * `becomes` should clear the mutation tracker which is created in `after_initialize`.
1314
12
 
1315
- create_table :barcodes, primary_key: ["region", "code"] do |t|
1316
- t.string :region
1317
- t.integer :code
1318
- end
13
+ Fixes #32867.
1319
14
 
1320
15
  *Ryuta Kamizono*
1321
16
 
1322
- * Lookup the attribute name for `restrict_with_error` messages on the
1323
- model class that defines the association.
1324
-
1325
- *kuboon*, *Ronak Jangir*
1326
-
1327
- * Correct query for PostgreSQL 8.2 compatibility.
1328
-
1329
- *Ben Murphy*, *Matthew Draper*
1330
-
1331
- * `bin/rails db:migrate` uses
1332
- `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
1333
- `Migrator.migrations_paths`.
1334
-
1335
- *Tobias Bielohlawek*
1336
-
1337
- * Support dropping indexes concurrently in PostgreSQL.
1338
-
1339
- See http://www.postgresql.org/docs/9.4/static/sql-dropindex.html for more
1340
- details.
1341
17
 
1342
- *Grey Baker*
18
+ ## Rails 5.1.6.2 (March 11, 2019) ##
1343
19
 
1344
- * Deprecate passing conditions to `ActiveRecord::Relation#delete_all`
1345
- and `ActiveRecord::Relation#destroy_all`.
1346
-
1347
- *Wojciech Wnętrzak*
20
+ * No changes.
1348
21
 
1349
- * Instantiating an AR model with `ActionController::Parameters` now raises
1350
- an `ActiveModel::ForbiddenAttributesError` if the parameters include a
1351
- `type` field that has not been explicitly permitted. Previously, the
1352
- `type` field was simply ignored in the same situation.
1353
22
 
1354
- *Prem Sichanugrist*
23
+ ## Rails 5.1.6.1 (November 27, 2018) ##
1355
24
 
1356
- * PostgreSQL, `create_schema`, `drop_schema` and `rename_table` now quote
1357
- schema names.
25
+ * No changes.
1358
26
 
1359
- Fixes #21418.
1360
27
 
1361
- Example:
28
+ ## Rails 5.1.6 (March 29, 2018) ##
1362
29
 
1363
- create_schema("my.schema")
1364
- # CREATE SCHEMA "my.schema";
30
+ * MySQL: Support mysql2 0.5.x.
1365
31
 
1366
- *Yves Senn*
32
+ *Aaron Stone*
1367
33
 
1368
- * PostgreSQL, add `:if_exists` option to `#drop_schema`. This makes it
1369
- possible to drop a schema that might exist without raising an exception if
1370
- it doesn't.
34
+ * Apply time column precision on assignment.
1371
35
 
1372
- *Yves Senn*
36
+ PR #20317 changed the behavior of datetime columns so that when they
37
+ have a specified precision then on assignment the value is rounded to
38
+ that precision. This behavior is now applied to time columns as well.
1373
39
 
1374
- * Only try to nullify has_one target association if the record is persisted.
40
+ Fixes #30301.
1375
41
 
1376
- Fixes #21223.
42
+ *Andrew White*
1377
43
 
1378
- *Agis Anastasopoulos*
44
+ * Normalize time column values for SQLite database.
1379
45
 
1380
- * Uniqueness validator raises descriptive error when running on a persisted
1381
- record without primary key.
46
+ For legacy reasons, time columns in SQLite are stored as full datetimes
47
+ because until #24542 the quoting for time columns didn't remove the date
48
+ component. To ensure that values are consistent we now normalize the
49
+ date component to 2001-01-01 on reading and writing.
1382
50
 
1383
- Fixes #21304.
51
+ *Andrew White*
1384
52
 
1385
- *Yves Senn*
53
+ * Ensure that the date component is removed when quoting times.
1386
54
 
1387
- * Add a native JSON data type support in MySQL.
55
+ PR #24542 altered the quoting for time columns so that the date component
56
+ was removed however it only removed it when it was 2001-01-01. Now the
57
+ date component is removed irrespective of what the date is.
1388
58
 
1389
- Example:
59
+ *Andrew White*
1390
60
 
1391
- create_table :json_data_type do |t|
1392
- t.json :settings
1393
- end
61
+ * Fix that after commit callbacks on update does not triggered when optimistic locking is enabled.
1394
62
 
1395
63
  *Ryuta Kamizono*
1396
64
 
1397
- * Descriptive error message when fixtures contain a missing column.
1398
-
1399
- Fixes #21201.
1400
-
1401
- *Yves Senn*
1402
-
1403
- * `ActiveRecord::Tasks::PostgreSQLDatabaseTasks` fail if shellout to
1404
- postgresql commands (like `pg_dump`) is not successful.
1405
-
1406
- *Bryan Paxton*, *Nate Berkopec*
1407
-
1408
- * Add `ActiveRecord::Relation#in_batches` to work with records and relations
1409
- in batches.
1410
-
1411
- Available options are `of` (batch size), `load`, `start`, and `finish`.
1412
-
1413
- Examples:
1414
-
1415
- Person.in_batches.each_record(&:party_all_night!)
1416
- Person.in_batches.update_all(awesome: true)
1417
- Person.in_batches.delete_all
1418
- Person.in_batches.each do |relation|
1419
- relation.delete_all
1420
- sleep 10 # Throttles the delete queries
1421
- end
1422
-
1423
- Fixes #20933.
1424
-
1425
- *Sina Siadat*
1426
-
1427
- * Added methods for PostgreSQL geometric data types to use in migrations.
1428
-
1429
- Example:
1430
-
1431
- create_table :foo do |t|
1432
- t.line :foo_line
1433
- t.lseg :foo_lseg
1434
- t.box :foo_box
1435
- t.path :foo_path
1436
- t.polygon :foo_polygon
1437
- t.circle :foo_circle
1438
- end
1439
-
1440
- *Mehmet Emin İNAÇ*
1441
-
1442
- * Add `cache_key` to `ActiveRecord::Relation`.
65
+ * `ActiveRecord::Persistence#touch` does not work well when optimistic locking enabled and
66
+ `locking_column`, without default value, is null in the database.
1443
67
 
1444
- Example:
68
+ *bogdanvlviv*
1445
69
 
1446
- @users = User.where("name like ?", "%Alberto%")
1447
- @users.cache_key
1448
- # => "/users/query-5942b155a43b139f2471b872ac54251f-3-20150714212107656125000"
70
+ * Fix destroying existing object does not work well when optimistic locking enabled and
71
+ `locking column` is null in the database.
1449
72
 
1450
- *Alberto Fernández-Capel*
73
+ *bogdanvlviv*
1451
74
 
1452
- * Properly allow uniqueness validations on primary keys.
1453
75
 
1454
- Fixes #20966.
76
+ ## Rails 5.1.5 (February 14, 2018) ##
1455
77
 
1456
- *Sean Griffin*, *presskey*
78
+ * PostgreSQL: Allow pg-1.0 gem to be used with Active Record.
1457
79
 
1458
- * Don't raise an error if an association failed to destroy when `destroy` was
1459
- called on the parent (as opposed to `destroy!`).
80
+ *Lars Kanis*
1460
81
 
1461
- Fixes #20991.
82
+ * Fix `count(:all)` with eager loading and having an order other than the driving table.
1462
83
 
1463
- *Sean Griffin*
84
+ Fixes #31783.
1464
85
 
1465
- * `ActiveRecord::RecordNotFound` modified to store model name, primary_key and
1466
- id of the caller model. It allows the catcher of this exception to make
1467
- a better decision to what to do with it.
86
+ *Ryuta Kamizono*
1468
87
 
1469
- Example:
88
+ * Use `count(:all)` in `HasManyAssociation#count_records` to prevent invalid
89
+ SQL queries for association counting.
1470
90
 
1471
- class SomeAbstractController < ActionController::Base
1472
- rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404
91
+ *Klas Eskilson*
1473
92
 
1474
- private def redirect_to_404(e)
1475
- return redirect_to(posts_url) if e.model == 'Post'
1476
- raise
1477
- end
1478
- end
93
+ * Fix to invoke callbacks when using `update_attribute`.
1479
94
 
1480
- *Sameer Rahmani*
95
+ *Mike Busch*
1481
96
 
1482
- * Deprecate the keys for association `restrict_dependent_destroy` errors in favor
1483
- of new key names.
97
+ * Fix `count(:all)` to correctly work `distinct` with custom SELECT list.
1484
98
 
1485
- Previously `has_one` and `has_many` associations were using the
1486
- `one` and `many` keys respectively. Both of these keys have special
1487
- meaning in I18n (they are considered to be pluralizations) so by
1488
- renaming them to `has_one` and `has_many` we make the messages more explicit
1489
- and most importantly they don't clash with linguistical systems that need to
1490
- validate translation keys (and their pluralizations).
99
+ *Ryuta Kamizono*
1491
100
 
1492
- The `:'restrict_dependent_destroy.one'` key should be replaced with
1493
- `:'restrict_dependent_destroy.has_one'`, and `:'restrict_dependent_destroy.many'`
1494
- with `:'restrict_dependent_destroy.has_many'`.
101
+ * Fix conflicts `counter_cache` with `touch: true` by optimistic locking.
1495
102
 
1496
- *Roque Pinel*, *Christopher Dell*
103
+ ```
104
+ # create_table :posts do |t|
105
+ # t.integer :comments_count, default: 0
106
+ # t.integer :lock_version
107
+ # t.timestamps
108
+ # end
109
+ class Post < ApplicationRecord
110
+ end
111
+
112
+ # create_table :comments do |t|
113
+ # t.belongs_to :post
114
+ # end
115
+ class Comment < ApplicationRecord
116
+ belongs_to :post, touch: true, counter_cache: true
117
+ end
118
+ ```
1497
119
 
1498
- * Fix state being carried over from previous transaction.
120
+ Before:
121
+ ```
122
+ post = Post.create!
123
+ # => begin transaction
124
+ INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
125
+ VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
126
+ commit transaction
127
+
128
+ comment = Comment.create!(post: post)
129
+ # => begin transaction
130
+ INSERT INTO "comments" ("post_id") VALUES (1)
131
+
132
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
133
+ "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
134
+
135
+ UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
136
+ "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
137
+ rollback transaction
138
+ # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
139
+
140
+ Comment.take.destroy!
141
+ # => begin transaction
142
+ DELETE FROM "comments" WHERE "comments"."id" = 1
143
+
144
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
145
+ "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
146
+
147
+ UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
148
+ "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
149
+ rollback transaction
150
+ # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
151
+ ```
1499
152
 
1500
- Considering the following example where `name` is a required attribute.
1501
- Before we had `new_record?` returning `true` for a persisted record:
153
+ After:
154
+ ```
155
+ post = Post.create!
156
+ # => begin transaction
157
+ INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
158
+ VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
159
+ commit transaction
160
+
161
+ comment = Comment.create!(post: post)
162
+ # => begin transaction
163
+ INSERT INTO "comments" ("post_id") VALUES (1)
164
+
165
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
166
+ "lock_version" = COALESCE("lock_version", 0) + 1,
167
+ "updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
168
+ commit transaction
169
+
170
+ comment.destroy!
171
+ # => begin transaction
172
+ DELETE FROM "comments" WHERE "comments"."id" = 1
173
+
174
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
175
+ "lock_version" = COALESCE("lock_version", 0) + 1,
176
+ "updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
177
+ commit transaction
178
+ ```
1502
179
 
1503
- author = Author.create! name: 'foo'
1504
- author.name = nil
1505
- author.save # => false
1506
- author.new_record? # => true
180
+ Fixes #31199.
1507
181
 
1508
- Fixes #20824.
182
+ *bogdanvlviv*
1509
183
 
1510
- *Roque Pinel*
184
+ * Query cache was unavailable when entering the `ActiveRecord::Base.cache` block
185
+ without being connected.
1511
186
 
1512
- * Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
1513
- when validating associations.
187
+ *Tsukasa Oishi*
1514
188
 
1515
- Fixes #20882.
189
+ * Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong
190
+ ar_internal_metadata's data for a test database.
1516
191
 
1517
- *Sean Griffin*
192
+ Before:
193
+ ```
194
+ $ RAILS_ENV=test rails dbconsole
195
+ > SELECT * FROM ar_internal_metadata;
196
+ key|value|created_at|updated_at
197
+ environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
198
+ ```
1518
199
 
1519
- * Fix a bug where counter_cache doesn't always work with polymorphic
1520
- relations.
200
+ After:
201
+ ```
202
+ $ RAILS_ENV=test rails dbconsole
203
+ > SELECT * FROM ar_internal_metadata;
204
+ key|value|created_at|updated_at
205
+ environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
206
+ ```
1521
207
 
1522
- Fixes #16407.
208
+ Fixes #26731.
1523
209
 
1524
- *Stefan Kanev*, *Sean Griffin*
210
+ *bogdanvlviv*
1525
211
 
1526
- * Ensure that cyclic associations with autosave don't cause duplicate errors
1527
- to be added to the parent record.
212
+ * Fix longer sequence name detection for serial columns.
1528
213
 
1529
- Fixes #20874.
214
+ Fixes #28332.
1530
215
 
1531
- *Sean Griffin*
216
+ *Ryuta Kamizono*
1532
217
 
1533
- * Ensure that `ActionController::Parameters` can still be passed to nested
1534
- attributes.
218
+ * MySQL: Don't lose `auto_increment: true` in the `db/schema.rb`.
1535
219
 
1536
- Fixes #20922.
220
+ Fixes #30894.
1537
221
 
1538
- *Sean Griffin*
222
+ *Ryuta Kamizono*
1539
223
 
1540
- * Deprecate force association reload by passing a truthy argument to
1541
- association method.
224
+ * Fix `COUNT(DISTINCT ...)` for `GROUP BY` with `ORDER BY` and `LIMIT`.
1542
225
 
1543
- For collection association, you can call `#reload` on association proxy to
1544
- force a reload:
226
+ Fixes #30886.
1545
227
 
1546
- @user.posts.reload # Instead of @user.posts(true)
228
+ *Ryuta Kamizono*
1547
229
 
1548
- For singular association, you can call `#reload` on the parent object to
1549
- clear its association cache then call the association method:
1550
230
 
1551
- @user.reload.profile # Instead of @user.profile(true)
231
+ ## Rails 5.1.4 (September 07, 2017) ##
1552
232
 
1553
- Passing a truthy argument to force association to reload will be removed in
1554
- Rails 5.1.
233
+ * No changes.
1555
234
 
1556
- *Prem Sichanugrist*
1557
235
 
1558
- * Replaced `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch`
1559
- from the concurrent-ruby gem.
236
+ ## Rails 5.1.4.rc1 (August 24, 2017) ##
1560
237
 
1561
- *Jerry D'Antonio*
238
+ * Ensure `sum` honors `distinct` on `has_many :through` associations
1562
239
 
1563
- * Fix through associations using scopes having the scope merged multiple
1564
- times.
240
+ Fixes #16791
1565
241
 
1566
- Fixes #20721.
1567
- Fixes #20727.
242
+ *Aaron Wortham
1568
243
 
1569
- *Sean Griffin*
244
+ * Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing select list.
1570
245
 
1571
- * `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
1572
- other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
246
+ *Ryuta Kamizono*
1573
247
 
1574
- Fixes #20743.
248
+ * Fix `unscoped(where: [columns])` removing the wrong bind values
1575
249
 
1576
- *Yves Senn*
250
+ When the `where` is called on a relation after a `or`, unscoping the column of that later `where`, it removed
251
+ bind values used by the `or` instead.
1577
252
 
1578
- * Add alternate syntax to make `change_column_default` reversible.
253
+ ```
254
+ Post.where(id: 1).or(Post.where(id: 2)).where(foo: 3).unscope(where: :foo).to_sql
255
+ # Currently:
256
+ # SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
257
+ # With fix:
258
+ # SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
259
+ ```
1579
260
 
1580
- User can pass in `:from` and `:to` to make `change_column_default` command
1581
- become reversible.
261
+ *Maxime Handfield Lapointe*
1582
262
 
1583
- Example:
263
+ * When a `has_one` association is destroyed by `dependent: destroy`,
264
+ `destroyed_by_association` will now be set to the reflection, matching the
265
+ behaviour of `has_many` associations.
1584
266
 
1585
- change_column_default :posts, :status, from: nil, to: "draft"
1586
- change_column_default :users, :authorized, from: true, to: false
267
+ *Lisa Ugray*
1587
268
 
1588
- *Prem Sichanugrist*
1589
269
 
1590
- * Prevent error when using `force_reload: true` on an unassigned polymorphic
1591
- belongs_to association.
270
+ ## Rails 5.1.3 (August 03, 2017) ##
1592
271
 
1593
- Fixes #20426.
272
+ * No changes.
1594
273
 
1595
- *James Dabbs*
1596
274
 
1597
- * Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
1598
- a wrong type to a namespaced association.
275
+ ## Rails 5.1.3.rc3 (July 31, 2017) ##
1599
276
 
1600
- Fixes #20545.
277
+ * No changes.
1601
278
 
1602
- *Diego Carrion*
1603
279
 
1604
- * `validates_absence_of` respects `marked_for_destruction?`.
280
+ ## Rails 5.1.3.rc2 (July 25, 2017) ##
1605
281
 
1606
- Fixes #20449.
282
+ * No changes.
1607
283
 
1608
- *Yves Senn*
1609
284
 
1610
- * Include the `Enumerable` module in `ActiveRecord::Relation`
285
+ ## Rails 5.1.3.rc1 (July 19, 2017) ##
1611
286
 
1612
- *Sean Griffin*, *bogdan*
287
+ * `Relation#joins` is no longer affected by the target model's
288
+ `current_scope`, with the exception of `unscoped`.
1613
289
 
1614
- * Use `Enumerable#sum` in `ActiveRecord::Relation` if a block is given.
290
+ Fixes #29338.
1615
291
 
1616
292
  *Sean Griffin*
1617
293
 
1618
- * Let `WITH` queries (Common Table Expressions) be explainable.
294
+ * Previously, when building records using a `has_many :through` association,
295
+ if the child records were deleted before the parent was saved, they would
296
+ still be persisted. Now, if child records are deleted before the parent is saved
297
+ on a `has_many :through` association, the child records will not be persisted.
1619
298
 
1620
- *Vladimir Kochnev*
299
+ *Tobias Kraze*
1621
300
 
1622
- * Make `remove_index :table, :column` reversible.
1623
301
 
1624
- *Yves Senn*
1625
-
1626
- * Fixed an error which would occur in dirty checking when calling
1627
- `update_attributes` from a getter.
302
+ ## Rails 5.1.2 (June 26, 2017) ##
1628
303
 
1629
- Fixes #20531.
304
+ * Restore previous behavior of collection proxies: their values can have
305
+ methods stubbed, and they respect extension modules applied by a default
306
+ scope.
1630
307
 
1631
- *Sean Griffin*
308
+ *Ryuta Kamizono*
1632
309
 
1633
- * Make `remove_foreign_key` reversible. Any foreign key options must be
1634
- specified, similar to `remove_column`.
310
+ * Loading model schema from database is now thread-safe.
1635
311
 
1636
- *Aster Ryan*
312
+ Fixes #28589.
1637
313
 
1638
- * Add `:_prefix` and `:_suffix` options to `enum` definition.
314
+ *Vikrant Chaudhary*, *David Abdemoulaie*
1639
315
 
1640
- Fixes #17511, #17415.
1641
316
 
1642
- *Igor Kapkov*
317
+ ## Rails 5.1.1 (May 12, 2017) ##
1643
318
 
1644
- * Correctly handle decimal arrays with defaults in the schema dumper.
319
+ * Add type caster to `RuntimeReflection#alias_name`
1645
320
 
1646
- Fixes #20515.
321
+ Fixes #28959.
1647
322
 
1648
- *Sean Griffin*, *jmondo*
323
+ *Jon Moss*
1649
324
 
1650
- * Deprecate the PostgreSQL `:point` type in favor of a new one which will return
1651
- `Point` objects instead of an `Array`
1652
325
 
1653
- *Sean Griffin*
326
+ ## Rails 5.1.0 (April 27, 2017) ##
1654
327
 
1655
- * Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
1656
- as columns.
328
+ * Quote database name in db:create grant statement (when database_user does not have access to create the database).
1657
329
 
1658
- Fixes #20360.
330
+ *Rune Philosof*
1659
331
 
1660
- *Sean Griffin*
332
+ * When multiple threads are sharing a database connection inside a test using
333
+ transactional fixtures, a nested transaction will temporarily lock the
334
+ connection to the current thread, forcing others to wait.
1661
335
 
1662
- * Do not set `sql_mode` if `strict: :default` is specified.
336
+ Fixes #28197.
1663
337
 
1664
- # config/database.yml
1665
- production:
1666
- adapter: mysql2
1667
- database: foo_prod
1668
- user: foo
1669
- strict: :default
338
+ *Matthew Draper*
1670
339
 
1671
- *Ryuta Kamizono*
340
+ * Load only needed records on `ActiveRecord::Relation#inspect`.
1672
341
 
1673
- * Allow proc defaults to be passed to the attributes API. See documentation
1674
- for examples.
342
+ Instead of loading all records and returning only a subset of those, just
343
+ load the records as needed.
1675
344
 
1676
- *Sean Griffin*, *Kir Shatrov*
345
+ Fixes #25537.
1677
346
 
1678
- * SQLite: `:collation` support for string and text columns.
347
+ *Hendy Tanata*
1679
348
 
1680
- Example:
349
+ * Remove comments from structure.sql when using postgresql adapter to avoid
350
+ version-specific parts of the file.
1681
351
 
1682
- create_table :foo do |t|
1683
- t.string :string_nocase, collation: 'NOCASE'
1684
- t.text :text_rtrim, collation: 'RTRIM'
1685
- end
352
+ Fixes #28153.
1686
353
 
1687
- add_column :foo, :title, :string, collation: 'RTRIM'
354
+ *Ari Pollak*
1688
355
 
1689
- change_column :foo, :title, :string, collation: 'NOCASE'
356
+ * Add `:default` option to `belongs_to`.
1690
357
 
1691
- *Akshay Vishnoi*
358
+ Use it to specify that an association should be initialized with a particular
359
+ record before validation. For example:
1692
360
 
1693
- * Allow the use of symbols or strings to specify enum values in test
1694
- fixtures:
361
+ # Before
362
+ belongs_to :account
363
+ before_validation -> { self.account ||= Current.account }
1695
364
 
1696
- awdr:
1697
- title: "Agile Web Development with Rails"
1698
- status: :proposed
365
+ # After
366
+ belongs_to :account, default: -> { Current.account }
1699
367
 
1700
368
  *George Claghorn*
1701
369
 
1702
- * Clear query cache when `ActiveRecord::Base#reload` is called.
1703
-
1704
- *Shane Hender, Pierre Nespo*
1705
-
1706
- * Include stored procedures and function on the MySQL structure dump.
1707
-
1708
- *Jonathan Worek*
1709
-
1710
- * Pass `:extend` option for `has_and_belongs_to_many` associations to the
1711
- underlying `has_many :through`.
1712
-
1713
- *Jaehyun Shin*
1714
-
1715
- * Deprecate `Relation#uniq` use `Relation#distinct` instead.
1716
-
1717
- See #9683.
1718
-
1719
- *Yves Senn*
1720
-
1721
- * Allow single table inheritance instantiation to work when storing
1722
- demodulized class names.
1723
-
1724
- *Alex Robbin*
1725
-
1726
- * Correctly pass MySQL options when using `structure_dump` or
1727
- `structure_load`.
1728
-
1729
- Specifically, it fixes an issue when using SSL authentication.
1730
-
1731
- *Alex Coomans*
1732
-
1733
- * Correctly dump `:options` on `create_table` for MySQL.
370
+ * Deprecate `Migrator.schema_migrations_table_name`.
1734
371
 
1735
372
  *Ryuta Kamizono*
1736
373
 
1737
- * PostgreSQL: `:collation` support for string and text columns.
1738
-
1739
- Example:
374
+ * Fix select with block doesn't return newly built records in has_many association.
1740
375
 
1741
- create_table :foos do |t|
1742
- t.string :string_en, collation: 'en_US.UTF-8'
1743
- t.text :text_ja, collation: 'ja_JP.UTF-8'
1744
- end
376
+ Fixes #28348.
1745
377
 
1746
378
  *Ryuta Kamizono*
1747
379
 
1748
- * Remove `ActiveRecord::Serialization::XmlSerializer` from core.
1749
-
1750
- *Zachary Scott*
1751
-
1752
- * Make `unscope` aware of "less than" and "greater than" conditions.
1753
-
1754
- *TAKAHASHI Kazuaki*
1755
-
1756
- * `find_by` and `find_by!` raise `ArgumentError` when called without
1757
- arguments.
1758
-
1759
- *Kohei Suzuki*
1760
-
1761
- * Revert behavior of `db:schema:load` back to loading the full
1762
- environment. This ensures that initializers are run.
1763
-
1764
- Fixes #19545.
1765
-
1766
- *Yves Senn*
1767
-
1768
- * Fix missing index when using `timestamps` with the `index` option.
1769
-
1770
- The `index` option used with `timestamps` should be passed to both
1771
- `column` definitions for `created_at` and `updated_at` rather than just
1772
- the first.
1773
-
1774
- *Paul Mucur*
380
+ * Check whether `Rails.application` defined before calling it
1775
381
 
1776
- * Rename `:class` to `:anonymous_class` in association options.
382
+ In #27674 we changed the migration generator to generate migrations at the
383
+ path defined in `Rails.application.config.paths` however the code checked
384
+ for the presence of the `Rails` constant but not the `Rails.application`
385
+ method which caused problems when using Active Record and generators outside
386
+ of the context of a Rails application.
1777
387
 
1778
- Fixes #19659.
388
+ Fixes #28325.
1779
389
 
1780
390
  *Andrew White*
1781
391
 
1782
- * Autosave existing records on a has many through association when the parent
1783
- is new.
1784
-
1785
- Fixes #19782.
1786
-
1787
- *Sean Griffin*
392
+ * Fix `deserialize` with JSON array.
1788
393
 
1789
- * Fixed a bug where uniqueness validations would error on out of range values,
1790
- even if an validation should have prevented it from hitting the database.
394
+ Fixes #28285.
1791
395
 
1792
- *Andrey Voronkov*
396
+ *Ryuta Kamizono*
1793
397
 
1794
- * MySQL: `:charset` and `:collation` support for string and text columns.
398
+ * Fix `rake db:schema:load` with subdirectories.
1795
399
 
1796
- Example:
400
+ *Ryuta Kamizono*
1797
401
 
1798
- create_table :foos do |t|
1799
- t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin'
1800
- t.text :text_ascii, charset: 'ascii'
1801
- end
402
+ * Fix `rake db:migrate:status` with subdirectories.
1802
403
 
1803
404
  *Ryuta Kamizono*
1804
405
 
1805
- * Foreign key related methods in the migration DSL respect
1806
- `ActiveRecord::Base.pluralize_table_names = false`.
1807
-
1808
- Fixes #19643.
406
+ * Don't share options between reference id and type columns
1809
407
 
1810
- *Mehmet Emin İNAÇ*
408
+ When using a polymorphic reference column in a migration, sharing options
409
+ between the two columns doesn't make sense since they are different types.
410
+ The `reference_id` column is usually an integer and the `reference_type`
411
+ column a string so options like `unsigned: true` will result in an invalid
412
+ table definition.
1811
413
 
1812
- * Reduce memory usage from loading types on PostgreSQL.
414
+ *Ryuta Kamizono*
1813
415
 
1814
- Fixes #19578.
416
+ * Use `max_identifier_length` for `index_name_length` in PostgreSQL adapter.
1815
417
 
1816
- *Sean Griffin*
418
+ *Ryuta Kamizono*
1817
419
 
1818
- * Add `config.active_record.warn_on_records_fetched_greater_than` option.
420
+ * Deprecate `supports_migrations?` on connection adapters.
1819
421
 
1820
- When set to an integer, a warning will be logged whenever a result set
1821
- larger than the specified size is returned by a query.
422
+ *Ryuta Kamizono*
1822
423
 
1823
- Fixes #16463.
424
+ * Fix regression of #1969 with SELECT aliases in HAVING clause.
1824
425
 
1825
- *Jason Nochlin*
426
+ *Eugene Kenny*
1826
427
 
1827
- * Ignore `.psqlrc` when loading database structure.
428
+ * Deprecate using `#quoted_id` in quoting.
1828
429
 
1829
- *Jason Weathered*
430
+ *Ryuta Kamizono*
1830
431
 
1831
- * Fix referencing wrong table aliases while joining tables of has many through
1832
- association (only when calling calculation methods).
432
+ * Fix `wait_timeout` to configurable for mysql2 adapter.
1833
433
 
1834
- Fixes #19276.
434
+ Fixes #26556.
1835
435
 
1836
- *pinglamb*
436
+ *Ryuta Kamizono*
1837
437
 
1838
- * Correctly persist a serialized attribute that has been returned to
1839
- its default value by an in-place modification.
438
+ * Correctly dump native timestamp types for MySQL.
1840
439
 
1841
- Fixes #19467.
440
+ The native timestamp type in MySQL is different from datetime type.
441
+ Internal representation of the timestamp type is UNIX time, This means
442
+ that timestamp columns are affected by time zone.
1842
443
 
1843
- *Matthew Draper*
444
+ > SET time_zone = '+00:00';
445
+ Query OK, 0 rows affected (0.00 sec)
1844
446
 
1845
- * Fix generating the schema file when using PostgreSQL `BigInt[]` data type.
1846
- Previously the `limit: 8` was not coming through, and this caused it to
1847
- become `Int[]` data type after rebuilding from the schema.
447
+ > INSERT INTO time_with_zone(ts,dt) VALUES (NOW(),NOW());
448
+ Query OK, 1 row affected (0.02 sec)
1848
449
 
1849
- Fixes #19420.
450
+ > SELECT * FROM time_with_zone;
451
+ +---------------------+---------------------+
452
+ | ts | dt |
453
+ +---------------------+---------------------+
454
+ | 2016-02-07 22:11:44 | 2016-02-07 22:11:44 |
455
+ +---------------------+---------------------+
456
+ 1 row in set (0.00 sec)
1850
457
 
1851
- *Jake Waller*
458
+ > SET time_zone = '-08:00';
459
+ Query OK, 0 rows affected (0.00 sec)
1852
460
 
1853
- * Reuse the `CollectionAssociation#reader` cache when the foreign key is
1854
- available prior to save.
461
+ > SELECT * FROM time_with_zone;
462
+ +---------------------+---------------------+
463
+ | ts | dt |
464
+ +---------------------+---------------------+
465
+ | 2016-02-07 14:11:44 | 2016-02-07 22:11:44 |
466
+ +---------------------+---------------------+
467
+ 1 row in set (0.00 sec)
1855
468
 
1856
- *Ben Woosley*
469
+ *Ryuta Kamizono*
1857
470
 
1858
- * Add `config.active_record.dump_schemas` to fix `db:structure:dump`
1859
- when using schema_search_path and PostgreSQL extensions.
471
+ * All integer-like PKs are autoincrement unless they have an explicit default.
1860
472
 
1861
- Fixes #17157.
473
+ *Matthew Draper*
1862
474
 
1863
- *Ryan Wallace*
475
+ * Omit redundant `using: :btree` for schema dumping.
1864
476
 
1865
- * Renaming `use_transactional_fixtures` to `use_transactional_tests` for clarity.
477
+ *Ryuta Kamizono*
1866
478
 
1867
- Fixes #18864.
479
+ * Deprecate passing `default` to `index_name_exists?`.
1868
480
 
1869
- *Brandon Weiss*
481
+ *Ryuta Kamizono*
1870
482
 
1871
- * Increase pg gem version requirement to `~> 0.18`. Earlier versions of the
1872
- pg gem are known to have problems with Ruby 2.2.
483
+ * PostgreSQL: schema dumping support for interval and OID columns.
1873
484
 
1874
- *Matt Brictson*
485
+ *Ryuta Kamizono*
1875
486
 
1876
- * Correctly dump `serial` and `bigserial`.
487
+ * Deprecate `supports_primary_key?` on connection adapters since it's
488
+ been long unused and unsupported.
1877
489
 
1878
490
  *Ryuta Kamizono*
1879
491
 
1880
- * Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
492
+ * Make `table_name=` reset current statement cache,
493
+ so queries are not run against the previous table name.
1881
494
 
1882
- *James Cox*
495
+ *namusyaka*
1883
496
 
1884
- * Don't enroll records in the transaction if they don't have commit callbacks.
1885
- This was causing a memory leak when creating many records inside a transaction.
497
+ * Allow `ActiveRecord::Base#as_json` to be passed a frozen Hash.
1886
498
 
1887
- Fixes #15549.
499
+ *Isaac Betesh*
1888
500
 
1889
- *Will Bryant*, *Aaron Patterson*
501
+ * Fix inspection behavior when the :id column is not primary key.
1890
502
 
1891
- * Correctly create through records when created on a has many through
1892
- association when using `where`.
503
+ *namusyaka*
1893
504
 
1894
- Fixes #19073.
505
+ * Deprecate locking records with unpersisted changes.
1895
506
 
1896
- *Sean Griffin*
507
+ *Marc Schütz*
1897
508
 
1898
- * Add `SchemaMigration.create_table` support for any unicode charsets with MySQL.
509
+ * Remove deprecated behavior that halts callbacks when the return is false.
1899
510
 
1900
- *Ryuta Kamizono*
511
+ *Rafael Mendonça França*
1901
512
 
1902
- * PostgreSQL no longer disables user triggers if system triggers can't be
1903
- disabled. Disabling user triggers does not fulfill what the method promises.
1904
- Rails currently requires superuser privileges for this method.
513
+ * Deprecate `ColumnDumper#migration_keys`.
1905
514
 
1906
- If you absolutely rely on this behavior, consider patching
1907
- `disable_referential_integrity`.
515
+ *Ryuta Kamizono*
1908
516
 
1909
- *Yves Senn*
517
+ * Fix `association_primary_key_type` for reflections with symbol primary key.
1910
518
 
1911
- * Restore aborted transaction state when `disable_referential_integrity` fails
1912
- due to missing permissions.
519
+ Fixes #27864.
1913
520
 
1914
- *Toby Ovod-Everett*, *Yves Senn*
521
+ *Daniel Colson*
1915
522
 
1916
- * In PostgreSQL, print a warning message if `disable_referential_integrity`
1917
- fails due to missing permissions.
523
+ * Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+.
1918
524
 
1919
- *Andrey Nering*, *Yves Senn*
525
+ MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html
526
+ MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/
1920
527
 
1921
- * Allow a `:limit` option for MySQL bigint primary key support.
528
+ Declare virtual columns with `t.virtual name, type: …, as: "expression"`.
529
+ Pass `stored: true` to persist the generated value (false by default).
1922
530
 
1923
531
  Example:
1924
532
 
1925
- create_table :foos, id: :primary_key, limit: 8 do |t|
533
+ create_table :generated_columns do |t|
534
+ t.string :name
535
+ t.virtual :upper_name, type: :string, as: "UPPER(name)"
536
+ t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true
537
+ t.index :name_length # May be indexed, too!
1926
538
  end
1927
539
 
1928
- # or
540
+ *Ryuta Kamizono*
1929
541
 
1930
- create_table :foos, id: false do |t|
1931
- t.primary_key :id, limit: 8
1932
- end
542
+ * Deprecate `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.
1933
543
 
1934
544
  *Ryuta Kamizono*
1935
545
 
1936
- * `belongs_to` will now trigger a validation error by default if the association is not present.
1937
- You can turn this off on a per-association basis with `optional: true`.
1938
- (Note this new default only applies to new Rails apps that will be generated with
1939
- `config.active_record.belongs_to_required_by_default = true` in initializer.)
546
+ * Support foreign key creation for SQLite3.
1940
547
 
1941
- *Josef Šimánek*
1942
-
1943
- * Fixed `ActiveRecord::Relation#becomes!` and `changed_attributes` issues for type
1944
- columns.
548
+ *Ryuta Kamizono*
1945
549
 
1946
- Fixes #17139.
550
+ * Place generated migrations into the path set by `config.paths["db/migrate"]`.
1947
551
 
1948
- *Miklos Fazekas*
552
+ *Kevin Glowacz*
1949
553
 
1950
- * Format the time string according to the precision of the time column.
554
+ * Raise `ActiveRecord::InvalidForeignKey` when a foreign key constraint fails on SQLite3.
1951
555
 
1952
556
  *Ryuta Kamizono*
1953
557
 
1954
- * Allow a `:precision` option for time type columns.
558
+ * Add the touch option to `#increment!` and `#decrement!`.
1955
559
 
1956
- *Ryuta Kamizono*
560
+ *Hiroaki Izu*
1957
561
 
1958
- * Add `ActiveRecord::Base.suppress` to prevent the receiver from being saved
1959
- during the given block.
562
+ * Deprecate passing a class to the `class_name` because it eagerloads more classes than
563
+ necessary and potentially creates circular dependencies.
1960
564
 
1961
- For example, here's a pattern of creating notifications when new comments
1962
- are posted. (The notification may in turn trigger an email, a push
1963
- notification, or just appear in the UI somewhere):
565
+ *Kir Shatrov*
1964
566
 
1965
- class Comment < ActiveRecord::Base
1966
- belongs_to :commentable, polymorphic: true
1967
- after_create -> { Notification.create! comment: self,
1968
- recipients: commentable.recipients }
1969
- end
567
+ * Raise error when has_many through is defined before through association.
1970
568
 
1971
- That's what you want the bulk of the time. A new comment creates a new
1972
- Notification. There may be edge cases where you don't want that, like
1973
- when copying a commentable and its comments, in which case write a
1974
- concern with something like this:
569
+ Fixes #26834.
1975
570
 
1976
- module Copyable
1977
- def copy_to(destination)
1978
- Notification.suppress do
1979
- # Copy logic that creates new comments that we do not want triggering
1980
- # notifications.
1981
- end
1982
- end
1983
- end
571
+ *Chris Holmes*
1984
572
 
1985
- *Michael Ryan*
573
+ * Deprecate passing `name` to `indexes`.
1986
574
 
1987
- * `:time` option added for `#touch`.
575
+ *Ryuta Kamizono*
1988
576
 
1989
- Fixes #18905.
577
+ * Remove deprecated tasks: `db:test:clone`, `db:test:clone_schema`, `db:test:clone_structure`.
1990
578
 
1991
- *Hyonjee Joo*
579
+ *Rafel Mendonça França*
1992
580
 
1993
- * Add `foreign_key_exists?` method.
581
+ * Compare deserialized values for `PostgreSQL::OID::Hstore` types when
582
+ calling `ActiveRecord::Dirty#changed_in_place?`.
1994
583
 
1995
- *Tõnis Simo*
584
+ Fixes #27502.
1996
585
 
1997
- * Use SQL COUNT and LIMIT 1 queries for `none?` and `one?` methods
1998
- if no block or limit is given, instead of loading the entire
1999
- collection into memory. This applies to relations (e.g. `User.all`)
2000
- as well as associations (e.g. `account.users`)
586
+ *Jon Moss*
2001
587
 
2002
- # Before:
588
+ * Raise `ArgumentError` when passing an `ActiveRecord::Base` instance to `.find`,
589
+ `.exists?` and `.update`.
2003
590
 
2004
- users.none?
2005
- # SELECT "users".* FROM "users"
591
+ *Rafael Mendonça França*
2006
592
 
2007
- users.one?
2008
- # SELECT "users".* FROM "users"
593
+ * Respect precision option for arrays of timestamps.
2009
594
 
2010
- # After:
595
+ Fixes #27514.
2011
596
 
2012
- users.none?
2013
- # SELECT 1 AS one FROM "users" LIMIT 1
597
+ *Sean Griffin*
2014
598
 
2015
- users.one?
2016
- # SELECT COUNT(*) FROM "users"
599
+ * Optimize slow model instantiation when using STI and `store_full_sti_class = false` option.
2017
600
 
2018
- *Eugene Gilburg*
601
+ *Konstantin Lazarev*
2019
602
 
2020
- * Have `enum` perform type casting consistently with the rest of Active
2021
- Record, such as `where`.
603
+ * Add `touch` option to counter cache modifying methods.
2022
604
 
2023
- *Sean Griffin*
605
+ Works when updating, resetting, incrementing and decrementing counters:
2024
606
 
2025
- * `scoping` no longer pollutes the current scope of sibling classes when using
2026
- STI.
607
+ # Touches `updated_at`/`updated_on`.
608
+ Topic.increment_counter(:messages_count, 1, touch: true)
609
+ Topic.decrement_counter(:messages_count, 1, touch: true)
2027
610
 
2028
- Fixes #18806.
611
+ # Touches `last_discussed_at`.
612
+ Topic.reset_counters(18, :messages, touch: :last_discussed_at)
2029
613
 
2030
- Example:
614
+ # Touches `updated_at` and `last_discussed_at`.
615
+ Topic.update_counters(18, messages_count: 5, touch: %i( updated_at last_discussed_at ))
2031
616
 
2032
- StiOne.none.scoping do
2033
- StiTwo.all
2034
- end
617
+ Fixes #26724.
2035
618
 
619
+ *Jarred Trost*
2036
620
 
2037
- *Sean Griffin*
621
+ * Remove deprecated `#uniq`, `#uniq!`, and `#uniq_value`.
2038
622
 
2039
- * `remove_reference` with `foreign_key: true` removes the foreign key before
2040
- removing the column. This fixes a bug where it was not possible to remove
2041
- the column on MySQL.
623
+ *Ryuta Kamizono*
2042
624
 
2043
- Fixes #18664.
625
+ * Remove deprecated `#insert_sql`, `#update_sql`, and `#delete_sql`.
2044
626
 
2045
- *Yves Senn*
627
+ *Ryuta Kamizono*
2046
628
 
2047
- * `find_in_batches` now accepts an `:finish` parameter that complements the `:start`
2048
- parameter to specify where to stop batch processing.
629
+ * Remove deprecated `#use_transactional_fixtures` configuration.
2049
630
 
2050
- *Vipul A M*
631
+ *Rafael Mendonça França*
2051
632
 
2052
- * Fix a rounding problem for PostgreSQL timestamp columns.
633
+ * Remove deprecated `#raise_in_transactional_callbacks` configuration.
2053
634
 
2054
- If a timestamp column has a precision specified, it needs to
2055
- format according to that.
635
+ *Rafael Mendonça França*
2056
636
 
2057
- *Ryuta Kamizono*
637
+ * Remove deprecated `#load_schema_for`.
2058
638
 
2059
- * Respect the database default charset for `schema_migrations` table.
639
+ *Rafael Mendonça França*
2060
640
 
2061
- The charset of `version` column in `schema_migrations` table depends
2062
- on the database default charset and collation rather than the encoding
2063
- of the connection.
641
+ * Remove deprecated conditions parameter from `#destroy_all` and `#delete_all`.
2064
642
 
2065
- *Ryuta Kamizono*
643
+ *Rafael Mendonça França*
2066
644
 
2067
- * Raise `ArgumentError` when passing `nil` or `false` to `Relation#merge`.
645
+ * Remove deprecated support to passing arguments to `#select` when a block is provided.
2068
646
 
2069
- These are not valid values to merge in a relation, so it should warn users
2070
- early.
647
+ *Rafael Mendonça França*
648
+
649
+ * Remove deprecated support to query using commas on LIMIT.
2071
650
 
2072
651
  *Rafael Mendonça França*
2073
652
 
2074
- * Use `SCHEMA` instead of `DB_STRUCTURE` for specifying a structure file.
653
+ * Remove deprecated support to passing a class as a value in a query.
2075
654
 
2076
- This makes the `db:structure` tasks consistent with `test:load_structure`.
655
+ *Rafael Mendonça França*
2077
656
 
2078
- *Dieter Komendera*
657
+ * Raise `ActiveRecord::IrreversibleOrderError` when using `last` with an irreversible
658
+ order.
2079
659
 
2080
- * Respect custom primary keys for associations when calling `Relation#where`
660
+ *Rafael Mendonça França*
2081
661
 
2082
- Fixes #18813.
662
+ * Raise when a `has_many :through` association has an ambiguous reflection name.
2083
663
 
2084
- *Sean Griffin*
664
+ *Rafael Mendonça França*
2085
665
 
2086
- * Fix several edge cases which could result in a counter cache updating
2087
- twice or not updating at all for `has_many` and `has_many :through`.
666
+ * Raise when `ActiveRecord::Migration` is inherited from directly.
2088
667
 
2089
- Fixes #10865.
668
+ *Rafael Mendonça França*
2090
669
 
2091
- *Sean Griffin*
670
+ * Remove deprecated `original_exception` argument in `ActiveRecord::StatementInvalid#initialize`
671
+ and `ActiveRecord::StatementInvalid#original_exception`.
2092
672
 
2093
- * Foreign keys added by migrations were given random, generated names. This
2094
- meant a different `structure.sql` would be generated every time a developer
2095
- ran migrations on their machine.
673
+ *Rafael Mendonça França*
2096
674
 
2097
- The generated part of foreign key names is now a hash of the table name and
2098
- column name, which is consistent every time you run the migration.
675
+ * `#tables` and `#table_exists?` return only tables and not views.
2099
676
 
2100
- *Chris Sinjakli*
677
+ All the deprecations on those methods were removed.
2101
678
 
2102
- * Fix n+1 query problem when eager loading nil associations (fixes #18312)
679
+ *Rafael Mendonça França*
2103
680
 
2104
- *Sammy Larbi*
681
+ * Remove deprecated `name` argument from `#tables`.
2105
682
 
2106
- * Change the default error message from `can't be blank` to `must exist` for
2107
- the presence validator of the `:required` option on `belongs_to`/`has_one`
2108
- associations.
683
+ *Rafael Mendonça França*
2109
684
 
2110
- *Henrik Nygren*
685
+ * Remove deprecated support to passing a column to `#quote`.
2111
686
 
2112
- * Fixed `ActiveRecord::Relation#group` method when an argument is an SQL
2113
- reserved keyword:
687
+ *Rafael Mendonça França*
2114
688
 
2115
- Example:
689
+ * Set `:time` as a timezone aware type and remove deprecation when
690
+ `config.active_record.time_zone_aware_types` is not explicitly set.
2116
691
 
2117
- SplitTest.group(:key).count
2118
- Property.group(:value).count
692
+ *Rafael Mendonça França*
2119
693
 
2120
- *Bogdan Gusiev*
694
+ * Remove deprecated force reload argument in singular and collection association readers.
2121
695
 
2122
- * Added the `#or` method on `ActiveRecord::Relation`, allowing use of the OR
2123
- operator to combine WHERE or HAVING clauses.
696
+ *Rafael Mendonça França*
2124
697
 
2125
- Example:
698
+ * Remove deprecated `activerecord.errors.messages.restrict_dependent_destroy.one` and
699
+ `activerecord.errors.messages.restrict_dependent_destroy.many` i18n scopes.
2126
700
 
2127
- Post.where('id = 1').or(Post.where('id = 2'))
2128
- # => SELECT * FROM posts WHERE (id = 1) OR (id = 2)
701
+ *Rafael Mendonça França*
2129
702
 
2130
- *Sean Griffin*, *Matthew Draper*, *Gael Muller*, *Olivier El Mekki*
703
+ * Allow passing extra flags to `db:structure:load` and `db:structure:dump`
2131
704
 
2132
- * Don't define autosave association callbacks twice from
2133
- `accepts_nested_attributes_for`.
705
+ Introduces `ActiveRecord::Tasks::DatabaseTasks.structure_(load|dump)_flags` to customize the
706
+ eventual commands run against the database, e.g. mysqldump/pg_dump.
2134
707
 
2135
- Fixes #18704.
708
+ *Kir Shatrov*
2136
709
 
2137
- *Sean Griffin*
710
+ * Notifications see frozen SQL string.
2138
711
 
2139
- * Integer types will no longer raise a `RangeError` when assigning an
2140
- attribute, but will instead raise when going to the database.
712
+ Fixes #23774.
2141
713
 
2142
- Fixes several vague issues which were never reported directly. See the
2143
- commit message from the commit which added this line for some examples.
714
+ *Richard Monette*
2144
715
 
2145
- *Sean Griffin*
716
+ * RuntimeErrors are no longer translated to `ActiveRecord::StatementInvalid`.
2146
717
 
2147
- * Values which would error while being sent to the database (such as an
2148
- ASCII-8BIT string with invalid UTF-8 bytes on SQLite3), no longer error on
2149
- assignment. They will still error when sent to the database, but you are
2150
- given the ability to re-assign it to a valid value.
718
+ *Richard Monette*
2151
719
 
2152
- Fixes #18580.
720
+ * Change the schema cache format to use YAML instead of Marshal.
2153
721
 
2154
- *Sean Griffin*
722
+ *Kir Shatrov*
2155
723
 
2156
- * Don't remove join dependencies in `Relation#exists?`
724
+ * Support index length and order options using both string and symbol
725
+ column names.
2157
726
 
2158
- Fixes #18632.
727
+ Fixes #27243.
2159
728
 
2160
- *Sean Griffin*
729
+ *Ryuta Kamizono*
2161
730
 
2162
- * Invalid values assigned to a JSON column are assumed to be `nil`.
731
+ * Raise `ActiveRecord::RangeError` when values that executed are out of range.
2163
732
 
2164
- Fixes #18629.
733
+ *Ryuta Kamizono*
2165
734
 
2166
- *Sean Griffin*
735
+ * Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted
736
+ or updated because it would violate a not null constraint.
2167
737
 
2168
- * Add `ActiveRecord::Base#accessed_fields`, which can be used to quickly
2169
- discover which fields were read from a model when you are looking to only
2170
- select the data you need from the database.
738
+ *Ryuta Kamizono*
2171
739
 
2172
- *Sean Griffin*
740
+ * Emulate db trigger behaviour for after_commit :destroy, :update.
2173
741
 
2174
- * Introduce the `:if_exists` option for `drop_table`.
742
+ Race conditions can occur when an ActiveRecord is destroyed
743
+ twice or destroyed and updated. The callbacks should only be
744
+ triggered once, similar to a SQL database trigger.
2175
745
 
2176
- Example:
746
+ *Stefan Budeanu*
2177
747
 
2178
- drop_table(:posts, if_exists: true)
748
+ * Moved `DecimalWithoutScale`, `Text`, and `UnsignedInteger` from Active Model to Active Record.
2179
749
 
2180
- That would execute:
750
+ *Iain Beeston*
2181
751
 
2182
- DROP TABLE IF EXISTS posts
752
+ * Fix `write_attribute` method to check whether an attribute is aliased or not, and
753
+ use the aliased attribute name if needed.
2183
754
 
2184
- If the table doesn't exist, `if_exists: false` (the default) raises an
2185
- exception whereas `if_exists: true` does nothing.
755
+ *Prathamesh Sonpatki*
2186
756
 
2187
- *Cody Cutrer*, *Stefan Kanev*, *Ryuta Kamizono*
757
+ * Fix `read_attribute` method to check whether an attribute is aliased or not, and
758
+ use the aliased attribute name if needed.
2188
759
 
2189
- * Don't run SQL if attribute value is not changed for update_attribute method.
760
+ Fixes #26417.
2190
761
 
2191
762
  *Prathamesh Sonpatki*
2192
763
 
2193
- * `time` columns can now get affected by `time_zone_aware_attributes`. If you have
2194
- set `config.time_zone` to a value other than `'UTC'`, they will be treated
2195
- as in that time zone by default in Rails 5.1. If this is not the desired
2196
- behavior, you can set
2197
-
2198
- ActiveRecord::Base.time_zone_aware_types = [:datetime]
764
+ * PostgreSQL & MySQL: Use big integer as primary key type for new tables.
2199
765
 
2200
- A deprecation warning will be emitted if you have a `:time` column, and have
2201
- not explicitly opted out.
766
+ *Jon McCartie*, *Pavel Pravosud*
2202
767
 
2203
- Fixes #3145.
768
+ * Change the type argument of `ActiveRecord::Base#attribute` to be optional.
769
+ The default is now `ActiveRecord::Type::Value.new`, which provides no type
770
+ casting behavior.
2204
771
 
2205
772
  *Sean Griffin*
2206
773
 
2207
- * Tests now run after_commit callbacks. You no longer have to declare
2208
- `uses_transaction ‘test name’` to test the results of an after_commit.
774
+ * Don't treat unsigned integers with zerofill as signed.
2209
775
 
2210
- after_commit callbacks run after committing a transaction whose parent
2211
- is not `joinable?`: un-nested transactions, transactions within test cases,
2212
- and transactions in `console --sandbox`.
776
+ Fixes #27125.
2213
777
 
2214
- *arthurnn*, *Ravil Bayramgalin*, *Matthew Draper*
778
+ *Ryuta Kamizono*
2215
779
 
2216
- * `nil` as a value for a binary column in a query no longer logs as
2217
- "<NULL binary data>", and instead logs as just "nil".
780
+ * Fix the uniqueness validation scope with a polymorphic association.
2218
781
 
2219
- *Sean Griffin*
782
+ *Sergey Alekseev*
2220
783
 
2221
- * `attribute_will_change!` will no longer cause non-persistable attributes to
2222
- be sent to the database.
784
+ * Raise `ActiveRecord::RecordNotFound` from collection `*_ids` setters
785
+ for unknown IDs with a better error message.
2223
786
 
2224
- Fixes #18407.
787
+ Changes the collection `*_ids` setters to cast provided IDs the data
788
+ type of the primary key set in the association, not the model
789
+ primary key.
2225
790
 
2226
- *Sean Griffin*
791
+ *Dominic Cleal*
2227
792
 
2228
- * Remove support for the `protected_attributes` gem.
793
+ * For PostgreSQL >= 9.4 use `pgcrypto`'s `gen_random_uuid()` instead of
794
+ `uuid-ossp`'s UUID generation function.
2229
795
 
2230
- *Carlos Antonio da Silva*, *Roberto Miranda*
796
+ *Yuji Yaginuma*, *Yaw Boakye*
2231
797
 
2232
- * Fix accessing of fixtures having non-string labels like Fixnum.
798
+ * Introduce `Model#reload_<association>` to bring back the behavior
799
+ of `Article.category(true)` where `category` is a singular
800
+ association.
2233
801
 
2234
- *Prathamesh Sonpatki*
802
+ The force reloading of the association reader was deprecated
803
+ in #20888. Unfortunately the suggested alternative of
804
+ `article.reload.category` does not expose the same behavior.
2235
805
 
2236
- * Remove deprecated support to preload instance-dependent associations.
806
+ This patch adds a reader method with the prefix `reload_` for
807
+ singular associations. This method has the same semantics as
808
+ passing true to the association reader used to have.
2237
809
 
2238
810
  *Yves Senn*
2239
811
 
2240
- * Remove deprecated support for PostgreSQL ranges with exclusive lower bounds.
812
+ * Make sure eager loading `ActiveRecord::Associations` also loads
813
+ constants defined in `ActiveRecord::Associations::Preloader`.
2241
814
 
2242
815
  *Yves Senn*
2243
816
 
2244
- * Remove deprecation when modifying a relation with cached Arel.
2245
- This raises an `ImmutableRelation` error instead.
817
+ * Allow `ActionController::Parameters`-like objects to be passed as
818
+ values for Postgres HStore columns.
2246
819
 
2247
- *Yves Senn*
820
+ Fixes #26904.
2248
821
 
2249
- * Added `ActiveRecord::SecureToken` in order to encapsulate generation of
2250
- unique tokens for attributes in a model using `SecureRandom`.
822
+ *Jon Moss*
2251
823
 
2252
- *Roberto Miranda*
824
+ * Added `stat` method to `ActiveRecord::ConnectionAdapters::ConnectionPool`.
2253
825
 
2254
- * Change the behavior of boolean columns to be closer to Ruby's semantics.
826
+ Example:
2255
827
 
2256
- Before this change we had a small set of "truthy", and all others are "falsy".
828
+ ActiveRecord::Base.connection_pool.stat # =>
829
+ { size: 15, connections: 1, busy: 1, dead: 0, idle: 0, waiting: 0, checkout_timeout: 5 }
2257
830
 
2258
- Now, we have a small set of "falsy" values and all others are "truthy" matching
2259
- Ruby's semantics.
831
+ *Pavel Evstigneev*
2260
832
 
2261
- *Rafael Mendonça França*
833
+ * Avoid `unscope(:order)` when `limit_value` is presented for `count`
834
+ and `exists?`.
2262
835
 
2263
- * Deprecate `ActiveRecord::Base.errors_in_transactional_callbacks=`.
836
+ If `limit_value` is presented, records fetching order is very important
837
+ for performance. We should not unscope the order in the case.
2264
838
 
2265
- *Rafael Mendonça França*
839
+ *Ryuta Kamizono*
2266
840
 
2267
- * Change transaction callbacks to not swallow errors.
841
+ * Fix an Active Record `DateTime` field `NoMethodError` caused by incomplete
842
+ datetime.
2268
843
 
2269
- Before this change any errors raised inside a transaction callback
2270
- were getting rescued and printed in the logs.
844
+ Fixes #24195.
2271
845
 
2272
- Now these errors are not rescued anymore and just bubble up, as the other callbacks.
846
+ *Sen Zhang*
2273
847
 
2274
- *Rafael Mendonça França*
848
+ * Allow `slice` to take an array of methods(without the need for splatting).
2275
849
 
2276
- * Remove deprecated `sanitize_sql_hash_for_conditions`.
850
+ *Cohen Carlisle*
2277
851
 
2278
- *Rafael Mendonça França*
852
+ * Improved partial writes with HABTM and has many through associations
853
+ to fire database query only if relation has been changed.
2279
854
 
2280
- * Remove deprecated `Reflection#source_macro`.
855
+ Fixes #19663.
2281
856
 
2282
- *Rafael Mendonça França*
857
+ *Mehmet Emin İNAÇ*
2283
858
 
2284
- * Remove deprecated `symbolized_base_class` and `symbolized_sti_name`.
859
+ * Deprecate passing arguments and block at the same time to
860
+ `ActiveRecord::QueryMethods#select`.
2285
861
 
2286
- *Rafael Mendonça França*
862
+ *Prathamesh Sonpatki*
2287
863
 
2288
- * Remove deprecated `ActiveRecord::Base.disable_implicit_join_references=`.
864
+ * Fixed: Optimistic locking does not work well with `null` in the database.
2289
865
 
2290
- *Rafael Mendonça França*
866
+ Fixes #26024.
2291
867
 
2292
- * Remove deprecated access to connection specification using a string accessor.
868
+ *bogdanvlviv*
2293
869
 
2294
- Now all strings will be handled as a URL.
870
+ * Fixed support for case insensitive comparisons of `text` columns in
871
+ PostgreSQL.
2295
872
 
2296
- *Rafael Mendonça França*
873
+ *Edho Arief*
2297
874
 
2298
- * Change the default `null` value for `timestamps` to `false`.
875
+ * Serialize JSON attribute value `nil` as SQL `NULL`, not JSON `null`.
2299
876
 
2300
- *Rafael Mendonça França*
877
+ *Trung Duc Tran*
2301
878
 
2302
- * Return an array of pools from `connection_pools`.
879
+ * Return `true` from `update_attribute` when the value of the attribute
880
+ to be updated is unchanged.
2303
881
 
2304
- *Rafael Mendonça França*
882
+ Fixes #26593.
2305
883
 
2306
- * Return a null column from `column_for_attribute` when no column exists.
884
+ *Prathamesh Sonpatki*
2307
885
 
2308
- *Rafael Mendonça França*
886
+ * Always store errors details information with symbols.
2309
887
 
2310
- * Remove deprecated `serialized_attributes`.
888
+ When the association is autosaved we were storing the details with
889
+ string keys. This was creating inconsistency with other details that are
890
+ added using the `Errors#add` method. It was also inconsistent with the
891
+ `Errors#messages` storage.
2311
892
 
2312
- *Rafael Mendonça França*
893
+ To fix this inconsistency we are always storing with symbols. This will
894
+ cause a small breaking change because in those cases the details could
895
+ be accessed as strings keys but now it can not.
2313
896
 
2314
- * Remove deprecated automatic counter caches on `has_many :through`.
897
+ Fix #26499.
2315
898
 
2316
- *Rafael Mendonça França*
899
+ *Rafael Mendonça França*, *Marcus Vieira*
2317
900
 
2318
- * Change the way in which callback chains can be halted.
901
+ * Calling `touch` on a model using optimistic locking will now leave the model
902
+ in a non-dirty state with no attribute changes.
2319
903
 
2320
- The preferred method to halt a callback chain from now on is to explicitly
2321
- `throw(:abort)`.
2322
- In the past, returning `false` in an Active Record `before_` callback had the
2323
- side effect of halting the callback chain.
2324
- This is not recommended anymore and, depending on the value of the
2325
- `ActiveSupport.halt_callback_chains_on_return_false` option, will
2326
- either not work at all or display a deprecation warning.
904
+ Fixes #26496.
2327
905
 
2328
- *claudiob*
906
+ *Jakob Skjerning*
2329
907
 
2330
- * Clear query cache on rollback.
908
+ * Using a mysql2 connection after it fails to reconnect will now have an error message
909
+ saying the connection is closed rather than an undefined method error message.
2331
910
 
2332
- *Florian Weingarten*
911
+ *Dylan Thacker-Smith*
2333
912
 
2334
- * Fix setting of foreign_key for through associations when building a new record.
913
+ * PostgreSQL array columns will now respect the encoding of strings contained
914
+ in the array.
2335
915
 
2336
- Fixes #12698.
916
+ Fixes #26326.
2337
917
 
2338
- *Ivan Antropov*
918
+ *Sean Griffin*
2339
919
 
2340
- * Improve dumping of the primary key. If it is not a default primary key,
2341
- correctly dump the type and options.
920
+ * Inverse association instances will now be set before `after_find` or
921
+ `after_initialize` callbacks are run.
2342
922
 
2343
- Fixes #14169, #16599.
923
+ Fixes #26320.
2344
924
 
2345
- *Ryuta Kamizono*
925
+ *Sean Griffin*
2346
926
 
2347
- * Format the datetime string according to the precision of the datetime field.
927
+ * Remove unnecessarily association load when a `belongs_to` association has already been
928
+ loaded then the foreign key is changed directly and the record saved.
2348
929
 
2349
- Incompatible to rounding behavior between MySQL 5.6 and earlier.
930
+ *James Coleman*
2350
931
 
2351
- In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
2352
- is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
932
+ * Remove standardized column types/arguments spaces in schema dump.
2353
933
 
2354
- http://bugs.mysql.com/bug.php?id=68760
934
+ *Tim Petricola*
2355
935
 
2356
- *Ryuta Kamizono*
936
+ * Avoid loading records from database when they are already loaded using
937
+ the `pluck` method on a collection.
2357
938
 
2358
- * Allow a precision option for MySQL datetimes.
939
+ Fixes #25921.
2359
940
 
2360
941
  *Ryuta Kamizono*
2361
942
 
2362
- * Fixed automatic `inverse_of` for models nested in a module.
2363
-
2364
- *Andrew McCloud*
2365
-
2366
- * Change `ActiveRecord::Relation#update` behavior so that it can
2367
- be called without passing ids of the records to be updated.
2368
-
2369
- This change allows updating multiple records returned by
2370
- `ActiveRecord::Relation` with callbacks and validations.
2371
-
2372
- # Before
2373
- # ArgumentError: wrong number of arguments (1 for 2)
2374
- Comment.where(group: 'expert').update(body: "Group of Rails Experts")
2375
-
2376
- # After
2377
- # Comments with group expert updated with body "Group of Rails Experts"
2378
- Comment.where(group: 'expert').update(body: "Group of Rails Experts")
2379
-
2380
- *Prathamesh Sonpatki*
2381
-
2382
- * Fix `reaping_frequency` option when the value is a string.
2383
-
2384
- This usually happens when it is configured using `DATABASE_URL`.
2385
-
2386
- *korbin*
943
+ * Remove text default treated as an empty string in non-strict mode for
944
+ consistency with other types.
945
+
946
+ Strict mode controls how MySQL handles invalid or missing values in
947
+ data-change statements such as INSERT or UPDATE. If strict mode is not
948
+ in effect, MySQL inserts adjusted values for invalid or missing values
949
+ and produces warnings.
950
+
951
+ def test_mysql_not_null_defaults_non_strict
952
+ using_strict(false) do
953
+ with_mysql_not_null_table do |klass|
954
+ record = klass.new
955
+ assert_nil record.non_null_integer
956
+ assert_nil record.non_null_string
957
+ assert_nil record.non_null_text
958
+ assert_nil record.non_null_blob
959
+
960
+ record.save!
961
+ record.reload
962
+
963
+ assert_equal 0, record.non_null_integer
964
+ assert_equal "", record.non_null_string
965
+ assert_equal "", record.non_null_text
966
+ assert_equal "", record.non_null_blob
967
+ end
968
+ end
969
+ end
2387
970
 
2388
- * Fix error message when trying to create an associated record and the foreign
2389
- key is missing.
971
+ https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict
2390
972
 
2391
- Before this fix the following exception was being raised:
973
+ *Ryuta Kamizono*
2392
974
 
2393
- NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
975
+ * SQLite3 migrations to add a column to an existing table can now be
976
+ successfully rolled back when the column was given and invalid column
977
+ type.
2394
978
 
2395
- Now the message is:
979
+ Fixes #26087.
2396
980
 
2397
- ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
981
+ *Travis O'Neill*
2398
982
 
2399
- *Rafael Mendonça França*
983
+ * Deprecate `sanitize_conditions`. Use `sanitize_sql` instead.
2400
984
 
2401
- * Fix change detection problem for PostgreSQL bytea type and
2402
- `ArgumentError: string contains null byte` exception with pg-0.18.
985
+ *Ryuta Kamizono*
2403
986
 
2404
- Fixes #17680.
987
+ * Doing count on relations that contain LEFT OUTER JOIN Arel node no longer
988
+ force a DISTINCT. This solves issues when using count after a left_joins.
2405
989
 
2406
- *Lars Kanis*
990
+ *Maxime Handfield Lapointe*
2407
991
 
2408
- * When a table has a composite primary key, the `primary_key` method for
2409
- SQLite3 and PostgreSQL adapters was only returning the first field of the key.
2410
- Ensures that it will return nil instead, as Active Record doesn't support
2411
- composite primary keys.
992
+ * RecordNotFound raised by association.find exposes `id`, `primary_key` and
993
+ `model` methods to be consistent with RecordNotFound raised by Record.find.
2412
994
 
2413
- Fixes #18070.
995
+ *Michel Pigassou*
2414
996
 
2415
- *arthurnn*
997
+ * Hashes can once again be passed to setters of `composed_of`, if all of the
998
+ mapping methods are methods implemented on `Hash`.
2416
999
 
2417
- * `validates_size_of` / `validates_length_of` do not count records
2418
- which are `marked_for_destruction?`.
1000
+ Fixes #25978.
2419
1001
 
2420
- Fixes #7247.
1002
+ *Sean Griffin*
2421
1003
 
2422
- *Yves Senn*
1004
+ * Fix the SELECT statement in `#table_comment` for MySQL.
2423
1005
 
2424
- * Ensure `first!` and friends work on loaded associations.
1006
+ *Takeshi Akima*
2425
1007
 
2426
- Fixes #18237.
1008
+ * Virtual attributes will no longer raise when read on models loaded from the
1009
+ database.
2427
1010
 
2428
1011
  *Sean Griffin*
2429
1012
 
2430
- * `eager_load` preserves readonly flag for associations.
1013
+ * Support calling the method `merge` in `scope`'s lambda.
2431
1014
 
2432
- Fixes #15853.
1015
+ *Yasuhiro Sugino*
2433
1016
 
2434
- *Takashi Kokubun*
1017
+ * Fixes multi-parameter attributes conversion with invalid params.
2435
1018
 
2436
- * Provide `:touch` option to `save()` to accommodate saving without updating
2437
- timestamps.
1019
+ *Hiroyuki Ishii*
2438
1020
 
2439
- Fixes #18202.
1021
+ * Add newline between each migration in `structure.sql`.
2440
1022
 
2441
- *Dan Olson*
1023
+ Keeps schema migration inserts as a single commit, but allows for easier
1024
+ git diffing.
2442
1025
 
2443
- * Provide a more helpful error message when an unsupported class is passed to
2444
- `serialize`.
1026
+ Fixes #25504.
2445
1027
 
2446
- Fixes #18224.
1028
+ *Grey Baker*, *Norberto Lopes*
2447
1029
 
2448
- *Sean Griffin*
1030
+ * The flag `error_on_ignored_order_or_limit` has been deprecated in favor of
1031
+ the current `error_on_ignored_order`.
2449
1032
 
2450
- * Add bigint primary key support for MySQL.
1033
+ *Xavier Noria*
2451
1034
 
2452
- Example:
1035
+ * Batch processing methods support `limit`:
2453
1036
 
2454
- create_table :foos, id: :bigint do |t|
1037
+ Post.limit(10_000).find_each do |post|
1038
+ # ...
2455
1039
  end
2456
1040
 
2457
- *Ryuta Kamizono*
2458
-
2459
- * Support for any type of primary key.
2460
-
2461
- Fixes #14194.
2462
-
2463
- *Ryuta Kamizono*
1041
+ It also works in `find_in_batches` and `in_batches`.
2464
1042
 
2465
- * Dump the default `nil` for PostgreSQL UUID primary key.
1043
+ *Xavier Noria*
2466
1044
 
2467
- *Ryuta Kamizono*
1045
+ * Using `group` with an attribute that has a custom type will properly cast
1046
+ the hash keys after calling a calculation method like `count`.
2468
1047
 
2469
- * Add a `:foreign_key` option to `references` and associated migration
2470
- methods. The model and migration generators now use this option, rather than
2471
- the `add_foreign_key` form.
1048
+ Fixes #25595.
2472
1049
 
2473
1050
  *Sean Griffin*
2474
1051
 
2475
- * Don't raise when writing an attribute with an out-of-range datetime passed
2476
- by the user.
1052
+ * Fix the generated `#to_param` method to use `omission: ''` so that
1053
+ the resulting output is actually up to 20 characters, not
1054
+ effectively 17 to leave room for the default "...".
1055
+ Also call `#parameterize` before `#truncate` and make the
1056
+ `separator: /-/` to maximize the information included in the
1057
+ output.
2477
1058
 
2478
- *Grey Baker*
1059
+ Fixes #23635.
2479
1060
 
2480
- * Replace deprecated `ActiveRecord::Tasks::DatabaseTasks#load_schema` with
2481
- `ActiveRecord::Tasks::DatabaseTasks#load_schema_for`.
1061
+ *Rob Biedenharn*
2482
1062
 
2483
- *Yves Senn*
1063
+ * Ensure concurrent invocations of the connection reaper cannot allocate the
1064
+ same connection to two threads.
1065
+
1066
+ Fixes #25585.
2484
1067
 
2485
- * Fix bug with `ActiveRecord::Type::Numeric` that caused negative values to
2486
- be marked as having changed when set to the same negative value.
1068
+ *Matthew Draper*
2487
1069
 
2488
- Fixes #18161.
1070
+ * Inspecting an object with an associated array of over 10 elements no longer
1071
+ truncates the array, preventing `inspect` from looping infinitely in some
1072
+ cases.
2489
1073
 
2490
- *Daniel Fox*
1074
+ *Kevin McPhillips*
2491
1075
 
2492
- * Introduce `force: :cascade` option for `create_table`. Using this option
2493
- will recreate tables even if they have dependent objects (like foreign keys).
2494
- `db/schema.rb` now uses `force: :cascade`. This makes it possible to
2495
- reload the schema when foreign keys are in place.
1076
+ * Removed the unused methods `ActiveRecord::Base.connection_id` and
1077
+ `ActiveRecord::Base.connection_id=`.
2496
1078
 
2497
- *Matthew Draper*, *Yves Senn*
1079
+ *Sean Griffin*
2498
1080
 
2499
- * `db:schema:load` and `db:structure:load` no longer purge the database
2500
- before loading the schema. This is left for the user to do.
2501
- `db:test:prepare` will still purge the database.
1081
+ * Ensure hashes can be assigned to attributes created using `composed_of`.
2502
1082
 
2503
- Fixes #17945.
1083
+ Fixes #25210.
2504
1084
 
2505
- *Yves Senn*
1085
+ *Sean Griffin*
2506
1086
 
2507
- * Fix undesirable RangeError by `Type::Integer`. Add `Type::UnsignedInteger`.
1087
+ * Fix logging edge case where if an attribute was of the binary type and
1088
+ was provided as a Hash.
2508
1089
 
2509
- *Ryuta Kamizono*
1090
+ *Jon Moss*
2510
1091
 
2511
- * Add `foreign_type` option to `has_one` and `has_many` association macros.
1092
+ * Handle JSON deserialization correctly if the column default from database
1093
+ adapter returns `''` instead of `nil`.
2512
1094
 
2513
- This option enables to define the column name of associated object's type for polymorphic associations.
1095
+ *Johannes Opper*
2514
1096
 
2515
- *Ulisses Almeida*, *Kassio Borges*
1097
+ * Introduce new Active Record transaction error classes for catching
1098
+ transaction serialization failures or deadlocks.
2516
1099
 
2517
- * Remove deprecated behavior allowing nested arrays to be passed as query
2518
- values.
1100
+ *Erol Fornoles*
2519
1101
 
2520
- *Melanie Gilman*
1102
+ * PostgreSQL: Fix `db:structure:load` silent failure on SQL error.
2521
1103
 
2522
- * Deprecate passing a class as a value in a query. Users should pass strings
2523
- instead.
1104
+ The command line flag `-v ON_ERROR_STOP=1` should be used
1105
+ when invoking `psql` to make sure errors are not suppressed.
2524
1106
 
2525
- *Melanie Gilman*
1107
+ Example:
2526
1108
 
2527
- * `add_timestamps` and `remove_timestamps` now properly reversible with
2528
- options.
1109
+ psql -v ON_ERROR_STOP=1 -q -f awesome-file.sql my-app-db
2529
1110
 
2530
- *Noam Gagliardi-Rabinovich*
1111
+ Fixes #23818.
2531
1112
 
2532
- * `ActiveRecord::ConnectionAdapters::ColumnDumper#column_spec` and
2533
- `ActiveRecord::ConnectionAdapters::ColumnDumper#prepare_column_options` no
2534
- longer have a `types` argument. They should access
2535
- `connection#native_database_types` directly.
1113
+ *Ralin Chimev*
2536
1114
 
2537
- *Yves Senn*
2538
1115
 
2539
- Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md) for previous changes.
1116
+ Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/activerecord/CHANGELOG.md) for previous changes.