activerecord 5.2.8.1 → 6.0.6

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