activerecord 5.2.6 → 6.0.5

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 (294) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +928 -559
  3. data/MIT-LICENSE +3 -1
  4. data/README.rdoc +5 -3
  5. data/examples/performance.rb +1 -1
  6. data/lib/active_record/advisory_lock_base.rb +18 -0
  7. data/lib/active_record/aggregations.rb +4 -3
  8. data/lib/active_record/association_relation.rb +10 -8
  9. data/lib/active_record/associations/alias_tracker.rb +0 -1
  10. data/lib/active_record/associations/association.rb +55 -19
  11. data/lib/active_record/associations/association_scope.rb +11 -7
  12. data/lib/active_record/associations/belongs_to_association.rb +36 -42
  13. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +0 -4
  14. data/lib/active_record/associations/builder/association.rb +14 -18
  15. data/lib/active_record/associations/builder/belongs_to.rb +19 -52
  16. data/lib/active_record/associations/builder/collection_association.rb +3 -13
  17. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +17 -40
  18. data/lib/active_record/associations/builder/has_many.rb +2 -0
  19. data/lib/active_record/associations/builder/has_one.rb +35 -1
  20. data/lib/active_record/associations/builder/singular_association.rb +2 -0
  21. data/lib/active_record/associations/collection_association.rb +19 -23
  22. data/lib/active_record/associations/collection_proxy.rb +14 -17
  23. data/lib/active_record/associations/foreign_association.rb +7 -0
  24. data/lib/active_record/associations/has_many_association.rb +2 -11
  25. data/lib/active_record/associations/has_many_through_association.rb +14 -14
  26. data/lib/active_record/associations/has_one_association.rb +28 -30
  27. data/lib/active_record/associations/has_one_through_association.rb +5 -5
  28. data/lib/active_record/associations/join_dependency/join_association.rb +16 -10
  29. data/lib/active_record/associations/join_dependency/join_part.rb +4 -4
  30. data/lib/active_record/associations/join_dependency.rb +47 -30
  31. data/lib/active_record/associations/preloader/association.rb +61 -41
  32. data/lib/active_record/associations/preloader/through_association.rb +48 -39
  33. data/lib/active_record/associations/preloader.rb +44 -33
  34. data/lib/active_record/associations/singular_association.rb +2 -16
  35. data/lib/active_record/associations/through_association.rb +1 -1
  36. data/lib/active_record/associations.rb +21 -16
  37. data/lib/active_record/attribute_assignment.rb +7 -11
  38. data/lib/active_record/attribute_decorators.rb +0 -2
  39. data/lib/active_record/attribute_methods/before_type_cast.rb +4 -2
  40. data/lib/active_record/attribute_methods/dirty.rb +111 -40
  41. data/lib/active_record/attribute_methods/primary_key.rb +15 -24
  42. data/lib/active_record/attribute_methods/query.rb +2 -3
  43. data/lib/active_record/attribute_methods/read.rb +15 -54
  44. data/lib/active_record/attribute_methods/serialization.rb +1 -2
  45. data/lib/active_record/attribute_methods/time_zone_conversion.rb +1 -3
  46. data/lib/active_record/attribute_methods/write.rb +17 -25
  47. data/lib/active_record/attribute_methods.rb +28 -100
  48. data/lib/active_record/attributes.rb +13 -1
  49. data/lib/active_record/autosave_association.rb +12 -14
  50. data/lib/active_record/base.rb +2 -3
  51. data/lib/active_record/callbacks.rb +6 -21
  52. data/lib/active_record/coders/yaml_column.rb +0 -1
  53. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +109 -18
  54. data/lib/active_record/connection_adapters/abstract/database_limits.rb +17 -4
  55. data/lib/active_record/connection_adapters/abstract/database_statements.rb +102 -124
  56. data/lib/active_record/connection_adapters/abstract/query_cache.rb +18 -9
  57. data/lib/active_record/connection_adapters/abstract/quoting.rb +68 -17
  58. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +20 -14
  59. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +105 -72
  60. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +1 -3
  61. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +175 -79
  62. data/lib/active_record/connection_adapters/abstract/transaction.rb +96 -57
  63. data/lib/active_record/connection_adapters/abstract_adapter.rb +197 -43
  64. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +149 -217
  65. data/lib/active_record/connection_adapters/column.rb +17 -13
  66. data/lib/active_record/connection_adapters/connection_specification.rb +54 -45
  67. data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +6 -10
  68. data/lib/active_record/connection_adapters/mysql/column.rb +1 -1
  69. data/lib/active_record/connection_adapters/mysql/database_statements.rb +70 -14
  70. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +0 -1
  71. data/lib/active_record/connection_adapters/mysql/quoting.rb +44 -7
  72. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +4 -6
  73. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +40 -32
  74. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +14 -6
  75. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +139 -19
  76. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +6 -10
  77. data/lib/active_record/connection_adapters/mysql2_adapter.rb +26 -10
  78. data/lib/active_record/connection_adapters/postgresql/column.rb +17 -31
  79. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +26 -1
  80. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -2
  81. data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +1 -4
  82. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +8 -0
  83. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +0 -1
  84. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +1 -2
  85. data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +1 -2
  86. data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +1 -1
  87. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +1 -2
  88. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +25 -7
  89. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +1 -1
  90. data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +9 -7
  91. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +5 -3
  92. data/lib/active_record/connection_adapters/postgresql/quoting.rb +44 -7
  93. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +1 -1
  94. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +14 -3
  95. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +107 -91
  96. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +0 -1
  97. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +63 -75
  98. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +24 -27
  99. data/lib/active_record/connection_adapters/postgresql/utils.rb +0 -1
  100. data/lib/active_record/connection_adapters/postgresql_adapter.rb +168 -75
  101. data/lib/active_record/connection_adapters/schema_cache.rb +37 -14
  102. data/lib/active_record/connection_adapters/sql_type_metadata.rb +11 -8
  103. data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +119 -0
  104. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +42 -7
  105. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +43 -12
  106. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +137 -147
  107. data/lib/active_record/connection_adapters/statement_pool.rb +0 -1
  108. data/lib/active_record/connection_handling.rb +139 -26
  109. data/lib/active_record/core.rb +107 -66
  110. data/lib/active_record/counter_cache.rb +8 -30
  111. data/lib/active_record/database_configurations/database_config.rb +37 -0
  112. data/lib/active_record/database_configurations/hash_config.rb +50 -0
  113. data/lib/active_record/database_configurations/url_config.rb +78 -0
  114. data/lib/active_record/database_configurations.rb +233 -0
  115. data/lib/active_record/dynamic_matchers.rb +3 -4
  116. data/lib/active_record/enum.rb +44 -7
  117. data/lib/active_record/errors.rb +15 -7
  118. data/lib/active_record/explain.rb +1 -2
  119. data/lib/active_record/fixture_set/model_metadata.rb +33 -0
  120. data/lib/active_record/fixture_set/render_context.rb +17 -0
  121. data/lib/active_record/fixture_set/table_row.rb +152 -0
  122. data/lib/active_record/fixture_set/table_rows.rb +46 -0
  123. data/lib/active_record/fixtures.rb +144 -474
  124. data/lib/active_record/gem_version.rb +3 -3
  125. data/lib/active_record/inheritance.rb +13 -6
  126. data/lib/active_record/insert_all.rb +179 -0
  127. data/lib/active_record/integration.rb +68 -16
  128. data/lib/active_record/internal_metadata.rb +11 -3
  129. data/lib/active_record/locking/optimistic.rb +14 -7
  130. data/lib/active_record/locking/pessimistic.rb +3 -3
  131. data/lib/active_record/log_subscriber.rb +8 -27
  132. data/lib/active_record/middleware/database_selector/resolver/session.rb +45 -0
  133. data/lib/active_record/middleware/database_selector/resolver.rb +87 -0
  134. data/lib/active_record/middleware/database_selector.rb +74 -0
  135. data/lib/active_record/migration/command_recorder.rb +54 -22
  136. data/lib/active_record/migration/compatibility.rb +79 -52
  137. data/lib/active_record/migration/join_table.rb +0 -1
  138. data/lib/active_record/migration.rb +104 -85
  139. data/lib/active_record/model_schema.rb +62 -11
  140. data/lib/active_record/nested_attributes.rb +2 -4
  141. data/lib/active_record/no_touching.rb +9 -2
  142. data/lib/active_record/null_relation.rb +0 -1
  143. data/lib/active_record/persistence.rb +232 -29
  144. data/lib/active_record/query_cache.rb +11 -4
  145. data/lib/active_record/querying.rb +33 -21
  146. data/lib/active_record/railtie.rb +80 -43
  147. data/lib/active_record/railties/collection_cache_association_loading.rb +34 -0
  148. data/lib/active_record/railties/controller_runtime.rb +30 -35
  149. data/lib/active_record/railties/databases.rake +199 -46
  150. data/lib/active_record/reflection.rb +51 -51
  151. data/lib/active_record/relation/batches.rb +13 -11
  152. data/lib/active_record/relation/calculations.rb +55 -49
  153. data/lib/active_record/relation/delegation.rb +35 -50
  154. data/lib/active_record/relation/finder_methods.rb +23 -28
  155. data/lib/active_record/relation/from_clause.rb +4 -0
  156. data/lib/active_record/relation/merger.rb +12 -17
  157. data/lib/active_record/relation/predicate_builder/array_handler.rb +5 -4
  158. data/lib/active_record/relation/predicate_builder/association_query_value.rb +1 -4
  159. data/lib/active_record/relation/predicate_builder/base_handler.rb +1 -2
  160. data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +1 -2
  161. data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +1 -4
  162. data/lib/active_record/relation/predicate_builder/range_handler.rb +3 -23
  163. data/lib/active_record/relation/predicate_builder.rb +5 -11
  164. data/lib/active_record/relation/query_attribute.rb +13 -8
  165. data/lib/active_record/relation/query_methods.rb +232 -69
  166. data/lib/active_record/relation/spawn_methods.rb +1 -2
  167. data/lib/active_record/relation/where_clause.rb +14 -11
  168. data/lib/active_record/relation/where_clause_factory.rb +1 -2
  169. data/lib/active_record/relation.rb +326 -81
  170. data/lib/active_record/result.rb +30 -12
  171. data/lib/active_record/sanitization.rb +32 -40
  172. data/lib/active_record/schema.rb +2 -11
  173. data/lib/active_record/schema_dumper.rb +22 -7
  174. data/lib/active_record/schema_migration.rb +6 -2
  175. data/lib/active_record/scoping/default.rb +4 -6
  176. data/lib/active_record/scoping/named.rb +25 -16
  177. data/lib/active_record/scoping.rb +8 -9
  178. data/lib/active_record/statement_cache.rb +30 -3
  179. data/lib/active_record/store.rb +87 -8
  180. data/lib/active_record/suppressor.rb +2 -2
  181. data/lib/active_record/table_metadata.rb +23 -15
  182. data/lib/active_record/tasks/database_tasks.rb +194 -25
  183. data/lib/active_record/tasks/mysql_database_tasks.rb +5 -6
  184. data/lib/active_record/tasks/postgresql_database_tasks.rb +5 -8
  185. data/lib/active_record/tasks/sqlite_database_tasks.rb +2 -9
  186. data/lib/active_record/test_databases.rb +23 -0
  187. data/lib/active_record/test_fixtures.rb +243 -0
  188. data/lib/active_record/timestamp.rb +39 -26
  189. data/lib/active_record/touch_later.rb +5 -4
  190. data/lib/active_record/transactions.rb +64 -73
  191. data/lib/active_record/translation.rb +1 -1
  192. data/lib/active_record/type/adapter_specific_registry.rb +3 -13
  193. data/lib/active_record/type/hash_lookup_type_map.rb +0 -1
  194. data/lib/active_record/type/serialized.rb +0 -1
  195. data/lib/active_record/type/time.rb +10 -0
  196. data/lib/active_record/type/type_map.rb +0 -1
  197. data/lib/active_record/type/unsigned_integer.rb +0 -1
  198. data/lib/active_record/type.rb +3 -5
  199. data/lib/active_record/type_caster/connection.rb +15 -14
  200. data/lib/active_record/type_caster/map.rb +1 -4
  201. data/lib/active_record/validations/associated.rb +0 -1
  202. data/lib/active_record/validations/uniqueness.rb +15 -27
  203. data/lib/active_record/validations.rb +3 -3
  204. data/lib/active_record.rb +10 -2
  205. data/lib/arel/alias_predication.rb +9 -0
  206. data/lib/arel/attributes/attribute.rb +37 -0
  207. data/lib/arel/attributes.rb +22 -0
  208. data/lib/arel/collectors/bind.rb +24 -0
  209. data/lib/arel/collectors/composite.rb +31 -0
  210. data/lib/arel/collectors/plain_string.rb +20 -0
  211. data/lib/arel/collectors/sql_string.rb +20 -0
  212. data/lib/arel/collectors/substitute_binds.rb +28 -0
  213. data/lib/arel/crud.rb +42 -0
  214. data/lib/arel/delete_manager.rb +18 -0
  215. data/lib/arel/errors.rb +9 -0
  216. data/lib/arel/expressions.rb +29 -0
  217. data/lib/arel/factory_methods.rb +49 -0
  218. data/lib/arel/insert_manager.rb +49 -0
  219. data/lib/arel/math.rb +45 -0
  220. data/lib/arel/nodes/and.rb +32 -0
  221. data/lib/arel/nodes/ascending.rb +23 -0
  222. data/lib/arel/nodes/binary.rb +52 -0
  223. data/lib/arel/nodes/bind_param.rb +36 -0
  224. data/lib/arel/nodes/case.rb +55 -0
  225. data/lib/arel/nodes/casted.rb +50 -0
  226. data/lib/arel/nodes/comment.rb +29 -0
  227. data/lib/arel/nodes/count.rb +12 -0
  228. data/lib/arel/nodes/delete_statement.rb +45 -0
  229. data/lib/arel/nodes/descending.rb +23 -0
  230. data/lib/arel/nodes/equality.rb +18 -0
  231. data/lib/arel/nodes/extract.rb +24 -0
  232. data/lib/arel/nodes/false.rb +16 -0
  233. data/lib/arel/nodes/full_outer_join.rb +8 -0
  234. data/lib/arel/nodes/function.rb +44 -0
  235. data/lib/arel/nodes/grouping.rb +8 -0
  236. data/lib/arel/nodes/in.rb +8 -0
  237. data/lib/arel/nodes/infix_operation.rb +80 -0
  238. data/lib/arel/nodes/inner_join.rb +8 -0
  239. data/lib/arel/nodes/insert_statement.rb +37 -0
  240. data/lib/arel/nodes/join_source.rb +20 -0
  241. data/lib/arel/nodes/matches.rb +18 -0
  242. data/lib/arel/nodes/named_function.rb +23 -0
  243. data/lib/arel/nodes/node.rb +50 -0
  244. data/lib/arel/nodes/node_expression.rb +13 -0
  245. data/lib/arel/nodes/outer_join.rb +8 -0
  246. data/lib/arel/nodes/over.rb +15 -0
  247. data/lib/arel/nodes/regexp.rb +16 -0
  248. data/lib/arel/nodes/right_outer_join.rb +8 -0
  249. data/lib/arel/nodes/select_core.rb +67 -0
  250. data/lib/arel/nodes/select_statement.rb +41 -0
  251. data/lib/arel/nodes/sql_literal.rb +16 -0
  252. data/lib/arel/nodes/string_join.rb +11 -0
  253. data/lib/arel/nodes/table_alias.rb +27 -0
  254. data/lib/arel/nodes/terminal.rb +16 -0
  255. data/lib/arel/nodes/true.rb +16 -0
  256. data/lib/arel/nodes/unary.rb +45 -0
  257. data/lib/arel/nodes/unary_operation.rb +20 -0
  258. data/lib/arel/nodes/unqualified_column.rb +22 -0
  259. data/lib/arel/nodes/update_statement.rb +41 -0
  260. data/lib/arel/nodes/values_list.rb +9 -0
  261. data/lib/arel/nodes/window.rb +126 -0
  262. data/lib/arel/nodes/with.rb +11 -0
  263. data/lib/arel/nodes.rb +68 -0
  264. data/lib/arel/order_predications.rb +13 -0
  265. data/lib/arel/predications.rb +256 -0
  266. data/lib/arel/select_manager.rb +271 -0
  267. data/lib/arel/table.rb +110 -0
  268. data/lib/arel/tree_manager.rb +72 -0
  269. data/lib/arel/update_manager.rb +34 -0
  270. data/lib/arel/visitors/depth_first.rb +203 -0
  271. data/lib/arel/visitors/dot.rb +296 -0
  272. data/lib/arel/visitors/ibm_db.rb +34 -0
  273. data/lib/arel/visitors/informix.rb +62 -0
  274. data/lib/arel/visitors/mssql.rb +156 -0
  275. data/lib/arel/visitors/mysql.rb +83 -0
  276. data/lib/arel/visitors/oracle.rb +158 -0
  277. data/lib/arel/visitors/oracle12.rb +65 -0
  278. data/lib/arel/visitors/postgresql.rb +109 -0
  279. data/lib/arel/visitors/sqlite.rb +38 -0
  280. data/lib/arel/visitors/to_sql.rb +888 -0
  281. data/lib/arel/visitors/visitor.rb +45 -0
  282. data/lib/arel/visitors/where_sql.rb +22 -0
  283. data/lib/arel/visitors.rb +20 -0
  284. data/lib/arel/window_predications.rb +9 -0
  285. data/lib/arel.rb +62 -0
  286. data/lib/rails/generators/active_record/application_record/application_record_generator.rb +0 -1
  287. data/lib/rails/generators/active_record/migration/migration_generator.rb +2 -5
  288. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +1 -1
  289. data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +4 -2
  290. data/lib/rails/generators/active_record/migration.rb +14 -2
  291. data/lib/rails/generators/active_record/model/model_generator.rb +1 -1
  292. data/lib/rails/generators/active_record/model/templates/model.rb.tt +10 -1
  293. metadata +116 -29
  294. data/lib/active_record/collection_cache_key.rb +0 -53
data/CHANGELOG.md CHANGED
@@ -1,1026 +1,1395 @@
1
- ## Rails 5.2.6 (May 05, 2021) ##
1
+ ## Rails 6.0.5 (May 09, 2022) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 5.2.5 (March 26, 2021) ##
6
+ ## Rails 6.0.4.8 (April 26, 2022) ##
7
7
 
8
8
  * No changes.
9
9
 
10
10
 
11
- ## Rails 5.2.4.6 (May 05, 2021) ##
11
+ ## Rails 6.0.4.7 (March 08, 2022) ##
12
12
 
13
13
  * No changes.
14
14
 
15
15
 
16
- ## Rails 5.2.4.5 (February 10, 2021) ##
16
+ ## Rails 6.0.4.6 (February 11, 2022) ##
17
17
 
18
- * Fix possible DoS vector in PostgreSQL money type
19
-
20
- Carefully crafted input can cause a DoS via the regular expressions used
21
- for validating the money format in the PostgreSQL adapter. This patch
22
- fixes the regexp.
18
+ * No changes.
23
19
 
24
- Thanks to @dee-see from Hackerone for this patch!
25
20
 
26
- [CVE-2021-22880]
21
+ ## Rails 6.0.4.5 (February 11, 2022) ##
27
22
 
28
- *Aaron Patterson*
23
+ * No changes.
29
24
 
30
25
 
31
- ## Rails 5.2.4.4 (September 09, 2020) ##
26
+ ## Rails 6.0.4.4 (December 15, 2021) ##
32
27
 
33
28
  * No changes.
34
29
 
35
30
 
36
- ## Rails 5.2.4.3 (May 18, 2020) ##
31
+ ## Rails 6.0.4.3 (December 14, 2021) ##
37
32
 
38
33
  * No changes.
39
34
 
40
- ## Rails 5.2.4.2 (March 19, 2020) ##
35
+
36
+ ## Rails 6.0.4.2 (December 14, 2021) ##
41
37
 
42
38
  * No changes.
43
39
 
44
40
 
45
- ## Rails 5.2.4.1 (December 18, 2019) ##
41
+ ## Rails 6.0.4.1 (August 19, 2021) ##
46
42
 
47
43
  * No changes.
48
44
 
49
45
 
50
- ## Rails 5.2.4 (November 27, 2019) ##
46
+ ## Rails 6.0.4 (June 15, 2021) ##
51
47
 
52
- * Fix circular `autosave: true` causes invalid records to be saved.
48
+ * Only warn about negative enums if a positive form that would cause conflicts exists.
53
49
 
54
- Prior to the fix, when there was a circular series of `autosave: true`
55
- associations, the callback for a `has_many` association was run while
56
- another instance of the same callback on the same association hadn't
57
- finished running. When control returned to the first instance of the
58
- callback, the instance variable had changed, and subsequent associated
59
- records weren't saved correctly. Specifically, the ID field for the
60
- `belongs_to` corresponding to the `has_many` was `nil`.
50
+ Fixes #39065.
61
51
 
62
- Fixes #28080.
52
+ *Alex Ghiculescu*
63
53
 
64
- *Larry Reid*
54
+ * Allow the inverse of a `has_one` association that was previously autosaved to be loaded.
65
55
 
66
- * PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
56
+ Fixes #34255.
67
57
 
68
- Fixes #36022.
58
+ *Steven Weber*
59
+
60
+ * Reset statement cache for association if `table_name` is changed.
61
+
62
+ Fixes #36453.
69
63
 
70
64
  *Ryuta Kamizono*
71
65
 
72
- * Fix sqlite3 collation parsing when using decimal columns.
66
+ * Type cast extra select for eager loading.
73
67
 
74
- *Martin R. Schuster*
68
+ *Ryuta Kamizono*
75
69
 
76
- * Make ActiveRecord `ConnectionPool.connections` method thread-safe.
70
+ * Prevent collection associations from being autosaved multiple times.
77
71
 
78
- Fixes #36465.
72
+ Fixes #39173.
79
73
 
80
- *Jeff Doering*
74
+ *Eugene Kenny*
81
75
 
82
- * Assign all attributes before calling `build` to ensure the child record is visible in
83
- `before_add` and `after_add` callbacks for `has_many :through` associations.
76
+ * Resolve issue with insert_all unique_by option when used with expression index.
84
77
 
85
- Fixes #33249.
78
+ When the `:unique_by` option of `ActiveRecord::Persistence.insert_all` and
79
+ `ActiveRecord::Persistence.upsert_all` was used with the name of an expression index, an error
80
+ was raised. Adding a guard around the formatting behavior for the `:unique_by` corrects this.
86
81
 
87
- *Ryan H. Kerr*
82
+ Usage:
88
83
 
84
+ ```ruby
85
+ create_table :books, id: :integer, force: true do |t|
86
+ t.column :name, :string
87
+ t.index "lower(name)", unique: true
88
+ end
89
89
 
90
- ## Rails 5.2.3 (March 27, 2019) ##
90
+ Book.insert_all [{ name: "MyTest" }], unique_by: :index_books_on_lower_name
91
+ ```
91
92
 
92
- * Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
93
+ Fixes #39516.
93
94
 
94
- Fixes #35214.
95
+ *Austen Madden*
95
96
 
96
- *Juani Villarejo*
97
+ * Fix preloading for polymorphic association with custom scope.
97
98
 
98
- * Fix prepared statements caching to be enabled even when query caching is enabled.
99
+ *Ryuta Kamizono*
100
+
101
+ * Allow relations with different SQL comments in the `or` method.
102
+
103
+ *Takumi Shotoku*
104
+
105
+ * Resolve conflict between counter cache and optimistic locking.
106
+
107
+ Bump an Active Record instance's lock version after updating its counter
108
+ cache. This avoids raising an unnecessary `ActiveRecord::StaleObjectError`
109
+ upon subsequent transactions by maintaining parity with the corresponding
110
+ database record's `lock_version` column.
111
+
112
+ Fixes #16449.
113
+
114
+ *Aaron Lipman*
115
+
116
+ * Fix through association with source/through scope which has joins.
99
117
 
100
118
  *Ryuta Kamizono*
101
119
 
102
- * Don't allow `where` with invalid value matches to nil values.
120
+ * Fix through association to respect source scope for includes/preload.
103
121
 
104
- Fixes #33624.
122
+ *Ryuta Kamizono*
123
+
124
+ * Fix eager load with Arel joins to maintain the original joins order.
105
125
 
106
126
  *Ryuta Kamizono*
107
127
 
108
- * Restore an ability that class level `update` without giving ids.
128
+ * Fix group by count with eager loading + order + limit/offset.
129
+
130
+ *Ryuta Kamizono*
109
131
 
110
- Fixes #34743.
132
+ * Fix left joins order when merging multiple left joins from different associations.
111
133
 
112
134
  *Ryuta Kamizono*
113
135
 
114
- * Fix join table column quoting with SQLite.
136
+ * Fix index creation to preserve index comment in bulk change table on MySQL.
115
137
 
116
- *Gannon McGibbon*
138
+ *Ryuta Kamizono*
117
139
 
118
- * Ensure that `delete_all` on collection proxy returns affected count.
140
+ * Change `remove_foreign_key` to not check `:validate` option if database
141
+ doesn't support the feature.
119
142
 
120
143
  *Ryuta Kamizono*
121
144
 
122
- * Reset scope after delete on collection association to clear stale offsets of removed records.
145
+ * Fix the result of aggregations to maintain duplicated "group by" fields.
123
146
 
124
- *Gannon McGibbon*
147
+ *Ryuta Kamizono*
125
148
 
149
+ * Do not return duplicated records when using preload.
126
150
 
127
- ## Rails 5.2.2.1 (March 11, 2019) ##
151
+ *Bogdan Gusiev*
152
+
153
+
154
+ ## Rails 6.0.3.7 (May 05, 2021) ##
128
155
 
129
156
  * No changes.
130
157
 
131
158
 
132
- ## Rails 5.2.2 (December 04, 2018) ##
159
+ ## Rails 6.0.3.6 (March 26, 2021) ##
133
160
 
134
- * Do not ignore the scoping with query methods in the scope block.
161
+ * No changes.
135
162
 
136
- *Ryuta Kamizono*
137
163
 
138
- * Allow aliased attributes to be used in `#update_columns` and `#update`.
164
+ ## Rails 6.0.3.5 (February 10, 2021) ##
139
165
 
140
- *Gannon McGibbon*
166
+ * Fix possible DoS vector in PostgreSQL money type
141
167
 
142
- * Allow spaces in postgres table names.
168
+ Carefully crafted input can cause a DoS via the regular expressions used
169
+ for validating the money format in the PostgreSQL adapter. This patch
170
+ fixes the regexp.
143
171
 
144
- Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres
145
- adapter.
172
+ Thanks to @dee-see from Hackerone for this patch!
146
173
 
147
- *Gannon McGibbon*
174
+ [CVE-2021-22880]
148
175
 
149
- * Cached columns_hash fields should be excluded from ResultSet#column_types
176
+ *Aaron Patterson*
150
177
 
151
- PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
152
- was passing for SQLite and MySQL, but failed for PostgreSQL:
153
178
 
154
- ```ruby
155
- class DeveloperName < ActiveRecord::Type::String
156
- def deserialize(value)
157
- "Developer: #{value}"
158
- end
159
- end
179
+ ## Rails 6.0.3.4 (October 07, 2020) ##
160
180
 
161
- class AttributedDeveloper < ActiveRecord::Base
162
- self.table_name = "developers"
181
+ * No changes.
163
182
 
164
- attribute :name, DeveloperName.new
165
183
 
166
- self.ignored_columns += ["name"]
167
- end
184
+ ## Rails 6.0.3.3 (September 09, 2020) ##
168
185
 
169
- developer = AttributedDeveloper.create
170
- developer.update_column :name, "name"
186
+ * No changes.
171
187
 
172
- loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
173
- puts loaded_developer.name # should be "Developer: name" but it's just "name"
174
- ```
175
188
 
176
- *Dmitry Tsepelev*
189
+ ## Rails 6.0.3.2 (June 17, 2020) ##
177
190
 
178
- * Values of enum are frozen, raising an error when attempting to modify them.
191
+ * No changes.
179
192
 
180
- *Emmanuel Byrd*
181
193
 
182
- * `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
183
- if the attribute does not exist.
194
+ ## Rails 6.0.3.1 (May 18, 2020) ##
184
195
 
185
- *Sean Griffin*
196
+ * No changes.
186
197
 
187
- * Do not use prepared statement in queries that have a large number of binds.
188
198
 
189
- *Ryuta Kamizono*
199
+ ## Rails 6.0.3 (May 06, 2020) ##
190
200
 
191
- * Fix query cache to load before first request.
201
+ * Recommend applications don't use the `database` kwarg in `connected_to`
202
+
203
+ The database kwarg in `connected_to` was meant to be used for one-off scripts but is often used in requests. This is really dangerous because it re-establishes a connection every time. It's deprecated in 6.1 and will be removed in 6.2 without replacement. This change soft deprecates it in 6.0 by removing documentation.
192
204
 
193
205
  *Eileen M. Uchitelle*
194
206
 
195
- * Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
207
+ * Fix support for PostgreSQL 11+ partitioned indexes.
196
208
 
197
- Fixes #33056.
209
+ *Sebastián Palma*
198
210
 
199
- *Federico Martinez*
211
+ * Add support for beginless ranges, introduced in Ruby 2.7.
200
212
 
201
- * Fix duplicated record creation when using nested attributes with `create_with`.
213
+ *Josh Goodall*
202
214
 
203
- *Darwin Wu*
215
+ * Fix insert_all with enum values
204
216
 
205
- * Fix regression setting children record in parent `before_save` callback.
217
+ Fixes #38716.
206
218
 
207
- *Guo Xiang Tan*
219
+ *Joel Blum*
208
220
 
209
- * Prevent leaking of user's DB credentials on `rails db:create` failure.
221
+ * Regexp-escape table name for MS SQL
210
222
 
211
- *bogdanvlviv*
223
+ Add `Regexp.escape` to one method in ActiveRecord, so that table names with regular expression characters in them work as expected. Since MS SQL Server uses "[" and "]" to quote table and column names, and those characters are regular expression characters, methods like `pluck` and `select` fail in certain cases when used with the MS SQL Server adapter.
212
224
 
213
- * Clear mutation tracker before continuing the around callbacks.
225
+ *Larry Reid*
214
226
 
215
- *Yuya Tanaka*
227
+ * Store advisory locks on their own named connection.
216
228
 
217
- * Prevent deadlocks when waiting for connection from pool.
229
+ Previously advisory locks were taken out against a connection when a migration started. This works fine in single database applications but doesn't work well when migrations need to open new connections which results in the lock getting dropped.
218
230
 
219
- *Brent Wheeldon*
231
+ In order to fix this we are storing the advisory lock on a new connection with the connection specification name `AdisoryLockBase`. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.
220
232
 
221
- * Avoid extra scoping when using `Relation#update` that was causing this method to change the current scope.
233
+ *Eileen M. Uchitelle*, *John Crepezzi*
222
234
 
223
- *Ryuta Kamizono*
235
+ * Ensure `:reading` connections always raise if a write is attempted.
224
236
 
225
- * Fix numericality validator not to be affected by custom getter.
237
+ Now Rails will raise an `ActiveRecord::ReadOnlyError` if any connection on the reading handler attempts to make a write. If your reading role needs to write you should name the role something other than `:reading`.
226
238
 
227
- *Ryuta Kamizono*
239
+ *Eileen M. Uchitelle*
228
240
 
229
- * Fix bulk change table ignores comment option on PostgreSQL.
241
+ * Enforce fresh ETag header after a collection's contents change by adding
242
+ ActiveRecord::Relation#cache_key_with_version. This method will be used by
243
+ ActionController::ConditionalGet to ensure that when collection cache versioning
244
+ is enabled, requests using ConditionalGet don't return the same ETag header
245
+ after a collection is modified. Fixes #38078.
230
246
 
231
- *Yoshiyuki Kinjo*
247
+ *Aaron Lipman*
232
248
 
249
+ * A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgresSQL `options`.
233
250
 
234
- ## Rails 5.2.1.1 (November 27, 2018) ##
251
+ *Joshua Flanagan*
252
+
253
+ * Retain explicit selections on the base model after applying `includes` and `joins`.
254
+
255
+ Resolves #34889.
256
+
257
+ *Patrick Rebsch*
258
+
259
+
260
+ ## Rails 6.0.2.2 (March 19, 2020) ##
235
261
 
236
262
  * No changes.
237
263
 
238
264
 
239
- ## Rails 5.2.1 (August 07, 2018) ##
265
+ ## Rails 6.0.2.1 (December 18, 2019) ##
240
266
 
241
- * PostgreSQL: Support new relkind for partitioned tables.
267
+ * No changes.
242
268
 
243
- Fixes #33008.
244
269
 
245
- *Yannick Schutz*
270
+ ## Rails 6.0.2 (December 13, 2019) ##
246
271
 
247
- * Rollback parent transaction when children fails to update.
272
+ * Share the same connection pool for primary and replica databases in the
273
+ transactional tests for the same database.
248
274
 
249
- *Guillaume Malette*
275
+ *Edouard Chin*
250
276
 
251
- * Fix default value for MySQL time types with specified precision.
277
+ * Fix the preloader when one record is fetched using `after_initialize`
278
+ but not the entire collection.
252
279
 
253
- *Nikolay Kondratyev*
280
+ *Bradley Price*
254
281
 
255
- * Fix `touch` option to behave consistently with `Persistence#touch` method.
282
+ * Fix collection callbacks not terminating when `:abort` is thrown.
256
283
 
257
- *Ryuta Kamizono*
284
+ *Edouard Chin*, *Ryuta Kamizono*
285
+
286
+ * Correctly deprecate `where.not` working as NOR for relations.
287
+
288
+ 12a9664 deprecated where.not working as NOR, however
289
+ doing a relation query like `where.not(relation: { ... })`
290
+ wouldn't be properly deprecated and `where.not` would work as
291
+ NAND instead.
258
292
 
259
- * Fix `save` in `after_create_commit` won't invoke extra `after_create_commit`.
293
+ *Edouard Chin*
260
294
 
261
- Fixes #32831.
295
+ * Fix `db:migrate` task with multiple databases to restore the connection
296
+ to the previous database.
297
+
298
+ The migrate task iterates and establish a connection over each db
299
+ resulting in the last one to be used by subsequent rake tasks.
300
+ We should reestablish a connection to the connection that was
301
+ established before the migrate tasks was run
302
+
303
+ *Edouard Chin*
304
+
305
+ * Fix multi-threaded issue for `AcceptanceValidator`.
262
306
 
263
307
  *Ryuta Kamizono*
264
308
 
265
- * Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
266
309
 
267
- *Brian Durand*
310
+ ## Rails 6.0.1 (November 5, 2019) ##
268
311
 
269
- * Fix parent record should not get saved with duplicate children records.
312
+ * Common Table Expressions are allowed on read-only connections.
270
313
 
271
- Fixes #32940.
314
+ *Chris Morris*
272
315
 
273
- *Santosh Wadghule*
316
+ * New record instantiation respects `unscope`.
274
317
 
275
- * Fix that association's after_touch is not called with counter cache.
318
+ *Ryuta Kamizono*
276
319
 
277
- Fixes #31559.
320
+ * Fixed a case where `find_in_batches` could halt too early.
278
321
 
279
- *Ryuta Kamizono*
322
+ *Takayuki Nakata*
280
323
 
281
- * `becomes` should clear the mutation tracker which is created in `after_initialize`.
324
+ * Autosaved associations always perform validations when a custom validation
325
+ context is used.
282
326
 
283
- Fixes #32867.
327
+ *Tekin Suleyman*
284
328
 
285
- *Ryuta Kamizono*
329
+ * `sql.active_record` notifications now include the `:connection` in
330
+ their payloads.
286
331
 
287
- * Allow a belonging to parent object to be created from a new record.
332
+ *Eugene Kenny*
288
333
 
289
- *Jolyon Pawlyn*
334
+ * A rollback encountered in an `after_commit` callback does not reset
335
+ previously-committed record state.
290
336
 
291
- * Fix that building record with assigning multiple has_one associations
292
- wrongly persists through record.
337
+ *Ryuta Kamizono*
293
338
 
294
- Fixes #32511.
339
+ * Fixed that join order was lost when eager-loading.
295
340
 
296
- *Sam DeCesare*
341
+ *Ryuta Kamizono*
297
342
 
298
- * Fix relation merging when one of the relations is going to skip the
299
- query cache.
343
+ * `DESCRIBE` queries are allowed on read-only connections.
300
344
 
301
- *James Williams*
345
+ *Dylan Thacker-Smith*
302
346
 
347
+ * Fixed that records that had been `inspect`ed could not be marshaled.
303
348
 
304
- ## Rails 5.2.0 (April 09, 2018) ##
349
+ *Eugene Kenny*
305
350
 
306
- * MySQL: Support mysql2 0.5.x.
351
+ * The connection pool reaper thread is respawned in forked processes. This
352
+ fixes that idle connections in forked processes wouldn't be reaped.
307
353
 
308
- *Aaron Stone*
354
+ *John Hawthorn*
309
355
 
310
- * Apply time column precision on assignment.
356
+ * The memoized result of `ActiveRecord::Relation#take` is properly cleared
357
+ when `ActiveRecord::Relation#reset` or `ActiveRecord::Relation#reload`
358
+ is called.
311
359
 
312
- PR #20317 changed the behavior of datetime columns so that when they
313
- have a specified precision then on assignment the value is rounded to
314
- that precision. This behavior is now applied to time columns as well.
360
+ *Anmol Arora*
315
361
 
316
- Fixes #30301.
362
+ * Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
317
363
 
318
- *Andrew White*
364
+ *Hiroyuki Ishii*
319
365
 
320
- * Normalize time column values for SQLite database.
366
+ * `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
321
367
 
322
- For legacy reasons, time columns in SQLite are stored as full datetimes
323
- because until #24542 the quoting for time columns didn't remove the date
324
- component. To ensure that values are consistent we now normalize the
325
- date component to 2001-01-01 on reading and writing.
368
+ *Eugene Kenny*
326
369
 
327
- *Andrew White*
370
+ * Call `while_preventing_writes` directly from `connected_to`.
328
371
 
329
- * Ensure that the date component is removed when quoting times.
372
+ In some cases application authors want to use the database switching middleware and make explicit calls with `connected_to`. It's possible for an app to turn off writes and not turn them back on by the time we call `connected_to(role: :writing)`.
330
373
 
331
- PR #24542 altered the quoting for time columns so that the date component
332
- was removed however it only removed it when it was 2001-01-01. Now the
333
- date component is removed irrespective of what the date is.
374
+ This change allows apps to fix this by assuming if a role is writing we want to allow writes, except in the case it's explicitly turned off.
334
375
 
335
- *Andrew White*
376
+ *Eileen M. Uchitelle*
336
377
 
337
- * Fix `dependent: :destroy` issue for has_one/belongs_to relationship where
338
- the parent class was getting deleted when the child was not.
378
+ * Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
339
379
 
340
- Fixes #32022.
380
+ *Kir Shatrov*
341
381
 
342
- *Fernando Gorodscy*
343
382
 
344
- * Whitelist `NULLS FIRST` and `NULLS LAST` in order clauses too.
383
+ ## Rails 6.0.0 (August 16, 2019) ##
345
384
 
346
- *Xavier Noria*
385
+ * Preserve user supplied joins order as much as possible.
347
386
 
348
- * Fix that after commit callbacks on update does not triggered when optimistic locking is enabled.
387
+ Fixes #36761, #34328, #24281, #12953.
349
388
 
350
389
  *Ryuta Kamizono*
351
390
 
352
- * Fix `#columns_for_distinct` of MySQL and PostgreSQL to make
353
- `ActiveRecord::FinderMethods#limited_ids_for` use correct primary key values
354
- even if `ORDER BY` columns include other table's primary key.
391
+ * Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
392
+
393
+ *John Crepezzi*, *Eileen Uchitelle*
394
+
395
+ * Add a warning for enum elements with 'not_' prefix.
396
+
397
+ class Foo
398
+ enum status: [:sent, :not_sent]
399
+ end
400
+
401
+ *Edu Depetris*
402
+
403
+ * Make currency symbols optional for money column type in PostgreSQL
355
404
 
356
- Fixes #28364.
405
+ *Joel Schneider*
357
406
 
358
- *Takumi Kagiyama*
359
407
 
360
- * Make `reflection.klass` raise if `polymorphic?` not to be misused.
408
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
361
409
 
362
- Fixes #31876.
410
+ * Add database_exists? method to connection adapters to check if a database exists.
411
+
412
+ *Guilherme Mansur*
413
+
414
+ * PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
415
+
416
+ Fixes #36022.
363
417
 
364
418
  *Ryuta Kamizono*
365
419
 
366
- * PostgreSQL: Allow pg-1.0 gem to be used with Active Record.
420
+ * Make ActiveRecord `ConnectionPool.connections` method thread-safe.
367
421
 
368
- *Lars Kanis*
422
+ Fixes #36465.
369
423
 
370
- * Deprecate `expand_hash_conditions_for_aggregates` without replacement.
371
- Using a `Relation` for performing queries is the prefered API.
424
+ *Jeff Doering*
425
+
426
+ * Fix sqlite3 collation parsing when using decimal columns.
427
+
428
+ *Martin R. Schuster*
429
+
430
+ * Fix invalid schema when primary key column has a comment.
431
+
432
+ Fixes #29966.
433
+
434
+ *Guilherme Goettems Schneider*
435
+
436
+ * Fix table comment also being applied to the primary key column.
437
+
438
+ *Guilherme Goettems Schneider*
439
+
440
+ * Fix merging left_joins to maintain its own `join_type` context.
441
+
442
+ Fixes #36103.
372
443
 
373
444
  *Ryuta Kamizono*
374
445
 
375
- * Fix not expanded problem when passing an Array object as argument to the where method using `composed_of` column.
376
446
 
447
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
448
+
449
+ * Add `touch` option to `has_one` association.
450
+
451
+ *Abhay Nikam*
452
+
453
+ * Deprecate `where.not` working as NOR and will be changed to NAND in Rails 6.1.
454
+
455
+ ```ruby
456
+ all = [treasures(:diamond), treasures(:sapphire), cars(:honda), treasures(:sapphire)]
457
+ assert_equal all, PriceEstimate.all.map(&:estimate_of)
377
458
  ```
378
- david_balance = customers(:david).balance
379
- Customer.where(balance: [david_balance]).to_sql
380
459
 
381
- # Before: WHERE `customers`.`balance` = NULL
382
- # After : WHERE `customers`.`balance` = 50
460
+ In Rails 6.0:
461
+
462
+ ```ruby
463
+ sapphire = treasures(:sapphire)
464
+
465
+ nor = all.reject { |e|
466
+ e.estimate_of_type == sapphire.class.polymorphic_name
467
+ }.reject { |e|
468
+ e.estimate_of_id == sapphire.id
469
+ }
470
+ assert_equal [cars(:honda)], nor
471
+
472
+ without_sapphire = PriceEstimate.where.not(
473
+ estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
474
+ )
475
+ assert_equal nor, without_sapphire.map(&:estimate_of)
383
476
  ```
384
477
 
385
- Fixes #31723.
478
+ In Rails 6.1:
386
479
 
387
- *Yutaro Kanagawa*
480
+ ```ruby
481
+ sapphire = treasures(:sapphire)
388
482
 
389
- * Fix `count(:all)` with eager loading and having an order other than the driving table.
483
+ nand = all - [sapphire]
484
+ assert_equal [treasures(:diamond), cars(:honda)], nand
390
485
 
391
- Fixes #31783.
486
+ without_sapphire = PriceEstimate.where.not(
487
+ estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
488
+ )
489
+ assert_equal nand, without_sapphire.map(&:estimate_of)
490
+ ```
392
491
 
393
492
  *Ryuta Kamizono*
394
493
 
395
- * Clear the transaction state when an Active Record object is duped.
494
+ * Fix dirty tracking after rollback.
396
495
 
397
- Fixes #31670.
496
+ Fixes #15018, #30167, #33868.
398
497
 
399
- *Yuriy Ustushenko*
498
+ *Ryuta Kamizono*
400
499
 
401
- * Support for PostgreSQL foreign tables.
500
+ * Add `ActiveRecord::Relation#cache_version` to support recyclable cache keys via
501
+ the versioned entries in `ActiveSupport::Cache`. This also means that
502
+ `ActiveRecord::Relation#cache_key` will now return a stable key that does not
503
+ include the max timestamp or count any more.
402
504
 
403
- *fatkodima*
505
+ NOTE: This feature is turned off by default, and `cache_key` will still return
506
+ cache keys with timestamps until you set `ActiveRecord::Base.collection_cache_versioning = true`.
507
+ That's the setting for all new apps on Rails 6.0+
404
508
 
405
- * Fix relation merger issue with `left_outer_joins`.
509
+ *Lachlan Sylvester*
406
510
 
407
- *Mehmet Emin İNAÇ*
511
+ * Fix dirty tracking for `touch` to track saved changes.
512
+
513
+ Fixes #33429.
514
+
515
+ *Ryuta Kamzono*
408
516
 
409
- * Don't allow destroyed object mutation after `save` or `save!` is called.
517
+ * `change_column_comment` and `change_table_comment` are invertible only if
518
+ `to` and `from` options are specified.
519
+
520
+ *Yoshiyuki Kinjo*
521
+
522
+ * Don't call commit/rollback callbacks when a record isn't saved.
523
+
524
+ Fixes #29747.
410
525
 
411
526
  *Ryuta Kamizono*
412
527
 
413
- * Take into account association conditions when deleting through records.
528
+ * Fix circular `autosave: true` causes invalid records to be saved.
529
+
530
+ Prior to the fix, when there was a circular series of `autosave: true`
531
+ associations, the callback for a `has_many` association was run while
532
+ another instance of the same callback on the same association hadn't
533
+ finished running. When control returned to the first instance of the
534
+ callback, the instance variable had changed, and subsequent associated
535
+ records weren't saved correctly. Specifically, the ID field for the
536
+ `belongs_to` corresponding to the `has_many` was `nil`.
537
+
538
+ Fixes #28080.
414
539
 
415
- Fixes #18424.
540
+ *Larry Reid*
416
541
 
417
- *Piotr Jakubowski*
542
+ * Raise `ArgumentError` for invalid `:limit` and `:precision` like as other options.
418
543
 
419
- * Fix nested `has_many :through` associations on unpersisted parent instances.
544
+ Before:
420
545
 
421
- For example, if you have
546
+ ```ruby
547
+ add_column :items, :attr1, :binary, size: 10 # => ArgumentError
548
+ add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
549
+ add_column :items, :attr3, :integer, limit: 10 # => ActiveRecordError
550
+ add_column :items, :attr4, :datetime, precision: 10 # => ActiveRecordError
551
+ ```
422
552
 
423
- class Post < ActiveRecord::Base
424
- belongs_to :author
425
- has_many :books, through: :author
426
- has_many :subscriptions, through: :books
427
- end
553
+ After:
428
554
 
429
- class Author < ActiveRecord::Base
430
- has_one :post
431
- has_many :books
432
- has_many :subscriptions, through: :books
433
- end
555
+ ```ruby
556
+ add_column :items, :attr1, :binary, size: 10 # => ArgumentError
557
+ add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
558
+ add_column :items, :attr3, :integer, limit: 10 # => ArgumentError
559
+ add_column :items, :attr4, :datetime, precision: 10 # => ArgumentError
560
+ ```
434
561
 
435
- class Book < ActiveRecord::Base
436
- belongs_to :author
437
- has_many :subscriptions
438
- end
562
+ *Ryuta Kamizono*
439
563
 
440
- class Subscription < ActiveRecord::Base
441
- belongs_to :book
442
- end
564
+ * Association loading isn't to be affected by scoping consistently
565
+ whether preloaded / eager loaded or not, with the exception of `unscoped`.
443
566
 
444
567
  Before:
445
568
 
446
- If `post` is not persisted, then `post.subscriptions` will be empty.
569
+ ```ruby
570
+ Post.where("1=0").scoping do
571
+ Comment.find(1).post # => nil
572
+ Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
573
+ Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
574
+ end
575
+ ```
447
576
 
448
577
  After:
449
578
 
450
- If `post` is not persisted, then `post.subscriptions` can be set and used
451
- just like it would if `post` were persisted.
579
+ ```ruby
580
+ Post.where("1=0").scoping do
581
+ Comment.find(1).post # => #<Post id: 1, ...>
582
+ Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
583
+ Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
584
+ end
585
+ ```
452
586
 
453
- Fixes #16313.
587
+ Fixes #34638, #35398.
454
588
 
455
- *Zoltan Kiss*
589
+ *Ryuta Kamizono*
456
590
 
457
- * Fixed inconsistency with `first(n)` when used with `limit()`.
458
- The `first(n)` finder now respects the `limit()`, making it consistent
459
- with `relation.to_a.first(n)`, and also with the behavior of `last(n)`.
591
+ * Add `rails db:prepare` to migrate or setup a database.
460
592
 
461
- Fixes #23979.
593
+ Runs `db:migrate` if the database exists or `db:setup` if it doesn't.
462
594
 
463
- *Brian Christian*
595
+ *Roberto Miranda*
464
596
 
465
- * Use `count(:all)` in `HasManyAssociation#count_records` to prevent invalid
466
- SQL queries for association counting.
597
+ * Add `after_save_commit` callback as shortcut for `after_commit :hook, on: [ :create, :update ]`.
467
598
 
468
- *Klas Eskilson*
599
+ *DHH*
469
600
 
470
- * Fix to invoke callbacks when using `update_attribute`.
601
+ * Assign all attributes before calling `build` to ensure the child record is visible in
602
+ `before_add` and `after_add` callbacks for `has_many :through` associations.
471
603
 
472
- *Mike Busch*
604
+ Fixes #33249.
473
605
 
474
- * Fix `count(:all)` to correctly work `distinct` with custom SELECT list.
606
+ *Ryan H. Kerr*
475
607
 
476
- *Ryuta Kamizono*
608
+ * Add `ActiveRecord::Relation#extract_associated` for extracting associated records from a relation.
609
+
610
+ ```
611
+ account.memberships.extract_associated(:user)
612
+ # => Returns collection of User records
613
+ ```
614
+
615
+ *DHH*
477
616
 
478
- * Using subselect for `delete_all` with `limit` or `offset`.
617
+ * Add `ActiveRecord::Relation#annotate` for adding SQL comments to its queries.
479
618
 
480
- *Ryuta Kamizono*
619
+ For example:
481
620
 
482
- * Undefine attribute methods on descendants when resetting column
483
- information.
621
+ ```
622
+ Post.where(id: 123).annotate("this is a comment").to_sql
623
+ # SELECT "posts".* FROM "posts" WHERE "posts"."id" = 123 /* this is a comment */
624
+ ```
625
+
626
+ This can be useful in instrumentation or other analysis of issued queries.
627
+
628
+ *Matt Yoho*
484
629
 
485
- *Chris Salzberg*
630
+ * Support Optimizer Hints.
486
631
 
487
- * Log database query callers.
632
+ In most databases, a way to control the optimizer is by using optimizer hints,
633
+ which can be specified within individual statements.
488
634
 
489
- Add `verbose_query_logs` configuration option to display the caller
490
- of database queries in the log to facilitate N+1 query resolution
491
- and other debugging.
635
+ Example (for MySQL):
492
636
 
493
- Enabled in development only for new and upgraded applications. Not
494
- recommended for use in the production environment since it relies
495
- on Ruby's `Kernel#caller_locations` which is fairly slow.
637
+ Topic.optimizer_hints("MAX_EXECUTION_TIME(50000)", "NO_INDEX_MERGE(topics)")
638
+ # SELECT /*+ MAX_EXECUTION_TIME(50000) NO_INDEX_MERGE(topics) */ `topics`.* FROM `topics`
496
639
 
497
- *Olivier Lacan*
640
+ Example (for PostgreSQL with pg_hint_plan):
498
641
 
499
- * Fix conflicts `counter_cache` with `touch: true` by optimistic locking.
642
+ Topic.optimizer_hints("SeqScan(topics)", "Parallel(topics 8)")
643
+ # SELECT /*+ SeqScan(topics) Parallel(topics 8) */ "topics".* FROM "topics"
644
+
645
+ See also:
646
+
647
+ * https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html
648
+ * https://pghintplan.osdn.jp/pg_hint_plan.html
649
+ * https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgsql/influencing-the-optimizer.html
650
+ * https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017
651
+ * https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.perf.doc/doc/c0070117.html
652
+
653
+ *Ryuta Kamizono*
654
+
655
+ * Fix query attribute method on user-defined attribute to be aware of typecasted value.
656
+
657
+ For example, the following code no longer return false as casted non-empty string:
500
658
 
501
659
  ```
502
- # create_table :posts do |t|
503
- # t.integer :comments_count, default: 0
504
- # t.integer :lock_version
505
- # t.timestamps
506
- # end
507
- class Post < ApplicationRecord
660
+ class Post < ActiveRecord::Base
661
+ attribute :user_defined_text, :text
508
662
  end
509
663
 
510
- # create_table :comments do |t|
511
- # t.belongs_to :post
512
- # end
513
- class Comment < ApplicationRecord
514
- belongs_to :post, touch: true, counter_cache: true
515
- end
664
+ Post.new(user_defined_text: "false").user_defined_text? # => true
516
665
  ```
517
666
 
518
- Before:
519
- ```
520
- post = Post.create!
521
- # => begin transaction
522
- INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
523
- VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
524
- commit transaction
525
-
526
- comment = Comment.create!(post: post)
527
- # => begin transaction
528
- INSERT INTO "comments" ("post_id") VALUES (1)
529
-
530
- UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
531
- "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
532
-
533
- UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
534
- "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
535
- rollback transaction
536
- # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
537
-
538
- Comment.take.destroy!
539
- # => begin transaction
540
- DELETE FROM "comments" WHERE "comments"."id" = 1
541
-
542
- UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
543
- "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
544
-
545
- UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
546
- "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
547
- rollback transaction
548
- # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
549
- ```
667
+ *Yuji Kamijima*
550
668
 
551
- After:
552
- ```
553
- post = Post.create!
554
- # => begin transaction
555
- INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
556
- VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
557
- commit transaction
558
-
559
- comment = Comment.create!(post: post)
560
- # => begin transaction
561
- INSERT INTO "comments" ("post_id") VALUES (1)
562
-
563
- UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
564
- "lock_version" = COALESCE("lock_version", 0) + 1,
565
- "updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
566
- commit transaction
567
-
568
- comment.destroy!
569
- # => begin transaction
570
- DELETE FROM "comments" WHERE "comments"."id" = 1
571
-
572
- UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
573
- "lock_version" = COALESCE("lock_version", 0) + 1,
574
- "updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
575
- commit transaction
576
- ```
669
+ * Quote empty ranges like other empty enumerables.
670
+
671
+ *Patrick Rebsch*
672
+
673
+ * Add `insert_all`/`insert_all!`/`upsert_all` methods to `ActiveRecord::Persistence`,
674
+ allowing bulk inserts akin to the bulk updates provided by `update_all` and
675
+ bulk deletes by `delete_all`.
676
+
677
+ Supports skipping or upserting duplicates through the `ON CONFLICT` syntax
678
+ for PostgreSQL (9.5+) and SQLite (3.24+) and `ON DUPLICATE KEY UPDATE` syntax
679
+ for MySQL.
680
+
681
+ *Bob Lail*
682
+
683
+ * Add `rails db:seed:replant` that truncates tables of each database
684
+ for current environment and loads the seeds.
685
+
686
+ *bogdanvlviv*, *DHH*
577
687
 
578
- Fixes #31199.
688
+ * Add `ActiveRecord::Base.connection.truncate` for SQLite3 adapter.
579
689
 
580
690
  *bogdanvlviv*
581
691
 
582
- * Add support for PostgreSQL operator classes to `add_index`.
692
+ * Deprecate mismatched collation comparison for uniqueness validator.
693
+
694
+ Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.
695
+ To continue case sensitive comparison on the case insensitive column,
696
+ pass `case_sensitive: true` option explicitly to the uniqueness validator.
697
+
698
+ *Ryuta Kamizono*
699
+
700
+ * Add `reselect` method. This is a short-hand for `unscope(:select).select(fields)`.
701
+
702
+ Fixes #27340.
703
+
704
+ *Willian Gustavo Veiga*
705
+
706
+ * Add negative scopes for all enum values.
583
707
 
584
708
  Example:
585
709
 
586
- add_index :users, :name, using: :gist, opclass: { name: :gist_trgm_ops }
710
+ class Post < ActiveRecord::Base
711
+ enum status: %i[ drafted active trashed ]
712
+ end
713
+
714
+ Post.not_drafted # => where.not(status: :drafted)
715
+ Post.not_active # => where.not(status: :active)
716
+ Post.not_trashed # => where.not(status: :trashed)
587
717
 
588
- *Greg Navis*
718
+ *DHH*
719
+
720
+ * Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
721
+
722
+ Fixes #35214.
589
723
 
590
- * Don't allow scopes to be defined which conflict with instance methods on `Relation`.
724
+ *Juani Villarejo*
725
+
726
+
727
+ ## Rails 6.0.0.beta3 (March 11, 2019) ##
728
+
729
+ * No changes.
591
730
 
592
- Fixes #31120.
593
731
 
594
- *kinnrot*
732
+ ## Rails 6.0.0.beta2 (February 25, 2019) ##
595
733
 
596
- * Add new error class `QueryCanceled` which will be raised
597
- when canceling statement due to user request.
734
+ * Fix prepared statements caching to be enabled even when query caching is enabled.
598
735
 
599
736
  *Ryuta Kamizono*
600
737
 
601
- * Add `#up_only` to database migrations for code that is only relevant when
602
- migrating up, e.g. populating a new column.
738
+ * Ensure `update_all` series cares about optimistic locking.
603
739
 
604
- *Rich Daley*
740
+ *Ryuta Kamizono*
605
741
 
606
- * Require raw SQL fragments to be explicitly marked when used in
607
- relation query methods.
742
+ * Don't allow `where` with non numeric string matches to 0 values.
608
743
 
609
- Before:
610
- ```
611
- Article.order("LENGTH(title)")
612
- ```
744
+ *Ryuta Kamizono*
613
745
 
614
- After:
615
- ```
616
- Article.order(Arel.sql("LENGTH(title)"))
617
- ```
746
+ * Introduce `ActiveRecord::Relation#destroy_by` and `ActiveRecord::Relation#delete_by`.
747
+
748
+ `destroy_by` allows relation to find all the records matching the condition and perform
749
+ `destroy_all` on the matched records.
750
+
751
+ Example:
752
+
753
+ Person.destroy_by(name: 'David')
754
+ Person.destroy_by(name: 'David', rating: 4)
755
+
756
+ david = Person.find_by(name: 'David')
757
+ david.posts.destroy_by(id: [1, 2, 3])
758
+
759
+ `delete_by` allows relation to find all the records matching the condition and perform
760
+ `delete_all` on the matched records.
761
+
762
+ Example:
763
+
764
+ Person.delete_by(name: 'David')
765
+ Person.delete_by(name: 'David', rating: 4)
766
+
767
+ david = Person.find_by(name: 'David')
768
+ david.posts.delete_by(id: [1, 2, 3])
769
+
770
+ *Abhay Nikam*
771
+
772
+ * Don't allow `where` with invalid value matches to nil values.
773
+
774
+ Fixes #33624.
775
+
776
+ *Ryuta Kamizono*
777
+
778
+ * SQLite3: Implement `add_foreign_key` and `remove_foreign_key`.
618
779
 
619
- This prevents SQL injection if applications use the [strongly
620
- discouraged] form `Article.order(params[:my_order])`, under the
621
- mistaken belief that only column names will be accepted.
780
+ *Ryuta Kamizono*
781
+
782
+ * Deprecate using class level querying methods if the receiver scope
783
+ regarded as leaked. Use `klass.unscoped` to avoid the leaking scope.
784
+
785
+ *Ryuta Kamizono*
622
786
 
623
- Raw SQL strings will now cause a deprecation warning, which will
624
- become an UnknownAttributeReference error in Rails 6.0. Applications
625
- can opt in to the future behavior by setting `allow_unsafe_raw_sql`
626
- to `:disabled`.
787
+ * Allow applications to automatically switch connections.
788
+
789
+ Adds a middleware and configuration options that can be used in your
790
+ application to automatically switch between the writing and reading
791
+ database connections.
792
+
793
+ `GET` and `HEAD` requests will read from the replica unless there was
794
+ a write in the last 2 seconds, otherwise they will read from the primary.
795
+ Non-get requests will always write to the primary. The middleware accepts
796
+ an argument for a Resolver class and an Operations class where you are able
797
+ to change how the auto-switcher works to be most beneficial for your
798
+ application.
799
+
800
+ To use the middleware in your application you can use the following
801
+ configuration options:
627
802
 
628
- Common and judged-safe string values (such as simple column
629
- references) are unaffected:
630
803
  ```
631
- Article.order("title DESC")
804
+ config.active_record.database_selector = { delay: 2.seconds }
805
+ config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
806
+ config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
632
807
  ```
633
808
 
634
- *Ben Toews*
809
+ To change the database selection strategy, pass a custom class to the
810
+ configuration options:
635
811
 
636
- * `update_all` will now pass its values to `Type#cast` before passing them to
637
- `Type#serialize`. This means that `update_all(foo: 'true')` will properly
638
- persist a boolean.
812
+ ```
813
+ config.active_record.database_selector = { delay: 10.seconds }
814
+ config.active_record.database_resolver = MyResolver
815
+ config.active_record.database_resolver_context = MyResolver::MyCookies
816
+ ```
639
817
 
640
- *Sean Griffin*
818
+ *Eileen M. Uchitelle*
641
819
 
642
- * Add new error class `StatementTimeout` which will be raised
643
- when statement timeout exceeded.
820
+ * MySQL: Support `:size` option to change text and blob size.
644
821
 
645
822
  *Ryuta Kamizono*
646
823
 
647
- * Fix `bin/rails db:migrate` with specified `VERSION`.
648
- `bin/rails db:migrate` with empty VERSION behaves as without `VERSION`.
649
- Check a format of `VERSION`: Allow a migration version number
650
- or name of a migration file. Raise error if format of `VERSION` is invalid.
651
- Raise error if target migration doesn't exist.
652
-
653
- *bogdanvlviv*
824
+ * Make `t.timestamps` with precision by default.
654
825
 
655
- * Fixed a bug where column orders for an index weren't written to
656
- `db/schema.rb` when using the sqlite adapter.
826
+ *Ryuta Kamizono*
657
827
 
658
- Fixes #30902.
659
828
 
660
- *Paul Kuruvilla*
829
+ ## Rails 6.0.0.beta1 (January 18, 2019) ##
661
830
 
662
- * Remove deprecated method `#sanitize_conditions`.
831
+ * Remove deprecated `#set_state` from the transaction object.
663
832
 
664
833
  *Rafael Mendonça França*
665
834
 
666
- * Remove deprecated method `#scope_chain`.
835
+ * Remove deprecated `#supports_statement_cache?` from the database adapters.
667
836
 
668
837
  *Rafael Mendonça França*
669
838
 
670
- * Remove deprecated configuration `.error_on_ignored_order_or_limit`.
839
+ * Remove deprecated `#insert_fixtures` from the database adapters.
671
840
 
672
841
  *Rafael Mendonça França*
673
842
 
674
- * Remove deprecated arguments from `#verify!`.
843
+ * Remove deprecated `ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?`.
675
844
 
676
845
  *Rafael Mendonça França*
677
846
 
678
- * Remove deprecated argument `name` from `#indexes`.
847
+ * Do not allow passing the column name to `sum` when a block is passed.
679
848
 
680
849
  *Rafael Mendonça França*
681
850
 
682
- * Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`.
851
+ * Do not allow passing the column name to `count` when a block is passed.
683
852
 
684
853
  *Rafael Mendonça França*
685
854
 
686
- * Remove deprecated method `supports_primary_key?`.
855
+ * Remove delegation of missing methods in a relation to arel.
687
856
 
688
857
  *Rafael Mendonça França*
689
858
 
690
- * Remove deprecated method `supports_migrations?`.
859
+ * Remove delegation of missing methods in a relation to private methods of the class.
691
860
 
692
861
  *Rafael Mendonça França*
693
862
 
694
- * Remove deprecated methods `initialize_schema_migrations_table` and `initialize_internal_metadata_table`.
863
+ * Deprecate `config.active_record.sqlite3.represent_boolean_as_integer`.
695
864
 
696
865
  *Rafael Mendonça França*
697
866
 
698
- * Raises when calling `lock!` in a dirty record.
867
+ * Change `SQLite3Adapter` to always represent boolean values as integers.
699
868
 
700
869
  *Rafael Mendonça França*
701
870
 
702
- * Remove deprecated support to passing a class to `:class_name` on associations.
871
+ * Remove ability to specify a timestamp name for `#cache_key`.
703
872
 
704
873
  *Rafael Mendonça França*
705
874
 
706
- * Remove deprecated argument `default` from `index_name_exists?`.
875
+ * Remove deprecated `ActiveRecord::Migrator.migrations_path=`.
707
876
 
708
877
  *Rafael Mendonça França*
709
878
 
710
- * Remove deprecated support to `quoted_id` when typecasting an Active Record object.
879
+ * Remove deprecated `expand_hash_conditions_for_aggregates`.
711
880
 
712
881
  *Rafael Mendonça França*
713
882
 
714
- * Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong
715
- ar_internal_metadata's data for a test database.
883
+ * Set polymorphic type column to NULL on `dependent: :nullify` strategy.
716
884
 
717
- Before:
718
- ```
719
- $ RAILS_ENV=test rails dbconsole
720
- > SELECT * FROM ar_internal_metadata;
721
- key|value|created_at|updated_at
722
- environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
723
- ```
885
+ On polymorphic associations both the foreign key and the foreign type columns will be set to NULL.
724
886
 
725
- After:
726
- ```
727
- $ RAILS_ENV=test rails dbconsole
728
- > SELECT * FROM ar_internal_metadata;
729
- key|value|created_at|updated_at
730
- environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
731
- ```
887
+ *Laerti Papa*
732
888
 
733
- Fixes #26731.
889
+ * Allow permitted instance of `ActionController::Parameters` as argument of `ActiveRecord::Relation#exists?`.
734
890
 
735
- *bogdanvlviv*
891
+ *Gannon McGibbon*
736
892
 
737
- * Fix longer sequence name detection for serial columns.
893
+ * Add support for endless ranges introduces in Ruby 2.6.
894
+
895
+ *Greg Navis*
738
896
 
739
- Fixes #28332.
897
+ * Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`.
740
898
 
741
899
  *Ryuta Kamizono*
742
900
 
743
- * MySQL: Don't lose `auto_increment: true` in the `db/schema.rb`.
901
+ * MySQL: `ROW_FORMAT=DYNAMIC` create table option by default.
744
902
 
745
- Fixes #30894.
903
+ Since MySQL 5.7.9, the `innodb_default_row_format` option defines the default row
904
+ format for InnoDB tables. The default setting is `DYNAMIC`.
905
+ The row format is required for indexing on `varchar(255)` with `utf8mb4` columns.
746
906
 
747
907
  *Ryuta Kamizono*
748
908
 
749
- * Fix `COUNT(DISTINCT ...)` for `GROUP BY` with `ORDER BY` and `LIMIT`.
909
+ * Fix join table column quoting with SQLite.
910
+
911
+ *Gannon McGibbon*
912
+
913
+ * Allow disabling scopes generated by `ActiveRecord.enum`.
750
914
 
751
- Fixes #30886.
915
+ *Alfred Dominic*
916
+
917
+ * Ensure that `delete_all` on collection proxy returns affected count.
752
918
 
753
919
  *Ryuta Kamizono*
754
920
 
755
- * PostgreSQL `tsrange` now preserves subsecond precision.
921
+ * Reset scope after delete on collection association to clear stale offsets of removed records.
756
922
 
757
- PostgreSQL 9.1+ introduced range types, and Rails added support for using
758
- this datatype in Active Record. However, the serialization of
759
- `PostgreSQL::OID::Range` was incomplete, because it did not properly
760
- cast the bounds that make up the range. This led to subseconds being
761
- dropped in SQL commands:
923
+ *Gannon McGibbon*
762
924
 
763
- Before:
925
+ * Add the ability to prevent writes to a database for the duration of a block.
764
926
 
765
- connection.type_cast(tsrange.serialize(range_value))
766
- # => "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
927
+ Allows the application to prevent writes to a database. This can be useful when
928
+ you're building out multiple databases and want to make sure you're not sending
929
+ writes when you want a read.
767
930
 
768
- Now:
931
+ If `while_preventing_writes` is called and the query is considered a write
932
+ query the database will raise an exception regardless of whether the database
933
+ user is able to write.
769
934
 
770
- connection.type_cast(tsrange.serialize(range_value))
771
- # => "[2010-01-01 13:30:00.670277,2011-02-02 19:30:00.745125)"
935
+ This is not meant to be a catch-all for write queries but rather a way to enforce
936
+ read-only queries without opening a second connection. One purpose of this is to
937
+ catch accidental writes, not all writes.
772
938
 
773
- *Thomas Cannon*
939
+ *Eileen M. Uchitelle*
774
940
 
775
- * Passing a `Set` to `Relation#where` now behaves the same as passing an
776
- array.
941
+ * Allow aliased attributes to be used in `#update_columns` and `#update`.
777
942
 
778
- *Sean Griffin*
943
+ *Gannon McGibbon*
779
944
 
780
- * Use given algorithm while removing index from database.
945
+ * Allow spaces in postgres table names.
781
946
 
782
- Fixes #24190.
947
+ Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres adapter.
783
948
 
784
- *Mehmet Emin İNAÇ*
949
+ *Gannon McGibbon*
785
950
 
786
- * Update payload names for `sql.active_record` instrumentation to be
787
- more descriptive.
951
+ * Cached `columns_hash` fields should be excluded from `ResultSet#column_types`.
788
952
 
789
- Fixes #30586.
953
+ PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
954
+ was passing for SQLite and MySQL, but failed for PostgreSQL:
790
955
 
791
- *Jeremy Green*
956
+ ```ruby
957
+ class DeveloperName < ActiveRecord::Type::String
958
+ def deserialize(value)
959
+ "Developer: #{value}"
960
+ end
961
+ end
792
962
 
793
- * Add new error class `LockWaitTimeout` which will be raised
794
- when lock wait timeout exceeded.
963
+ class AttributedDeveloper < ActiveRecord::Base
964
+ self.table_name = "developers"
795
965
 
796
- *Gabriel Courtemanche*
966
+ attribute :name, DeveloperName.new
797
967
 
798
- * Remove deprecated `#migration_keys`.
968
+ self.ignored_columns += ["name"]
969
+ end
799
970
 
800
- *Ryuta Kamizono*
971
+ developer = AttributedDeveloper.create
972
+ developer.update_column :name, "name"
801
973
 
802
- * Automatically guess the inverse associations for STI.
974
+ loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
975
+ puts loaded_developer.name # should be "Developer: name" but it's just "name"
976
+ ```
803
977
 
804
- *Yuichiro Kaneko*
978
+ *Dmitry Tsepelev*
805
979
 
806
- * Ensure `sum` honors `distinct` on `has_many :through` associations.
980
+ * Make the implicit order column configurable.
807
981
 
808
- Fixes #16791.
982
+ When calling ordered finder methods such as `first` or `last` without an
983
+ explicit order clause, ActiveRecord sorts records by primary key. This can
984
+ result in unpredictable and surprising behaviour when the primary key is
985
+ not an auto-incrementing integer, for example when it's a UUID. This change
986
+ makes it possible to override the column used for implicit ordering such
987
+ that `first` and `last` will return more predictable results.
809
988
 
810
- *Aaron Wortham*
989
+ Example:
811
990
 
812
- * Add `binary` fixture helper method.
991
+ class Project < ActiveRecord::Base
992
+ self.implicit_order_column = "created_at"
993
+ end
813
994
 
814
- *Atsushi Yoshida*
995
+ *Tekin Suleyman*
815
996
 
816
- * When using `Relation#or`, extract the common conditions and put them before the OR condition.
997
+ * Bump minimum PostgreSQL version to 9.3.
817
998
 
818
- *Maxime Handfield Lapointe*
999
+ *Yasuo Honda*
819
1000
 
820
- * `Relation#or` now accepts two relations who have different values for
821
- `references` only, as `references` can be implicitly called by `where`.
1001
+ * Values of enum are frozen, raising an error when attempting to modify them.
822
1002
 
823
- Fixes #29411.
1003
+ *Emmanuel Byrd*
1004
+
1005
+ * Move `ActiveRecord::StatementInvalid` SQL to error property and include binds as separate error property.
1006
+
1007
+ `ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception_class` now requires `binds` to be passed as the last argument.
1008
+
1009
+ `ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception` now requires `message`, `sql`, and `binds` to be passed as keyword arguments.
1010
+
1011
+ Subclasses of `ActiveRecord::StatementInvalid` must now provide `sql:` and `binds:` arguments to `super`.
1012
+
1013
+ Example:
1014
+
1015
+ ```
1016
+ class MySubclassedError < ActiveRecord::StatementInvalid
1017
+ def initialize(message, sql:, binds:)
1018
+ super(message, sql: sql, binds: binds)
1019
+ end
1020
+ end
1021
+ ```
1022
+
1023
+ *Gannon McGibbon*
1024
+
1025
+ * Add an `:if_not_exists` option to `create_table`.
1026
+
1027
+ Example:
1028
+
1029
+ create_table :posts, if_not_exists: true do |t|
1030
+ t.string :title
1031
+ end
1032
+
1033
+ That would execute:
1034
+
1035
+ CREATE TABLE IF NOT EXISTS posts (
1036
+ ...
1037
+ )
1038
+
1039
+ If the table already exists, `if_not_exists: false` (the default) raises an
1040
+ exception whereas `if_not_exists: true` does nothing.
1041
+
1042
+ *fatkodima*, *Stefan Kanev*
1043
+
1044
+ * Defining an Enum as a Hash with blank key, or as an Array with a blank value, now raises an `ArgumentError`.
1045
+
1046
+ *Christophe Maximin*
1047
+
1048
+ * Adds support for multiple databases to `rails db:schema:cache:dump` and `rails db:schema:cache:clear`.
1049
+
1050
+ *Gannon McGibbon*
1051
+
1052
+ * `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
1053
+ if the attribute does not exist.
824
1054
 
825
1055
  *Sean Griffin*
826
1056
 
827
- * `ApplicationRecord` is no longer generated when generating models. If you
828
- need to generate it, it can be created with `rails g application_record`.
1057
+ * Add support for hash and URL configs in database hash of `ActiveRecord::Base.connected_to`.
1058
+
1059
+ ````
1060
+ User.connected_to(database: { writing: "postgres://foo" }) do
1061
+ User.create!(name: "Gannon")
1062
+ end
1063
+
1064
+ config = { "adapter" => "sqlite3", "database" => "db/readonly.sqlite3" }
1065
+ User.connected_to(database: { reading: config }) do
1066
+ User.count
1067
+ end
1068
+ ````
1069
+
1070
+ *Gannon McGibbon*
1071
+
1072
+ * Support default expression for MySQL.
1073
+
1074
+ MySQL 8.0.13 and higher supports default value to be a function or expression.
1075
+
1076
+ https://dev.mysql.com/doc/refman/8.0/en/create-table.html
829
1077
 
830
- *Lisa Ugray*
1078
+ *Ryuta Kamizono*
1079
+
1080
+ * Support expression indexes for MySQL.
831
1081
 
832
- * Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing select list.
1082
+ MySQL 8.0.13 and higher supports functional key parts that index
1083
+ expression values rather than column or column prefix values.
1084
+
1085
+ https://dev.mysql.com/doc/refman/8.0/en/create-index.html
833
1086
 
834
1087
  *Ryuta Kamizono*
835
1088
 
836
- * When a `has_one` association is destroyed by `dependent: destroy`,
837
- `destroyed_by_association` will now be set to the reflection, matching the
838
- behaviour of `has_many` associations.
1089
+ * Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
1090
+
1091
+ Fixes #33056.
839
1092
 
840
- *Lisa Ugray*
1093
+ *Federico Martinez*
841
1094
 
842
- * Fix `unscoped(where: [columns])` removing the wrong bind values.
1095
+ * Add basic API for connection switching to support multiple databases.
843
1096
 
844
- When the `where` is called on a relation after a `or`, unscoping the column of that later `where` removed
845
- bind values used by the `or` instead. (possibly other cases too)
1097
+ 1) Adds a `connects_to` method for models to connect to multiple databases. Example:
846
1098
 
847
1099
  ```
848
- Post.where(id: 1).or(Post.where(id: 2)).where(foo: 3).unscope(where: :foo).to_sql
849
- # Currently:
850
- # SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR "posts"."id" = 3)
851
- # With fix:
852
- # SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."id" = 2)
1100
+ class AnimalsModel < ApplicationRecord
1101
+ self.abstract_class = true
1102
+
1103
+ connects_to database: { writing: :animals_primary, reading: :animals_replica }
1104
+ end
1105
+
1106
+ class Dog < AnimalsModel
1107
+ # connected to both the animals_primary db for writing and the animals_replica for reading
1108
+ end
853
1109
  ```
854
1110
 
855
- *Maxime Handfield Lapointe*
1111
+ 2) Adds a `connected_to` block method for switching connection roles or connecting to
1112
+ a database that the model didn't connect to. Connecting to the database in this block is
1113
+ useful when you have another defined connection, for example `slow_replica` that you don't
1114
+ want to connect to by default but need in the console, or a specific code block.
856
1115
 
857
- * Values constructed using multi-parameter assignment will now use the
858
- post-type-cast value for rendering in single-field form inputs.
1116
+ ```
1117
+ ActiveRecord::Base.connected_to(role: :reading) do
1118
+ Dog.first # finds dog from replica connected to AnimalsBase
1119
+ Book.first # doesn't have a reading connection, will raise an error
1120
+ end
1121
+ ```
859
1122
 
860
- *Sean Griffin*
1123
+ ```
1124
+ ActiveRecord::Base.connected_to(database: :slow_replica) do
1125
+ SlowReplicaModel.first # if the db config has a slow_replica configuration this will be used to do the lookup, otherwise this will throw an exception
1126
+ end
1127
+ ```
861
1128
 
862
- * `Relation#joins` is no longer affected by the target model's
863
- `current_scope`, with the exception of `unscoped`.
1129
+ *Eileen M. Uchitelle*
864
1130
 
865
- Fixes #29338.
1131
+ * Enum raises on invalid definition values
866
1132
 
867
- *Sean Griffin*
1133
+ When defining a Hash enum it can be easy to use `[]` instead of `{}`. This
1134
+ commit checks that only valid definition values are provided, those can
1135
+ be a Hash, an array of Symbols or an array of Strings. Otherwise it
1136
+ raises an `ArgumentError`.
868
1137
 
869
- * Change sqlite3 boolean serialization to use 1 and 0.
1138
+ Fixes #33961
870
1139
 
871
- SQLite natively recognizes 1 and 0 as true and false, but does not natively
872
- recognize 't' and 'f' as was previously serialized.
1140
+ *Alberto Almagro*
873
1141
 
874
- This change in serialization requires a migration of stored boolean data
875
- for SQLite databases, so it's implemented behind a configuration flag
876
- whose default false value is deprecated.
1142
+ * Reloading associations now clears the Query Cache like `Persistence#reload` does.
877
1143
 
878
- *Lisa Ugray*
1144
+ ```
1145
+ class Post < ActiveRecord::Base
1146
+ has_one :category
1147
+ belongs_to :author
1148
+ has_many :comments
1149
+ end
879
1150
 
880
- * Skip query caching when working with batches of records (`find_each`, `find_in_batches`,
881
- `in_batches`).
1151
+ # Each of the following will now clear the query cache.
1152
+ post.reload_category
1153
+ post.reload_author
1154
+ post.comments.reload
1155
+ ```
882
1156
 
883
- Previously, records would be fetched in batches, but all records would be retained in memory
884
- until the end of the request or job.
1157
+ *Christophe Maximin*
885
1158
 
886
- *Eugene Kenny*
1159
+ * Added `index` option for `change_table` migration helpers.
1160
+ With this change you can create indexes while adding new
1161
+ columns into the existing tables.
887
1162
 
888
- * Prevent errors raised by `sql.active_record` notification subscribers from being converted into
889
- `ActiveRecord::StatementInvalid` exceptions.
1163
+ Example:
1164
+
1165
+ change_table(:languages) do |t|
1166
+ t.string :country_code, index: true
1167
+ end
1168
+
1169
+ *Mehmet Emin İNAÇ*
1170
+
1171
+ * Fix `transaction` reverting for migrations.
1172
+
1173
+ Before: Commands inside a `transaction` in a reverted migration ran uninverted.
1174
+ Now: This change fixes that by reverting commands inside `transaction` block.
1175
+
1176
+ *fatkodima*, *David Verhasselt*
890
1177
 
891
- *Dennis Taylor*
1178
+ * Raise an error instead of scanning the filesystem root when `fixture_path` is blank.
892
1179
 
893
- * Fix eager loading/preloading association with scope including joins.
1180
+ *Gannon McGibbon*, *Max Albrecht*
894
1181
 
895
- Fixes #28324.
1182
+ * Allow `ActiveRecord::Base.configurations=` to be set with a symbolized hash.
1183
+
1184
+ *Gannon McGibbon*
1185
+
1186
+ * Don't update counter cache unless the record is actually saved.
1187
+
1188
+ Fixes #31493, #33113, #33117.
896
1189
 
897
1190
  *Ryuta Kamizono*
898
1191
 
899
- * Fix transactions to apply state to child transactions.
1192
+ * Deprecate `ActiveRecord::Result#to_hash` in favor of `ActiveRecord::Result#to_a`.
900
1193
 
901
- Previously, if you had a nested transaction and the outer transaction was rolledback, the record from the
902
- inner transaction would still be marked as persisted.
1194
+ *Gannon McGibbon*, *Kevin Cheng*
903
1195
 
904
- This change fixes that by applying the state of the parent transaction to the child transaction when the
905
- parent transaction is rolledback. This will correctly mark records from the inner transaction as not persisted.
1196
+ * SQLite3 adapter supports expression indexes.
906
1197
 
907
- *Eileen M. Uchitelle*, *Aaron Patterson*
1198
+ ```
1199
+ create_table :users do |t|
1200
+ t.string :email
1201
+ end
908
1202
 
909
- * Deprecate `set_state` method in `TransactionState`.
1203
+ add_index :users, 'lower(email)', name: 'index_users_on_email', unique: true
1204
+ ```
910
1205
 
911
- Deprecated the `set_state` method in favor of setting the state via specific methods. If you need to mark the
912
- state of the transaction you can now use `rollback!`, `commit!` or `nullify!` instead of
913
- `set_state(:rolledback)`, `set_state(:committed)`, or `set_state(nil)`.
1206
+ *Gray Kemmey*
914
1207
 
915
- *Eileen M. Uchitelle*, *Aaron Patterson*
1208
+ * Allow subclasses to redefine autosave callbacks for associated records.
1209
+
1210
+ Fixes #33305.
1211
+
1212
+ *Andrey Subbota*
1213
+
1214
+ * Bump minimum MySQL version to 5.5.8.
1215
+
1216
+ *Yasuo Honda*
1217
+
1218
+ * Use MySQL utf8mb4 character set by default.
1219
+
1220
+ `utf8mb4` character set with 4-Byte encoding supports supplementary characters including emoji.
1221
+ The previous default 3-Byte encoding character set `utf8` is not enough to support them.
1222
+
1223
+ *Yasuo Honda*
1224
+
1225
+ * Fix duplicated record creation when using nested attributes with `create_with`.
1226
+
1227
+ *Darwin Wu*
1228
+
1229
+ * Configuration item `config.filter_parameters` could also filter out
1230
+ sensitive values of database columns when calling `#inspect`.
1231
+ We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
1232
+ specify sensitive attributes to specific model.
1233
+
1234
+ ```
1235
+ Rails.application.config.filter_parameters += [:credit_card_number, /phone/]
1236
+ Account.last.inspect # => #<Account id: 123, name: "DHH", credit_card_number: [FILTERED], telephone_number: [FILTERED] ...>
1237
+ SecureAccount.filter_attributes += [:name]
1238
+ SecureAccount.last.inspect # => #<SecureAccount id: 42, name: [FILTERED], credit_card_number: [FILTERED] ...>
1239
+ ```
1240
+
1241
+ *Zhang Kang*, *Yoshiyuki Kinjo*
916
1242
 
917
- * Deprecate delegating to `arel` in `Relation`.
1243
+ * Deprecate `column_name_length`, `table_name_length`, `columns_per_table`,
1244
+ `indexes_per_table`, `columns_per_multicolumn_index`, `sql_query_length`,
1245
+ and `joins_per_query` methods in `DatabaseLimits`.
918
1246
 
919
1247
  *Ryuta Kamizono*
920
1248
 
921
- * Query cache was unavailable when entering the `ActiveRecord::Base.cache` block
922
- without being connected.
1249
+ * `ActiveRecord::Base.configurations` now returns an object.
923
1250
 
924
- *Tsukasa Oishi*
1251
+ `ActiveRecord::Base.configurations` used to return a hash, but this
1252
+ is an inflexible data model. In order to improve multiple-database
1253
+ handling in Rails, we've changed this to return an object. Some methods
1254
+ are provided to make the object behave hash-like in order to ease the
1255
+ transition process. Since most applications don't manipulate the hash
1256
+ we've decided to add backwards-compatible functionality that will throw
1257
+ a deprecation warning if used, however calling `ActiveRecord::Base.configurations`
1258
+ will use the new version internally and externally.
925
1259
 
926
- * Previously, when building records using a `has_many :through` association,
927
- if the child records were deleted before the parent was saved, they would
928
- still be persisted. Now, if child records are deleted before the parent is saved
929
- on a `has_many :through` association, the child records will not be persisted.
1260
+ For example, the following `database.yml`:
1261
+
1262
+ ```
1263
+ development:
1264
+ adapter: sqlite3
1265
+ database: db/development.sqlite3
1266
+ ```
930
1267
 
931
- *Tobias Kraze*
1268
+ Used to become a hash:
932
1269
 
933
- * Merging two relations representing nested joins no longer transforms the joins of
934
- the merged relation into LEFT OUTER JOIN.
1270
+ ```
1271
+ { "development" => { "adapter" => "sqlite3", "database" => "db/development.sqlite3" } }
1272
+ ```
935
1273
 
936
- Example:
1274
+ Is now converted into the following object:
937
1275
 
938
1276
  ```
939
- Author.joins(:posts).merge(Post.joins(:comments))
940
- # Before the change:
941
- #=> SELECT ... FROM authors INNER JOIN posts ON ... LEFT OUTER JOIN comments ON...
1277
+ #<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800 @configurations=[
1278
+ #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",
1279
+ @spec_name="primary", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
1280
+ ]
1281
+ ```
1282
+
1283
+ Iterating over the database configurations has also changed. Instead of
1284
+ calling hash methods on the `configurations` hash directly, a new method `configs_for` has
1285
+ been provided that allows you to select the correct configuration. `env_name` and
1286
+ `spec_name` arguments are optional. For example, these return an array of
1287
+ database config objects for the requested environment and a single database config object
1288
+ will be returned for the requested environment and specification name respectively.
942
1289
 
943
- # After the change:
944
- #=> SELECT ... FROM authors INNER JOIN posts ON ... INNER JOIN comments ON...
1290
+ ```
1291
+ ActiveRecord::Base.configurations.configs_for(env_name: "development")
1292
+ ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
945
1293
  ```
946
1294
 
947
- *Maxime Handfield Lapointe*
1295
+ *Eileen M. Uchitelle*, *Aaron Patterson*
948
1296
 
949
- * `ActiveRecord::Persistence#touch` does not work well when optimistic locking enabled and
950
- `locking_column`, without default value, is null in the database.
1297
+ * Add database configuration to disable advisory locks.
951
1298
 
952
- *bogdanvlviv*
1299
+ ```
1300
+ production:
1301
+ adapter: postgresql
1302
+ advisory_locks: false
1303
+ ```
953
1304
 
954
- * Fix destroying existing object does not work well when optimistic locking enabled and
955
- `locking_column` is null in the database.
1305
+ *Guo Xiang*
956
1306
 
957
- *bogdanvlviv*
1307
+ * SQLite3 adapter `alter_table` method restores foreign keys.
958
1308
 
959
- * Use bulk INSERT to insert fixtures for better performance.
1309
+ *Yasuo Honda*
960
1310
 
961
- *Kir Shatrov*
1311
+ * Allow `:to_table` option to `invert_remove_foreign_key`.
1312
+
1313
+ Example:
962
1314
 
963
- * Prevent creation of bind param if casted value is nil.
1315
+ remove_foreign_key :accounts, to_table: :owners
964
1316
 
965
- *Ryuta Kamizono*
1317
+ *Nikolay Epifanov*, *Rich Chen*
1318
+
1319
+ * Add environment & load_config dependency to `bin/rake db:seed` to enable
1320
+ seed load in environments without Rails and custom DB configuration
1321
+
1322
+ *Tobias Bielohlawek*
1323
+
1324
+ * Fix default value for mysql time types with specified precision.
1325
+
1326
+ *Nikolay Kondratyev*
966
1327
 
967
- * Deprecate passing arguments and block at the same time to `count` and `sum` in `ActiveRecord::Calculations`.
1328
+ * Fix `touch` option to behave consistently with `Persistence#touch` method.
968
1329
 
969
1330
  *Ryuta Kamizono*
970
1331
 
971
- * Loading model schema from database is now thread-safe.
1332
+ * Migrations raise when duplicate column definition.
972
1333
 
973
- Fixes #28589.
1334
+ Fixes #33024.
974
1335
 
975
- *Vikrant Chaudhary*, *David Abdemoulaie*
1336
+ *Federico Martinez*
976
1337
 
977
- * Add `ActiveRecord::Base#cache_version` to support recyclable cache keys via the new versioned entries
978
- in `ActiveSupport::Cache`. This also means that `ActiveRecord::Base#cache_key` will now return a stable key
979
- that does not include a timestamp any more.
1338
+ * Bump minimum SQLite version to 3.8
980
1339
 
981
- NOTE: This feature is turned off by default, and `#cache_key` will still return cache keys with timestamps
982
- until you set `ActiveRecord::Base.cache_versioning = true`. That's the setting for all new apps on Rails 5.2+
1340
+ *Yasuo Honda*
983
1341
 
984
- *DHH*
1342
+ * Fix parent record should not get saved with duplicate children records.
985
1343
 
986
- * Respect `SchemaDumper.ignore_tables` in rake tasks for databases structure dump.
1344
+ Fixes #32940.
987
1345
 
988
- *Rusty Geldmacher*, *Guillermo Iguaran*
1346
+ *Santosh Wadghule*
989
1347
 
990
- * Add type caster to `RuntimeReflection#alias_name`.
1348
+ * Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
991
1349
 
992
- Fixes #28959.
1350
+ *Brian Durand*
993
1351
 
994
- *Jon Moss*
1352
+ * Ensure `Associations::CollectionAssociation#size` and `Associations::CollectionAssociation#empty?`
1353
+ use loaded association ids if present.
995
1354
 
996
- * Deprecate `supports_statement_cache?`.
1355
+ *Graham Turner*
997
1356
 
998
- *Ryuta Kamizono*
1357
+ * Add support to preload associations of polymorphic associations when not all the records have the requested associations.
999
1358
 
1000
- * Raise error `UnknownMigrationVersionError` on the movement of migrations
1001
- when the current migration does not exist.
1359
+ *Dana Sherson*
1002
1360
 
1003
- *bogdanvlviv*
1361
+ * Add `touch_all` method to `ActiveRecord::Relation`.
1362
+
1363
+ Example:
1004
1364
 
1005
- * Fix `bin/rails db:forward` first migration.
1365
+ Person.where(name: "David").touch_all(time: Time.new(2020, 5, 16, 0, 0, 0))
1006
1366
 
1007
- *bogdanvlviv*
1367
+ *fatkodima*, *duggiefresh*
1008
1368
 
1009
- * Support Descending Indexes for MySQL.
1369
+ * Add `ActiveRecord::Base.base_class?` predicate.
1010
1370
 
1011
- MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored.
1012
- See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
1371
+ *Bogdan Gusiev*
1013
1372
 
1014
- *Ryuta Kamizono*
1373
+ * Add custom prefix/suffix options to `ActiveRecord::Store.store_accessor`.
1015
1374
 
1016
- * Fix inconsistency with changed attributes when overriding Active Record attribute reader.
1375
+ *Tan Huynh*, *Yukio Mizuta*
1017
1376
 
1018
- *bogdanvlviv*
1377
+ * Rails 6 requires Ruby 2.5.0 or newer.
1019
1378
 
1020
- * When calling the dynamic fixture accessor method with no arguments, it now returns all fixtures of this type.
1021
- Previously this method always returned an empty array.
1379
+ *Jeremy Daer*, *Kasper Timm Hansen*
1022
1380
 
1023
- *Kevin McPhillips*
1381
+ * Deprecate `update_attributes`/`!` in favor of `update`/`!`.
1382
+
1383
+ *Eddie Lebow*
1384
+
1385
+ * Add `ActiveRecord::Base.create_or_find_by`/`!` to deal with the SELECT/INSERT race condition in
1386
+ `ActiveRecord::Base.find_or_create_by`/`!` by leaning on unique constraints in the database.
1387
+
1388
+ *DHH*
1389
+
1390
+ * Add `Relation#pick` as short-hand for single-value plucks.
1391
+
1392
+ *DHH*
1024
1393
 
1025
1394
 
1026
- Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activerecord/CHANGELOG.md) for previous changes.
1395
+ Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activerecord/CHANGELOG.md) for previous changes.