activerecord 6.0.1 → 6.1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (270) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1363 -647
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -4
  5. data/lib/active_record/aggregations.rb +5 -6
  6. data/lib/active_record/association_relation.rb +26 -15
  7. data/lib/active_record/associations/alias_tracker.rb +19 -16
  8. data/lib/active_record/associations/association.rb +55 -37
  9. data/lib/active_record/associations/association_scope.rb +19 -15
  10. data/lib/active_record/associations/belongs_to_association.rb +23 -10
  11. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +8 -3
  12. data/lib/active_record/associations/builder/association.rb +32 -5
  13. data/lib/active_record/associations/builder/belongs_to.rb +10 -7
  14. data/lib/active_record/associations/builder/collection_association.rb +5 -4
  15. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +0 -3
  16. data/lib/active_record/associations/builder/has_many.rb +6 -2
  17. data/lib/active_record/associations/builder/has_one.rb +11 -14
  18. data/lib/active_record/associations/builder/singular_association.rb +1 -1
  19. data/lib/active_record/associations/collection_association.rb +38 -13
  20. data/lib/active_record/associations/collection_proxy.rb +14 -7
  21. data/lib/active_record/associations/foreign_association.rb +13 -0
  22. data/lib/active_record/associations/has_many_association.rb +24 -3
  23. data/lib/active_record/associations/has_many_through_association.rb +10 -4
  24. data/lib/active_record/associations/has_one_association.rb +15 -1
  25. data/lib/active_record/associations/join_dependency/join_association.rb +39 -16
  26. data/lib/active_record/associations/join_dependency/join_part.rb +3 -3
  27. data/lib/active_record/associations/join_dependency.rb +73 -42
  28. data/lib/active_record/associations/preloader/association.rb +49 -25
  29. data/lib/active_record/associations/preloader/through_association.rb +2 -2
  30. data/lib/active_record/associations/preloader.rb +12 -7
  31. data/lib/active_record/associations/singular_association.rb +1 -1
  32. data/lib/active_record/associations/through_association.rb +1 -1
  33. data/lib/active_record/associations.rb +119 -12
  34. data/lib/active_record/attribute_assignment.rb +10 -9
  35. data/lib/active_record/attribute_methods/before_type_cast.rb +13 -10
  36. data/lib/active_record/attribute_methods/dirty.rb +3 -13
  37. data/lib/active_record/attribute_methods/primary_key.rb +6 -4
  38. data/lib/active_record/attribute_methods/query.rb +3 -6
  39. data/lib/active_record/attribute_methods/read.rb +8 -12
  40. data/lib/active_record/attribute_methods/serialization.rb +11 -6
  41. data/lib/active_record/attribute_methods/time_zone_conversion.rb +12 -15
  42. data/lib/active_record/attribute_methods/write.rb +12 -21
  43. data/lib/active_record/attribute_methods.rb +64 -54
  44. data/lib/active_record/attributes.rb +33 -9
  45. data/lib/active_record/autosave_association.rb +56 -41
  46. data/lib/active_record/base.rb +2 -14
  47. data/lib/active_record/callbacks.rb +153 -24
  48. data/lib/active_record/coders/yaml_column.rb +24 -3
  49. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +190 -136
  50. data/lib/active_record/connection_adapters/abstract/database_limits.rb +2 -44
  51. data/lib/active_record/connection_adapters/abstract/database_statements.rb +83 -38
  52. data/lib/active_record/connection_adapters/abstract/query_cache.rb +3 -9
  53. data/lib/active_record/connection_adapters/abstract/quoting.rb +44 -35
  54. data/lib/active_record/connection_adapters/abstract/savepoints.rb +3 -3
  55. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +152 -116
  56. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +145 -52
  57. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +3 -3
  58. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +267 -105
  59. data/lib/active_record/connection_adapters/abstract/transaction.rb +94 -36
  60. data/lib/active_record/connection_adapters/abstract_adapter.rb +63 -77
  61. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +136 -111
  62. data/lib/active_record/connection_adapters/column.rb +15 -1
  63. data/lib/active_record/connection_adapters/deduplicable.rb +29 -0
  64. data/lib/active_record/connection_adapters/legacy_pool_manager.rb +35 -0
  65. data/lib/active_record/connection_adapters/mysql/column.rb +1 -1
  66. data/lib/active_record/connection_adapters/mysql/database_statements.rb +30 -36
  67. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +1 -2
  68. data/lib/active_record/connection_adapters/mysql/quoting.rb +18 -3
  69. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +32 -7
  70. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +8 -0
  71. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +5 -2
  72. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +20 -13
  73. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +10 -1
  74. data/lib/active_record/connection_adapters/mysql2_adapter.rb +31 -13
  75. data/lib/active_record/connection_adapters/pool_config.rb +73 -0
  76. data/lib/active_record/connection_adapters/pool_manager.rb +47 -0
  77. data/lib/active_record/connection_adapters/postgresql/column.rb +24 -1
  78. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +21 -56
  79. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +0 -1
  80. data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +3 -5
  81. data/lib/active_record/connection_adapters/postgresql/oid/date.rb +2 -2
  82. data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +10 -2
  83. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +0 -1
  84. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +0 -1
  85. data/lib/active_record/connection_adapters/postgresql/oid/interval.rb +49 -0
  86. data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +2 -3
  87. data/lib/active_record/connection_adapters/postgresql/oid/macaddr.rb +25 -0
  88. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
  89. data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +1 -1
  90. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +2 -3
  91. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +24 -6
  92. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +1 -1
  93. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +11 -2
  94. data/lib/active_record/connection_adapters/postgresql/oid.rb +2 -0
  95. data/lib/active_record/connection_adapters/postgresql/quoting.rb +30 -4
  96. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +2 -2
  97. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +7 -3
  98. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +1 -1
  99. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +0 -1
  100. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +72 -54
  101. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +8 -0
  102. data/lib/active_record/connection_adapters/postgresql/utils.rb +0 -1
  103. data/lib/active_record/connection_adapters/postgresql_adapter.rb +80 -66
  104. data/lib/active_record/connection_adapters/schema_cache.rb +130 -15
  105. data/lib/active_record/connection_adapters/sql_type_metadata.rb +8 -0
  106. data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +38 -12
  107. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +1 -2
  108. data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +5 -1
  109. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +38 -5
  110. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +57 -57
  111. data/lib/active_record/connection_adapters/statement_pool.rb +0 -1
  112. data/lib/active_record/connection_adapters.rb +52 -0
  113. data/lib/active_record/connection_handling.rb +218 -87
  114. data/lib/active_record/core.rb +276 -68
  115. data/lib/active_record/counter_cache.rb +4 -1
  116. data/lib/active_record/database_configurations/connection_url_resolver.rb +99 -0
  117. data/lib/active_record/database_configurations/database_config.rb +52 -9
  118. data/lib/active_record/database_configurations/hash_config.rb +54 -8
  119. data/lib/active_record/database_configurations/url_config.rb +15 -41
  120. data/lib/active_record/database_configurations.rb +125 -85
  121. data/lib/active_record/delegated_type.rb +209 -0
  122. data/lib/active_record/destroy_association_async_job.rb +36 -0
  123. data/lib/active_record/dynamic_matchers.rb +2 -3
  124. data/lib/active_record/enum.rb +80 -38
  125. data/lib/active_record/errors.rb +47 -12
  126. data/lib/active_record/explain.rb +9 -5
  127. data/lib/active_record/explain_subscriber.rb +1 -1
  128. data/lib/active_record/fixture_set/file.rb +10 -17
  129. data/lib/active_record/fixture_set/model_metadata.rb +1 -2
  130. data/lib/active_record/fixture_set/render_context.rb +1 -1
  131. data/lib/active_record/fixture_set/table_row.rb +2 -3
  132. data/lib/active_record/fixture_set/table_rows.rb +0 -1
  133. data/lib/active_record/fixtures.rb +58 -12
  134. data/lib/active_record/gem_version.rb +3 -3
  135. data/lib/active_record/inheritance.rb +40 -21
  136. data/lib/active_record/insert_all.rb +42 -9
  137. data/lib/active_record/integration.rb +3 -5
  138. data/lib/active_record/internal_metadata.rb +18 -7
  139. data/lib/active_record/legacy_yaml_adapter.rb +7 -3
  140. data/lib/active_record/locking/optimistic.rb +33 -18
  141. data/lib/active_record/locking/pessimistic.rb +6 -2
  142. data/lib/active_record/log_subscriber.rb +28 -9
  143. data/lib/active_record/middleware/database_selector/resolver/session.rb +3 -0
  144. data/lib/active_record/middleware/database_selector/resolver.rb +6 -2
  145. data/lib/active_record/middleware/database_selector.rb +4 -2
  146. data/lib/active_record/migration/command_recorder.rb +53 -45
  147. data/lib/active_record/migration/compatibility.rb +75 -21
  148. data/lib/active_record/migration/join_table.rb +0 -1
  149. data/lib/active_record/migration.rb +115 -85
  150. data/lib/active_record/model_schema.rb +117 -15
  151. data/lib/active_record/nested_attributes.rb +2 -5
  152. data/lib/active_record/no_touching.rb +1 -1
  153. data/lib/active_record/null_relation.rb +0 -1
  154. data/lib/active_record/persistence.rb +50 -46
  155. data/lib/active_record/query_cache.rb +15 -5
  156. data/lib/active_record/querying.rb +12 -7
  157. data/lib/active_record/railtie.rb +65 -45
  158. data/lib/active_record/railties/console_sandbox.rb +2 -4
  159. data/lib/active_record/railties/databases.rake +280 -99
  160. data/lib/active_record/readonly_attributes.rb +4 -0
  161. data/lib/active_record/reflection.rb +77 -63
  162. data/lib/active_record/relation/batches/batch_enumerator.rb +25 -9
  163. data/lib/active_record/relation/batches.rb +38 -32
  164. data/lib/active_record/relation/calculations.rb +106 -45
  165. data/lib/active_record/relation/delegation.rb +9 -7
  166. data/lib/active_record/relation/finder_methods.rb +45 -16
  167. data/lib/active_record/relation/from_clause.rb +5 -1
  168. data/lib/active_record/relation/merger.rb +27 -26
  169. data/lib/active_record/relation/predicate_builder/array_handler.rb +8 -9
  170. data/lib/active_record/relation/predicate_builder/association_query_value.rb +4 -5
  171. data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +10 -6
  172. data/lib/active_record/relation/predicate_builder/relation_handler.rb +1 -1
  173. data/lib/active_record/relation/predicate_builder.rb +59 -40
  174. data/lib/active_record/relation/query_methods.rb +341 -188
  175. data/lib/active_record/relation/record_fetch_warning.rb +3 -3
  176. data/lib/active_record/relation/spawn_methods.rb +8 -8
  177. data/lib/active_record/relation/where_clause.rb +111 -62
  178. data/lib/active_record/relation.rb +116 -83
  179. data/lib/active_record/result.rb +41 -34
  180. data/lib/active_record/runtime_registry.rb +2 -2
  181. data/lib/active_record/sanitization.rb +6 -17
  182. data/lib/active_record/schema_dumper.rb +34 -4
  183. data/lib/active_record/schema_migration.rb +2 -8
  184. data/lib/active_record/scoping/default.rb +1 -4
  185. data/lib/active_record/scoping/named.rb +7 -18
  186. data/lib/active_record/scoping.rb +0 -1
  187. data/lib/active_record/secure_token.rb +16 -8
  188. data/lib/active_record/serialization.rb +5 -3
  189. data/lib/active_record/signed_id.rb +116 -0
  190. data/lib/active_record/statement_cache.rb +20 -4
  191. data/lib/active_record/store.rb +9 -4
  192. data/lib/active_record/suppressor.rb +2 -2
  193. data/lib/active_record/table_metadata.rb +42 -36
  194. data/lib/active_record/tasks/database_tasks.rb +140 -113
  195. data/lib/active_record/tasks/mysql_database_tasks.rb +34 -36
  196. data/lib/active_record/tasks/postgresql_database_tasks.rb +24 -27
  197. data/lib/active_record/tasks/sqlite_database_tasks.rb +13 -10
  198. data/lib/active_record/test_databases.rb +5 -4
  199. data/lib/active_record/test_fixtures.rb +87 -20
  200. data/lib/active_record/timestamp.rb +4 -7
  201. data/lib/active_record/touch_later.rb +20 -21
  202. data/lib/active_record/transactions.rb +25 -72
  203. data/lib/active_record/type/adapter_specific_registry.rb +2 -5
  204. data/lib/active_record/type/hash_lookup_type_map.rb +0 -1
  205. data/lib/active_record/type/serialized.rb +6 -3
  206. data/lib/active_record/type/time.rb +10 -0
  207. data/lib/active_record/type/type_map.rb +0 -1
  208. data/lib/active_record/type/unsigned_integer.rb +0 -1
  209. data/lib/active_record/type.rb +8 -2
  210. data/lib/active_record/type_caster/connection.rb +0 -1
  211. data/lib/active_record/type_caster/map.rb +8 -5
  212. data/lib/active_record/validations/associated.rb +1 -2
  213. data/lib/active_record/validations/numericality.rb +35 -0
  214. data/lib/active_record/validations/uniqueness.rb +24 -4
  215. data/lib/active_record/validations.rb +3 -3
  216. data/lib/active_record.rb +7 -13
  217. data/lib/arel/attributes/attribute.rb +4 -0
  218. data/lib/arel/collectors/bind.rb +5 -0
  219. data/lib/arel/collectors/composite.rb +8 -0
  220. data/lib/arel/collectors/sql_string.rb +7 -0
  221. data/lib/arel/collectors/substitute_binds.rb +7 -0
  222. data/lib/arel/nodes/binary.rb +82 -8
  223. data/lib/arel/nodes/bind_param.rb +8 -0
  224. data/lib/arel/nodes/casted.rb +21 -9
  225. data/lib/arel/nodes/equality.rb +6 -9
  226. data/lib/arel/nodes/grouping.rb +3 -0
  227. data/lib/arel/nodes/homogeneous_in.rb +76 -0
  228. data/lib/arel/nodes/in.rb +8 -1
  229. data/lib/arel/nodes/infix_operation.rb +13 -1
  230. data/lib/arel/nodes/join_source.rb +1 -1
  231. data/lib/arel/nodes/node.rb +7 -6
  232. data/lib/arel/nodes/ordering.rb +27 -0
  233. data/lib/arel/nodes/sql_literal.rb +3 -0
  234. data/lib/arel/nodes/table_alias.rb +7 -3
  235. data/lib/arel/nodes/unary.rb +0 -1
  236. data/lib/arel/nodes.rb +3 -1
  237. data/lib/arel/predications.rb +17 -24
  238. data/lib/arel/select_manager.rb +1 -2
  239. data/lib/arel/table.rb +13 -5
  240. data/lib/arel/visitors/dot.rb +14 -3
  241. data/lib/arel/visitors/mysql.rb +11 -1
  242. data/lib/arel/visitors/postgresql.rb +15 -5
  243. data/lib/arel/visitors/sqlite.rb +0 -1
  244. data/lib/arel/visitors/to_sql.rb +89 -79
  245. data/lib/arel/visitors/visitor.rb +0 -1
  246. data/lib/arel/visitors.rb +0 -7
  247. data/lib/arel.rb +5 -9
  248. data/lib/rails/generators/active_record/application_record/application_record_generator.rb +0 -1
  249. data/lib/rails/generators/active_record/migration/migration_generator.rb +1 -0
  250. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +2 -0
  251. data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +4 -4
  252. data/lib/rails/generators/active_record/migration.rb +6 -2
  253. data/lib/rails/generators/active_record/model/model_generator.rb +38 -2
  254. data/lib/rails/generators/active_record/model/templates/abstract_base_class.rb.tt +7 -0
  255. metadata +30 -29
  256. data/lib/active_record/attribute_decorators.rb +0 -90
  257. data/lib/active_record/connection_adapters/connection_specification.rb +0 -297
  258. data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +0 -29
  259. data/lib/active_record/define_callbacks.rb +0 -22
  260. data/lib/active_record/railties/collection_cache_association_loading.rb +0 -34
  261. data/lib/active_record/relation/predicate_builder/base_handler.rb +0 -18
  262. data/lib/active_record/relation/where_clause_factory.rb +0 -33
  263. data/lib/arel/attributes.rb +0 -22
  264. data/lib/arel/visitors/depth_first.rb +0 -204
  265. data/lib/arel/visitors/ibm_db.rb +0 -34
  266. data/lib/arel/visitors/informix.rb +0 -62
  267. data/lib/arel/visitors/mssql.rb +0 -157
  268. data/lib/arel/visitors/oracle.rb +0 -159
  269. data/lib/arel/visitors/oracle12.rb +0 -66
  270. data/lib/arel/visitors/where_sql.rb +0 -23
data/CHANGELOG.md CHANGED
@@ -1,1086 +1,1802 @@
1
- ## Rails 6.0.1 (November 5, 2019) ##
1
+ ## Rails 6.1.7.2 (January 24, 2023) ##
2
2
 
3
- * Common Table Expressions are allowed on read-only connections.
4
-
5
- *Chris Morris*
6
-
7
- * New record instantiation respects `unscope`.
8
-
9
- *Ryuta Kamizono*
10
-
11
- * Fixed a case where `find_in_batches` could halt too early.
3
+ * No changes.
12
4
 
13
- *Takayuki Nakata*
14
5
 
15
- * Autosaved associations always perform validations when a custom validation
16
- context is used.
6
+ ## Rails 6.1.7.1 (January 17, 2023) ##
17
7
 
18
- *Tekin Suleyman*
8
+ * Make sanitize_as_sql_comment more strict
19
9
 
20
- * `sql.active_record` notifications now include the `:connection` in
21
- their payloads.
10
+ Though this method was likely never meant to take user input, it was
11
+ attempting sanitization. That sanitization could be bypassed with
12
+ carefully crafted input.
22
13
 
23
- *Eugene Kenny*
14
+ This commit makes the sanitization more robust by replacing any
15
+ occurrances of "/*" or "*/" with "/ *" or "* /". It also performs a
16
+ first pass to remove one surrounding comment to avoid compatibility
17
+ issues for users relying on the existing removal.
24
18
 
25
- * A rollback encountered in an `after_commit` callback does not reset
26
- previously-committed record state.
19
+ This also clarifies in the documentation of annotate that it should not
20
+ be provided user input.
27
21
 
28
- *Ryuta Kamizono*
22
+ [CVE-2023-22794]
29
23
 
30
- * Fixed that join order was lost when eager-loading.
24
+ * Added integer width check to PostgreSQL::Quoting
31
25
 
32
- *Ryuta Kamizono*
26
+ Given a value outside the range for a 64bit signed integer type
27
+ PostgreSQL will treat the column type as numeric. Comparing
28
+ integer values against numeric values can result in a slow
29
+ sequential scan.
33
30
 
34
- * `DESCRIBE` queries are allowed on read-only connections.
31
+ This behavior is configurable via
32
+ ActiveRecord::Base.raise_int_wider_than_64bit which defaults to true.
35
33
 
36
- *Dylan Thacker-Smith*
34
+ [CVE-2022-44566]
37
35
 
38
- * Fixed that records that had been `inspect`ed could not be marshaled.
36
+ ## Rails 6.1.7 (September 09, 2022) ##
39
37
 
40
- *Eugene Kenny*
38
+ * Symbol is allowed by default for YAML columns
41
39
 
42
- * The connection pool reaper thread is respawned in forked processes. This
43
- fixes that idle connections in forked processes wouldn't be reaped.
40
+ *Étienne Barrié*
44
41
 
45
- *John Hawthorn*
42
+ * Fix `ActiveRecord::Store` to serialize as a regular Hash
46
43
 
47
- * The memoized result of `ActiveRecord::Relation#take` is properly cleared
48
- when `ActiveRecord::Relation#reset` or `ActiveRecord::Relation#reload`
49
- is called.
44
+ Previously it would serialize as an `ActiveSupport::HashWithIndifferentAccess`
45
+ which is wasteful and cause problem with YAML safe_load.
50
46
 
51
- *Anmol Arora*
47
+ *Jean Boussier*
52
48
 
53
- * Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
49
+ * Fix PG.connect keyword arguments deprecation warning on ruby 2.7
54
50
 
55
- *Hiroyuki Ishii*
51
+ Fixes #44307.
56
52
 
57
- * `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
53
+ *Nikita Vasilevsky*
58
54
 
59
- *Eugene Kenny*
55
+ ## Rails 6.1.6.1 (July 12, 2022) ##
60
56
 
61
- * Call `while_preventing_writes` directly from `connected_to`.
57
+ * Change ActiveRecord::Coders::YAMLColumn default to safe_load
62
58
 
63
- 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)`.
59
+ This adds two new configuration options The configuration options are as
60
+ follows:
61
+
62
+ * `config.active_storage.use_yaml_unsafe_load`
63
+
64
+ When set to true, this configuration option tells Rails to use the old
65
+ "unsafe" YAML loading strategy, maintaining the existing behavior but leaving
66
+ the possible escalation vulnerability in place. Setting this option to true
67
+ is *not* recommended, but can aid in upgrading.
68
+
69
+ * `config.active_record.yaml_column_permitted_classes`
70
+
71
+ The "safe YAML" loading method does not allow all classes to be deserialized
72
+ by default. This option allows you to specify classes deemed "safe" in your
73
+ application. For example, if your application uses Symbol and Time in
74
+ serialized data, you can add Symbol and Time to the allowed list as follows:
75
+
76
+ ```
77
+ config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time]
78
+ ```
64
79
 
65
- 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.
80
+ [CVE-2022-32224]
66
81
 
67
- *Eileen M. Uchitelle*
68
82
 
69
- * Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
83
+ ## Rails 6.1.6 (May 09, 2022) ##
70
84
 
71
- *Kir Shatrov*
85
+ * No changes.
72
86
 
73
87
 
74
- ## Rails 6.0.0 (August 16, 2019) ##
88
+ ## Rails 6.1.5.1 (April 26, 2022) ##
75
89
 
76
- * Preserve user supplied joins order as much as possible.
90
+ * No changes.
77
91
 
78
- Fixes #36761, #34328, #24281, #12953.
79
92
 
80
- *Ryuta Kamizono*
93
+ ## Rails 6.1.5 (March 09, 2022) ##
81
94
 
82
- * Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
95
+ * Fix `ActiveRecord::ConnectionAdapters::SchemaCache#deep_deduplicate` for Ruby 2.6.
83
96
 
84
- *John Crepezzi*, *Eileen Uchitelle*
97
+ Ruby 2.6 and 2.7 have slightly different implementations of the `String#-@` method.
98
+ In Ruby 2.6, the receiver of the `String#-@` method is modified under certain circumstances.
99
+ This was later identified as a bug (https://bugs.ruby-lang.org/issues/15926) and only
100
+ fixed in Ruby 2.7.
85
101
 
86
- * Add a warning for enum elements with 'not_' prefix.
102
+ Before the changes in this commit, the
103
+ `ActiveRecord::ConnectionAdapters::SchemaCache#deep_deduplicate` method, which internally
104
+ calls the `String#-@` method, could also modify an input string argument in Ruby 2.6 --
105
+ changing a tainted, unfrozen string into a tainted, frozen string.
87
106
 
88
- class Foo
89
- enum status: [:sent, :not_sent]
90
- end
107
+ Fixes #43056
91
108
 
92
- *Edu Depetris*
109
+ *Eric O'Hanlon*
93
110
 
94
- * Make currency symbols optional for money column type in PostgreSQL
111
+ * Fix migration compatibility to create SQLite references/belongs_to column as integer when
112
+ migration version is 6.0.
95
113
 
96
- *Joel Schneider*
114
+ `reference`/`belongs_to` in migrations with version 6.0 were creating columns as
115
+ bigint instead of integer for the SQLite Adapter.
97
116
 
117
+ *Marcelo Lauxen*
98
118
 
99
- ## Rails 6.0.0.rc2 (July 22, 2019) ##
119
+ * Fix dbconsole for 3-tier config.
100
120
 
101
- * Add database_exists? method to connection adapters to check if a database exists.
121
+ *Eileen M. Uchitelle*
102
122
 
103
- *Guilherme Mansur*
123
+ * Better handle SQL queries with invalid encoding.
104
124
 
105
- * PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
125
+ ```ruby
126
+ Post.create(name: "broken \xC8 UTF-8")
127
+ ```
106
128
 
107
- Fixes #36022.
129
+ Would cause all adapters to fail in a non controlled way in the code
130
+ responsible to detect write queries.
108
131
 
109
- *Ryuta Kamizono*
132
+ The query is now properly passed to the database connection, which might or might
133
+ not be able to handle it, but will either succeed or failed in a more correct way.
110
134
 
111
- * Make ActiveRecord `ConnectionPool.connections` method thread-safe.
135
+ *Jean Boussier*
112
136
 
113
- Fixes #36465.
137
+ * Ignore persisted in-memory records when merging target lists.
114
138
 
115
- *Jeff Doering*
139
+ *Kevin Sjöberg*
116
140
 
117
- * Fix sqlite3 collation parsing when using decimal columns.
141
+ * Fix regression bug that caused ignoring additional conditions for preloading
142
+ `has_many` through relations.
118
143
 
119
- *Martin R. Schuster*
144
+ Fixes #43132
120
145
 
121
- * Fix invalid schema when primary key column has a comment.
146
+ *Alexander Pauly*
122
147
 
123
- Fixes #29966.
148
+ * Fix `ActiveRecord::InternalMetadata` to not be broken by
149
+ `config.active_record.record_timestamps = false`
124
150
 
125
- *Guilherme Goettems Schneider*
151
+ Since the model always create the timestamp columns, it has to set them, otherwise it breaks
152
+ various DB management tasks.
126
153
 
127
- * Fix table comment also being applied to the primary key column.
154
+ Fixes #42983
128
155
 
129
- *Guilherme Goettems Schneider*
156
+ *Jean Boussier*
130
157
 
131
- * Fix merging left_joins to maintain its own `join_type` context.
158
+ * Fix duplicate active record objects on `inverse_of`.
132
159
 
133
- Fixes #36103.
160
+ *Justin Carvalho*
134
161
 
135
- *Ryuta Kamizono*
162
+ * Fix duplicate objects stored in has many association after save.
136
163
 
164
+ Fixes #42549.
137
165
 
138
- ## Rails 6.0.0.rc1 (April 24, 2019) ##
166
+ *Alex Ghiculescu*
139
167
 
140
- * Add `touch` option to `has_one` association.
168
+ * Fix performance regression in `CollectionAssocation#build`.
141
169
 
142
- *Abhay Nikam*
170
+ *Alex Ghiculescu*
143
171
 
144
- * Deprecate `where.not` working as NOR and will be changed to NAND in Rails 6.1.
172
+ * Fix retrieving default value for text column for MariaDB.
145
173
 
146
- ```ruby
147
- all = [treasures(:diamond), treasures(:sapphire), cars(:honda), treasures(:sapphire)]
148
- assert_equal all, PriceEstimate.all.map(&:estimate_of)
149
- ```
174
+ *fatkodima*
150
175
 
151
- In Rails 6.0:
152
176
 
153
- ```ruby
154
- sapphire = treasures(:sapphire)
155
-
156
- nor = all.reject { |e|
157
- e.estimate_of_type == sapphire.class.polymorphic_name
158
- }.reject { |e|
159
- e.estimate_of_id == sapphire.id
160
- }
161
- assert_equal [cars(:honda)], nor
162
-
163
- without_sapphire = PriceEstimate.where.not(
164
- estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
165
- )
166
- assert_equal nor, without_sapphire.map(&:estimate_of)
167
- ```
177
+ ## Rails 6.1.4.7 (March 08, 2022) ##
168
178
 
169
- In Rails 6.1:
179
+ * No changes.
170
180
 
171
- ```ruby
172
- sapphire = treasures(:sapphire)
173
181
 
174
- nand = all - [sapphire]
175
- assert_equal [treasures(:diamond), cars(:honda)], nand
182
+ ## Rails 6.1.4.6 (February 11, 2022) ##
176
183
 
177
- without_sapphire = PriceEstimate.where.not(
178
- estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
179
- )
180
- assert_equal nand, without_sapphire.map(&:estimate_of)
181
- ```
184
+ * No changes.
182
185
 
183
- *Ryuta Kamizono*
184
186
 
185
- * Fix dirty tracking after rollback.
187
+ ## Rails 6.1.4.5 (February 11, 2022) ##
186
188
 
187
- Fixes #15018, #30167, #33868.
189
+ * No changes.
188
190
 
189
- *Ryuta Kamizono*
190
191
 
191
- * Add `ActiveRecord::Relation#cache_version` to support recyclable cache keys via
192
- the versioned entries in `ActiveSupport::Cache`. This also means that
193
- `ActiveRecord::Relation#cache_key` will now return a stable key that does not
194
- include the max timestamp or count any more.
192
+ ## Rails 6.1.4.4 (December 15, 2021) ##
195
193
 
196
- NOTE: This feature is turned off by default, and `cache_key` will still return
197
- cache keys with timestamps until you set `ActiveRecord::Base.collection_cache_versioning = true`.
198
- That's the setting for all new apps on Rails 6.0+
194
+ * No changes.
199
195
 
200
- *Lachlan Sylvester*
201
196
 
202
- * Fix dirty tracking for `touch` to track saved changes.
197
+ ## Rails 6.1.4.3 (December 14, 2021) ##
203
198
 
204
- Fixes #33429.
199
+ * No changes.
205
200
 
206
- *Ryuta Kamzono*
207
201
 
208
- * `change_column_comment` and `change_table_comment` are invertible only if
209
- `to` and `from` options are specified.
202
+ ## Rails 6.1.4.2 (December 14, 2021) ##
210
203
 
211
- *Yoshiyuki Kinjo*
204
+ * No changes.
212
205
 
213
- * Don't call commit/rollback callbacks when a record isn't saved.
214
206
 
215
- Fixes #29747.
207
+ ## Rails 6.1.4.1 (August 19, 2021) ##
216
208
 
217
- *Ryuta Kamizono*
209
+ * No changes.
218
210
 
219
- * Fix circular `autosave: true` causes invalid records to be saved.
220
211
 
221
- Prior to the fix, when there was a circular series of `autosave: true`
222
- associations, the callback for a `has_many` association was run while
223
- another instance of the same callback on the same association hadn't
224
- finished running. When control returned to the first instance of the
225
- callback, the instance variable had changed, and subsequent associated
226
- records weren't saved correctly. Specifically, the ID field for the
227
- `belongs_to` corresponding to the `has_many` was `nil`.
212
+ ## Rails 6.1.4 (June 24, 2021) ##
228
213
 
229
- Fixes #28080.
214
+ * Do not try to rollback transactions that failed due to a `ActiveRecord::TransactionRollbackError`.
230
215
 
231
- *Larry Reid*
216
+ *Jamie McCarthy*
232
217
 
233
- * Raise `ArgumentError` for invalid `:limit` and `:precision` like as other options.
218
+ * Raise an error if `pool_config` is `nil` in `set_pool_config`.
234
219
 
235
- Before:
220
+ *Eileen M. Uchitelle*
236
221
 
237
- ```ruby
238
- add_column :items, :attr1, :binary, size: 10 # => ArgumentError
239
- add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
240
- add_column :items, :attr3, :integer, limit: 10 # => ActiveRecordError
241
- add_column :items, :attr4, :datetime, precision: 10 # => ActiveRecordError
242
- ```
222
+ * Fix compatibility with `psych >= 4`.
243
223
 
244
- After:
224
+ Starting in Psych 4.0.0 `YAML.load` behaves like `YAML.safe_load`. To preserve compatibility
225
+ Active Record's schema cache loader and `YAMLColumn` now uses `YAML.unsafe_load` if available.
245
226
 
246
- ```ruby
247
- add_column :items, :attr1, :binary, size: 10 # => ArgumentError
248
- add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
249
- add_column :items, :attr3, :integer, limit: 10 # => ArgumentError
250
- add_column :items, :attr4, :datetime, precision: 10 # => ArgumentError
251
- ```
227
+ *Jean Boussier*
252
228
 
253
- *Ryuta Kamizono*
229
+ * Support using replicas when using `rails dbconsole`.
254
230
 
255
- * Association loading isn't to be affected by scoping consistently
256
- whether preloaded / eager loaded or not, with the exception of `unscoped`.
231
+ *Christopher Thornton*
257
232
 
258
- Before:
233
+ * Restore connection pools after transactional tests.
259
234
 
260
- ```ruby
261
- Post.where("1=0").scoping do
262
- Comment.find(1).post # => nil
263
- Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
264
- Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
265
- end
266
- ```
235
+ *Eugene Kenny*
267
236
 
268
- After:
237
+ * Change `upsert_all` to fails cleanly for MySQL when `:unique_by` is used.
269
238
 
270
- ```ruby
271
- Post.where("1=0").scoping do
272
- Comment.find(1).post # => #<Post id: 1, ...>
273
- Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
274
- Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
275
- end
276
- ```
239
+ *Bastian Bartmann*
277
240
 
278
- Fixes #34638, #35398.
241
+ * Fix user-defined `self.default_scope` to respect table alias.
279
242
 
280
243
  *Ryuta Kamizono*
281
244
 
282
- * Add `rails db:prepare` to migrate or setup a database.
283
-
284
- Runs `db:migrate` if the database exists or `db:setup` if it doesn't.
245
+ * Clear `@cache_keys` cache after `update_all`, `delete_all`, `destroy_all`.
285
246
 
286
- *Roberto Miranda*
247
+ *Ryuta Kamizono*
287
248
 
288
- * Add `after_save_commit` callback as shortcut for `after_commit :hook, on: [ :create, :update ]`.
249
+ * Changed Arel predications `contains` and `overlaps` to use
250
+ `quoted_node` so that PostgreSQL arrays are quoted properly.
289
251
 
290
- *DHH*
252
+ *Bradley Priest*
291
253
 
292
- * Assign all attributes before calling `build` to ensure the child record is visible in
293
- `before_add` and `after_add` callbacks for `has_many :through` associations.
254
+ * Fix `merge` when the `where` clauses have string contents.
294
255
 
295
- Fixes #33249.
256
+ *Ryuta Kamizono*
296
257
 
297
- *Ryan H. Kerr*
258
+ * Fix rollback of parent destruction with nested `dependent: :destroy`.
298
259
 
299
- * Add `ActiveRecord::Relation#extract_associated` for extracting associated records from a relation.
260
+ *Jacopo Beschi*
300
261
 
301
- ```
302
- account.memberships.extract_associated(:user)
303
- # => Returns collection of User records
304
- ```
262
+ * Fix binds logging for `"WHERE ... IN ..."` statements.
305
263
 
306
- *DHH*
264
+ *Ricardo Díaz*
307
265
 
308
- * Add `ActiveRecord::Relation#annotate` for adding SQL comments to its queries.
266
+ * Handle `false` in relation strict loading checks.
309
267
 
310
- For example:
268
+ Previously when a model had strict loading set to true and then had a
269
+ relation set `strict_loading` to false the false wasn't considered when
270
+ deciding whether to raise/warn about strict loading.
311
271
 
312
272
  ```
313
- Post.where(id: 123).annotate("this is a comment").to_sql
314
- # SELECT "posts".* FROM "posts" WHERE "posts"."id" = 123 /* this is a comment */
315
- ```
273
+ class Dog < ActiveRecord::Base
274
+ self.strict_loading_by_default = true
316
275
 
317
- This can be useful in instrumentation or other analysis of issued queries.
276
+ has_many :treats, strict_loading: false
277
+ end
278
+ ```
318
279
 
319
- *Matt Yoho*
280
+ In the example, `dog.treats` would still raise even though
281
+ `strict_loading` was set to false. This is a bug affecting more than
282
+ Active Storage which is why I made this PR superseding #41461. We need
283
+ to fix this for all applications since the behavior is a little
284
+ surprising. I took the test from #41461 and the code suggestion from #41453
285
+ with some additions.
320
286
 
321
- * Support Optimizer Hints.
287
+ *Eileen M. Uchitelle*, *Radamés Roriz*
322
288
 
323
- In most databases, a way to control the optimizer is by using optimizer hints,
324
- which can be specified within individual statements.
289
+ * Fix numericality validator without precision.
325
290
 
326
- Example (for MySQL):
291
+ *Ryuta Kamizono*
327
292
 
328
- Topic.optimizer_hints("MAX_EXECUTION_TIME(50000)", "NO_INDEX_MERGE(topics)")
329
- # SELECT /*+ MAX_EXECUTION_TIME(50000) NO_INDEX_MERGE(topics) */ `topics`.* FROM `topics`
293
+ * Fix aggregate attribute on Enum types.
330
294
 
331
- Example (for PostgreSQL with pg_hint_plan):
295
+ *Ryuta Kamizono*
332
296
 
333
- Topic.optimizer_hints("SeqScan(topics)", "Parallel(topics 8)")
334
- # SELECT /*+ SeqScan(topics) Parallel(topics 8) */ "topics".* FROM "topics"
297
+ * Fix `CREATE INDEX` statement generation for PostgreSQL.
335
298
 
336
- See also:
299
+ *eltongo*
337
300
 
338
- * https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html
339
- * https://pghintplan.osdn.jp/pg_hint_plan.html
340
- * https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgsql/influencing-the-optimizer.html
341
- * https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017
342
- * https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.perf.doc/doc/c0070117.html
301
+ * Fix where clause on enum attribute when providing array of strings.
343
302
 
344
303
  *Ryuta Kamizono*
345
304
 
346
- * Fix query attribute method on user-defined attribute to be aware of typecasted value.
305
+ * Fix `unprepared_statement` to work it when nesting.
347
306
 
348
- For example, the following code no longer return false as casted non-empty string:
349
-
350
- ```
351
- class Post < ActiveRecord::Base
352
- attribute :user_defined_text, :text
353
- end
307
+ *Ryuta Kamizono*
354
308
 
355
- Post.new(user_defined_text: "false").user_defined_text? # => true
356
- ```
357
309
 
358
- *Yuji Kamijima*
310
+ ## Rails 6.1.3.2 (May 05, 2021) ##
359
311
 
360
- * Quote empty ranges like other empty enumerables.
312
+ * No changes.
361
313
 
362
- *Patrick Rebsch*
363
314
 
364
- * Add `insert_all`/`insert_all!`/`upsert_all` methods to `ActiveRecord::Persistence`,
365
- allowing bulk inserts akin to the bulk updates provided by `update_all` and
366
- bulk deletes by `delete_all`.
315
+ ## Rails 6.1.3.1 (March 26, 2021) ##
367
316
 
368
- Supports skipping or upserting duplicates through the `ON CONFLICT` syntax
369
- for PostgreSQL (9.5+) and SQLite (3.24+) and `ON DUPLICATE KEY UPDATE` syntax
370
- for MySQL.
317
+ * No changes.
371
318
 
372
- *Bob Lail*
373
319
 
374
- * Add `rails db:seed:replant` that truncates tables of each database
375
- for current environment and loads the seeds.
320
+ ## Rails 6.1.3 (February 17, 2021) ##
376
321
 
377
- *bogdanvlviv*, *DHH*
322
+ * Fix the MySQL adapter to always set the right collation and charset
323
+ to the connection session.
378
324
 
379
- * Add `ActiveRecord::Base.connection.truncate` for SQLite3 adapter.
325
+ *Rafael Mendonça França*
380
326
 
381
- *bogdanvlviv*
327
+ * Fix MySQL adapter handling of time objects when prepared statements
328
+ are enabled.
382
329
 
383
- * Deprecate mismatched collation comparison for uniqueness validator.
330
+ *Rafael Mendonça França*
384
331
 
385
- Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.
386
- To continue case sensitive comparison on the case insensitive column,
387
- pass `case_sensitive: true` option explicitly to the uniqueness validator.
332
+ * Fix scoping in enum fields using conditions that would generate
333
+ an `IN` clause.
388
334
 
389
335
  *Ryuta Kamizono*
390
336
 
391
- * Add `reselect` method. This is a short-hand for `unscope(:select).select(fields)`.
392
-
393
- Fixes #27340.
394
-
395
- *Willian Gustavo Veiga*
337
+ * Skip optimised #exist? query when #include? is called on a relation
338
+ with a having clause
396
339
 
397
- * Add negative scopes for all enum values.
340
+ Relations that have aliased select values AND a having clause that
341
+ references an aliased select value would generate an error when
342
+ #include? was called, due to an optimisation that would generate
343
+ call #exists? on the relation instead, which effectively alters
344
+ the select values of the query (and thus removes the aliased select
345
+ values), but leaves the having clause intact. Because the having
346
+ clause is then referencing an aliased column that is no longer
347
+ present in the simplified query, an ActiveRecord::InvalidStatement
348
+ error was raised.
398
349
 
399
- Example:
350
+ An sample query affected by this problem:
400
351
 
401
- class Post < ActiveRecord::Base
402
- enum status: %i[ drafted active trashed ]
403
- end
352
+ ```ruby
353
+ Author.select('COUNT(*) as total_posts', 'authors.*')
354
+ .joins(:posts)
355
+ .group(:id)
356
+ .having('total_posts > 2')
357
+ .include?(Author.first)
358
+ ```
404
359
 
405
- Post.not_drafted # => where.not(status: :drafted)
406
- Post.not_active # => where.not(status: :active)
407
- Post.not_trashed # => where.not(status: :trashed)
360
+ This change adds an addition check to the condition that skips the
361
+ simplified #exists? query, which simply checks for the presence of
362
+ a having clause.
408
363
 
409
- *DHH*
364
+ Fixes #41417
410
365
 
411
- * Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
366
+ *Michael Smart*
412
367
 
413
- Fixes #35214.
368
+ * Increment postgres prepared statement counter before making a prepared statement, so if the statement is aborted
369
+ without Rails knowledge (e.g., if app gets kill -9d during long-running query or due to Rack::Timeout), app won't end
370
+ up in perpetual crash state for being inconsistent with Postgres.
414
371
 
415
- *Juani Villarejo*
372
+ *wbharding*, *Martin Tepper*
416
373
 
417
374
 
418
- ## Rails 6.0.0.beta3 (March 11, 2019) ##
375
+ ## Rails 6.1.2.1 (February 10, 2021) ##
419
376
 
420
- * No changes.
377
+ * Fix possible DoS vector in PostgreSQL money type
421
378
 
379
+ Carefully crafted input can cause a DoS via the regular expressions used
380
+ for validating the money format in the PostgreSQL adapter. This patch
381
+ fixes the regexp.
422
382
 
423
- ## Rails 6.0.0.beta2 (February 25, 2019) ##
383
+ Thanks to @dee-see from Hackerone for this patch!
424
384
 
425
- * Fix prepared statements caching to be enabled even when query caching is enabled.
385
+ [CVE-2021-22880]
426
386
 
427
- *Ryuta Kamizono*
387
+ *Aaron Patterson*
428
388
 
429
- * Ensure `update_all` series cares about optimistic locking.
430
389
 
431
- *Ryuta Kamizono*
390
+ ## Rails 6.1.2 (February 09, 2021) ##
432
391
 
433
- * Don't allow `where` with non numeric string matches to 0 values.
392
+ * Fix timestamp type for sqlite3.
434
393
 
435
- *Ryuta Kamizono*
394
+ *Eileen M. Uchitelle*
436
395
 
437
- * Introduce `ActiveRecord::Relation#destroy_by` and `ActiveRecord::Relation#delete_by`.
396
+ * Make destroy async transactional.
438
397
 
439
- `destroy_by` allows relation to find all the records matching the condition and perform
440
- `destroy_all` on the matched records.
398
+ An active record rollback could occur while enqueuing a job. In this
399
+ case the job would enqueue even though the database deletion
400
+ rolledback putting things in a funky state.
441
401
 
442
- Example:
402
+ Now the jobs are only enqueued until after the db transaction has been committed.
443
403
 
444
- Person.destroy_by(name: 'David')
445
- Person.destroy_by(name: 'David', rating: 4)
404
+ *Cory Gwin*
446
405
 
447
- david = Person.find_by(name: 'David')
448
- david.posts.destroy_by(id: [1, 2, 3])
406
+ * Fix malformed packet error in MySQL statement for connection configuration.
449
407
 
450
- `delete_by` allows relation to find all the records matching the condition and perform
451
- `delete_all` on the matched records.
408
+ *robinroestenburg*
452
409
 
453
- Example:
410
+ * Connection specification now passes the "url" key as a configuration for the
411
+ adapter if the "url" protocol is "jdbc", "http", or "https". Previously only
412
+ urls with the "jdbc" prefix were passed to the Active Record Adapter, others
413
+ are assumed to be adapter specification urls.
454
414
 
455
- Person.delete_by(name: 'David')
456
- Person.delete_by(name: 'David', rating: 4)
415
+ Fixes #41137.
457
416
 
458
- david = Person.find_by(name: 'David')
459
- david.posts.delete_by(id: [1, 2, 3])
417
+ *Jonathan Bracy*
460
418
 
461
- *Abhay Nikam*
419
+ * Fix granular connection swapping when there are multiple abstract classes.
462
420
 
463
- * Don't allow `where` with invalid value matches to nil values.
421
+ *Eileen M. Uchitelle*
464
422
 
465
- Fixes #33624.
423
+ * Fix `find_by` with custom primary key for belongs_to association.
466
424
 
467
425
  *Ryuta Kamizono*
468
426
 
469
- * SQLite3: Implement `add_foreign_key` and `remove_foreign_key`.
427
+ * Add support for `rails console --sandbox` for multiple database applications.
470
428
 
471
- *Ryuta Kamizono*
429
+ *alpaca-tc*
472
430
 
473
- * Deprecate using class level querying methods if the receiver scope
474
- regarded as leaked. Use `klass.unscoped` to avoid the leaking scope.
431
+ * Fix `where` on polymorphic association with empty array.
475
432
 
476
433
  *Ryuta Kamizono*
477
434
 
478
- * Allow applications to automatically switch connections.
435
+ * Fix preventing writes for `ApplicationRecord`.
479
436
 
480
- Adds a middleware and configuration options that can be used in your
481
- application to automatically switch between the writing and reading
482
- database connections.
437
+ *Eileen M. Uchitelle*
483
438
 
484
- `GET` and `HEAD` requests will read from the replica unless there was
485
- a write in the last 2 seconds, otherwise they will read from the primary.
486
- Non-get requests will always write to the primary. The middleware accepts
487
- an argument for a Resolver class and an Operations class where you are able
488
- to change how the auto-switcher works to be most beneficial for your
489
- application.
490
439
 
491
- To use the middleware in your application you can use the following
492
- configuration options:
440
+ ## Rails 6.1.1 (January 07, 2021) ##
493
441
 
494
- ```
495
- config.active_record.database_selector = { delay: 2.seconds }
496
- config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
497
- config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
498
- ```
442
+ * Fix fixtures loading when strict loading is enabled for the association.
499
443
 
500
- To change the database selection strategy, pass a custom class to the
501
- configuration options:
444
+ *Alex Ghiculescu*
502
445
 
503
- ```
504
- config.active_record.database_selector = { delay: 10.seconds }
505
- config.active_record.database_resolver = MyResolver
506
- config.active_record.database_resolver_context = MyResolver::MyCookies
507
- ```
446
+ * Fix `where` with custom primary key for belongs_to association.
508
447
 
509
- *Eileen M. Uchitelle*
448
+ *Ryuta Kamizono*
510
449
 
511
- * MySQL: Support `:size` option to change text and blob size.
450
+ * Fix `where` with aliased associations.
512
451
 
513
452
  *Ryuta Kamizono*
514
453
 
515
- * Make `t.timestamps` with precision by default.
454
+ * Fix `composed_of` with symbol mapping.
516
455
 
517
456
  *Ryuta Kamizono*
518
457
 
458
+ * Don't skip money's type cast for pluck and calculations.
519
459
 
520
- ## Rails 6.0.0.beta1 (January 18, 2019) ##
460
+ *Ryuta Kamizono*
521
461
 
522
- * Remove deprecated `#set_state` from the transaction object.
462
+ * Fix `where` on polymorphic association with non Active Record object.
523
463
 
524
- *Rafael Mendonça França*
464
+ *Ryuta Kamizono*
525
465
 
526
- * Remove deprecated `#supports_statement_cache?` from the database adapters.
466
+ * Make sure `db:prepare` works even the schema file doesn't exist.
527
467
 
528
468
  *Rafael Mendonça França*
529
469
 
530
- * Remove deprecated `#insert_fixtures` from the database adapters.
470
+ * Fix complicated `has_many :through` with nested where condition.
531
471
 
532
- *Rafael Mendonça França*
533
-
534
- * Remove deprecated `ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?`.
472
+ *Ryuta Kamizono*
535
473
 
536
- *Rafael Mendonça França*
474
+ * Handle STI models for `has_many dependent: :destroy_async`.
537
475
 
538
- * Do not allow passing the column name to `sum` when a block is passed.
476
+ *Muhammad Usman*
539
477
 
540
- *Rafael Mendonça França*
478
+ * Restore possibility of passing `false` to :polymorphic option of `belongs_to`.
541
479
 
542
- * Do not allow passing the column name to `count` when a block is passed.
480
+ Previously, passing `false` would trigger the option validation logic
481
+ to throw an error saying :polymorphic would not be a valid option.
543
482
 
544
- *Rafael Mendonça França*
483
+ *glaszig*
545
484
 
546
- * Remove delegation of missing methods in a relation to arel.
485
+ * Allow adding nonnamed expression indexes to be revertible.
547
486
 
548
- *Rafael Mendonça França*
487
+ Fixes #40732.
549
488
 
550
- * Remove delegation of missing methods in a relation to private methods of the class.
489
+ Previously, the following code would raise an error, when executed while rolling back,
490
+ and the index name should be specified explicitly. Now, the index name is inferred
491
+ automatically.
551
492
 
552
- *Rafael Mendonça França*
493
+ ```ruby
494
+ add_index(:items, "to_tsvector('english', description)")
495
+ ```
553
496
 
554
- * Deprecate `config.active_record.sqlite3.represent_boolean_as_integer`.
497
+ *fatkodima*
555
498
 
556
- *Rafael Mendonça França*
557
499
 
558
- * Change `SQLite3Adapter` to always represent boolean values as integers.
500
+ ## Rails 6.1.0 (December 09, 2020) ##
559
501
 
560
- *Rafael Mendonça França*
502
+ * Only warn about negative enums if a positive form that would cause conflicts exists.
561
503
 
562
- * Remove ability to specify a timestamp name for `#cache_key`.
504
+ Fixes #39065.
563
505
 
564
- *Rafael Mendonça França*
506
+ *Alex Ghiculescu*
565
507
 
566
- * Remove deprecated `ActiveRecord::Migrator.migrations_path=`.
508
+ * Change `attribute_for_inspect` to take `filter_attributes` in consideration.
567
509
 
568
510
  *Rafael Mendonça França*
569
511
 
570
- * Remove deprecated `expand_hash_conditions_for_aggregates`.
512
+ * Fix odd behavior of inverse_of with multiple belongs_to to same class.
571
513
 
572
- *Rafael Mendonça França*
514
+ Fixes #35204.
573
515
 
574
- * Set polymorphic type column to NULL on `dependent: :nullify` strategy.
516
+ *Tomoyuki Kai*
575
517
 
576
- On polymorphic associations both the foreign key and the foreign type columns will be set to NULL.
518
+ * Build predicate conditions with objects that delegate `#id` and primary key:
577
519
 
578
- *Laerti Papa*
520
+ ```ruby
521
+ class AdminAuthor
522
+ delegate_missing_to :@author
579
523
 
580
- * Allow permitted instance of `ActionController::Parameters` as argument of `ActiveRecord::Relation#exists?`.
524
+ def initialize(author)
525
+ @author = author
526
+ end
527
+ end
581
528
 
582
- *Gannon McGibbon*
529
+ Post.where(author: AdminAuthor.new(author))
530
+ ```
583
531
 
584
- * Add support for endless ranges introduces in Ruby 2.6.
532
+ *Sean Doyle*
585
533
 
586
- *Greg Navis*
534
+ * Add `connected_to_many` API.
587
535
 
588
- * Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`.
536
+ This API allows applications to connect to multiple databases at once without switching all of them or implementing a deeply nested stack.
589
537
 
590
- *Ryuta Kamizono*
538
+ Before:
591
539
 
592
- * MySQL: `ROW_FORMAT=DYNAMIC` create table option by default.
540
+ AnimalsRecord.connected_to(role: :reading) do
541
+ MealsRecord.connected_to(role: :reading) do
542
+ Dog.first # read from animals replica
543
+ Dinner.first # read from meals replica
544
+ Person.first # read from primary writer
545
+ end
546
+ end
593
547
 
594
- Since MySQL 5.7.9, the `innodb_default_row_format` option defines the default row
595
- format for InnoDB tables. The default setting is `DYNAMIC`.
596
- The row format is required for indexing on `varchar(255)` with `utf8mb4` columns.
548
+ After:
597
549
 
598
- *Ryuta Kamizono*
550
+ ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do
551
+ Dog.first # read from animals replica
552
+ Dinner.first # read from meals replica
553
+ Person.first # read from primary writer
554
+ end
599
555
 
600
- * Fix join table column quoting with SQLite.
556
+ *Eileen M. Uchitelle*, *John Crepezzi*
601
557
 
602
- *Gannon McGibbon*
558
+ * Add option to raise or log for `ActiveRecord::StrictLoadingViolationError`.
603
559
 
604
- * Allow disabling scopes generated by `ActiveRecord.enum`.
560
+ Some applications may not want to raise an error in production if using `strict_loading`. This would allow an application to set strict loading to log for the production environment while still raising in development and test environments.
605
561
 
606
- *Alfred Dominic*
562
+ Set `config.active_record.action_on_strict_loading_violation` to `:log` errors instead of raising.
607
563
 
608
- * Ensure that `delete_all` on collection proxy returns affected count.
564
+ *Eileen M. Uchitelle*
609
565
 
610
- *Ryuta Kamizono*
566
+ * Allow the inverse of a `has_one` association that was previously autosaved to be loaded.
611
567
 
612
- * Reset scope after delete on collection association to clear stale offsets of removed records.
568
+ Fixes #34255.
613
569
 
614
- *Gannon McGibbon*
570
+ *Steven Weber*
615
571
 
616
- * Add the ability to prevent writes to a database for the duration of a block.
572
+ * Optimise the length of index names for polymorphic references by using the reference name rather than the type and id column names.
617
573
 
618
- Allows the application to prevent writes to a database. This can be useful when
619
- you're building out multiple databases and want to make sure you're not sending
620
- writes when you want a read.
574
+ Because the default behaviour when adding an index with multiple columns is to use all column names in the index name, this could frequently lead to overly long index names for polymorphic references which would fail the migration if it exceeded the database limit.
621
575
 
622
- If `while_preventing_writes` is called and the query is considered a write
623
- query the database will raise an exception regardless of whether the database
624
- user is able to write.
576
+ This change reduces the chance of that happening by using the reference name, e.g. `index_my_table_on_my_reference`.
625
577
 
626
- This is not meant to be a catch-all for write queries but rather a way to enforce
627
- read-only queries without opening a second connection. One purpose of this is to
628
- catch accidental writes, not all writes.
578
+ Fixes #38655.
629
579
 
630
- *Eileen M. Uchitelle*
580
+ *Luke Redpath*
631
581
 
632
- * Allow aliased attributes to be used in `#update_columns` and `#update`.
582
+ * MySQL: Uniqueness validator now respects default database collation,
583
+ no longer enforce case sensitive comparison by default.
633
584
 
634
- *Gannon McGibbon*
585
+ *Ryuta Kamizono*
635
586
 
636
- * Allow spaces in postgres table names.
587
+ * Remove deprecated methods from `ActiveRecord::ConnectionAdapters::DatabaseLimits`.
637
588
 
638
- Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres adapter.
589
+ `column_name_length`
590
+ `table_name_length`
591
+ `columns_per_table`
592
+ `indexes_per_table`
593
+ `columns_per_multicolumn_index`
594
+ `sql_query_length`
595
+ `joins_per_query`
639
596
 
640
- *Gannon McGibbon*
597
+ *Rafael Mendonça França*
641
598
 
642
- * Cached `columns_hash` fields should be excluded from `ResultSet#column_types`.
599
+ * Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_multi_insert?`.
643
600
 
644
- PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
645
- was passing for SQLite and MySQL, but failed for PostgreSQL:
601
+ *Rafael Mendonça França*
646
602
 
647
- ```ruby
648
- class DeveloperName < ActiveRecord::Type::String
649
- def deserialize(value)
650
- "Developer: #{value}"
651
- end
652
- end
603
+ * Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_foreign_keys_in_create?`.
653
604
 
654
- class AttributedDeveloper < ActiveRecord::Base
655
- self.table_name = "developers"
605
+ *Rafael Mendonça França*
656
606
 
657
- attribute :name, DeveloperName.new
607
+ * Remove deprecated `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#supports_ranges?`.
658
608
 
659
- self.ignored_columns += ["name"]
660
- end
609
+ *Rafael Mendonça França*
661
610
 
662
- developer = AttributedDeveloper.create
663
- developer.update_column :name, "name"
611
+ * Remove deprecated `ActiveRecord::Base#update_attributes` and `ActiveRecord::Base#update_attributes!`.
664
612
 
665
- loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
666
- puts loaded_developer.name # should be "Developer: name" but it's just "name"
667
- ```
613
+ *Rafael Mendonça França*
668
614
 
669
- *Dmitry Tsepelev*
615
+ * Remove deprecated `migrations_path` argument in `ActiveRecord::ConnectionAdapter::SchemaStatements#assume_migrated_upto_version`.
670
616
 
671
- * Make the implicit order column configurable.
617
+ *Rafael Mendonça França*
672
618
 
673
- When calling ordered finder methods such as `first` or `last` without an
674
- explicit order clause, ActiveRecord sorts records by primary key. This can
675
- result in unpredictable and surprising behaviour when the primary key is
676
- not an auto-incrementing integer, for example when it's a UUID. This change
677
- makes it possible to override the column used for implicit ordering such
678
- that `first` and `last` will return more predictable results.
619
+ * Remove deprecated `config.active_record.sqlite3.represent_boolean_as_integer`.
679
620
 
680
- Example:
621
+ *Rafael Mendonça França*
681
622
 
682
- class Project < ActiveRecord::Base
683
- self.implicit_order_column = "created_at"
684
- end
623
+ * `relation.create` does no longer leak scope to class level querying methods
624
+ in initialization block and callbacks.
685
625
 
686
- *Tekin Suleyman*
626
+ Before:
687
627
 
688
- * Bump minimum PostgreSQL version to 9.3.
628
+ User.where(name: "John").create do |john|
629
+ User.find_by(name: "David") # => nil
630
+ end
689
631
 
690
- *Yasuo Honda*
632
+ After:
691
633
 
692
- * Values of enum are frozen, raising an error when attempting to modify them.
634
+ User.where(name: "John").create do |john|
635
+ User.find_by(name: "David") # => #<User name: "David", ...>
636
+ end
693
637
 
694
- *Emmanuel Byrd*
638
+ *Ryuta Kamizono*
695
639
 
696
- * Move `ActiveRecord::StatementInvalid` SQL to error property and include binds as separate error property.
640
+ * Named scope chain does no longer leak scope to class level querying methods.
697
641
 
698
- `ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception_class` now requires `binds` to be passed as the last argument.
642
+ class User < ActiveRecord::Base
643
+ scope :david, -> { User.where(name: "David") }
644
+ end
699
645
 
700
- `ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception` now requires `message`, `sql`, and `binds` to be passed as keyword arguments.
646
+ Before:
701
647
 
702
- Subclasses of `ActiveRecord::StatementInvalid` must now provide `sql:` and `binds:` arguments to `super`.
648
+ User.where(name: "John").david
649
+ # SELECT * FROM users WHERE name = 'John' AND name = 'David'
703
650
 
704
- Example:
651
+ After:
705
652
 
706
- ```
707
- class MySubclassedError < ActiveRecord::StatementInvalid
708
- def initialize(message, sql:, binds:)
709
- super(message, sql: sql, binds: binds)
710
- end
711
- end
712
- ```
653
+ User.where(name: "John").david
654
+ # SELECT * FROM users WHERE name = 'David'
713
655
 
714
- *Gannon McGibbon*
656
+ *Ryuta Kamizono*
715
657
 
716
- * Add an `:if_not_exists` option to `create_table`.
658
+ * Remove deprecated methods from `ActiveRecord::DatabaseConfigurations`.
717
659
 
718
- Example:
660
+ `fetch`
661
+ `each`
662
+ `first`
663
+ `values`
664
+ `[]=`
719
665
 
720
- create_table :posts, if_not_exists: true do |t|
721
- t.string :title
722
- end
666
+ *Rafael Mendonça França*
723
667
 
724
- That would execute:
668
+ * `where.not` now generates NAND predicates instead of NOR.
725
669
 
726
- CREATE TABLE IF NOT EXISTS posts (
727
- ...
728
- )
670
+ Before:
729
671
 
730
- If the table already exists, `if_not_exists: false` (the default) raises an
731
- exception whereas `if_not_exists: true` does nothing.
672
+ User.where.not(name: "Jon", role: "admin")
673
+ # SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
732
674
 
733
- *fatkodima*, *Stefan Kanev*
675
+ After:
734
676
 
735
- * Defining an Enum as a Hash with blank key, or as an Array with a blank value, now raises an `ArgumentError`.
677
+ User.where.not(name: "Jon", role: "admin")
678
+ # SELECT * FROM users WHERE NOT (name == 'Jon' AND role == 'admin')
736
679
 
737
- *Christophe Maximin*
680
+ *Rafael Mendonça França*
738
681
 
739
- * Adds support for multiple databases to `rails db:schema:cache:dump` and `rails db:schema:cache:clear`.
682
+ * Remove deprecated `ActiveRecord::Result#to_hash` method.
740
683
 
741
- *Gannon McGibbon*
684
+ *Rafael Mendonça França*
742
685
 
743
- * `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
744
- if the attribute does not exist.
686
+ * Deprecate `ActiveRecord::Base.allow_unsafe_raw_sql`.
745
687
 
746
- *Sean Griffin*
688
+ *Rafael Mendonça França*
747
689
 
748
- * Add support for hash and URL configs in database hash of `ActiveRecord::Base.connected_to`.
690
+ * Remove deprecated support for using unsafe raw SQL in `ActiveRecord::Relation` methods.
749
691
 
750
- ````
751
- User.connected_to(database: { writing: "postgres://foo" }) do
752
- User.create!(name: "Gannon")
753
- end
692
+ *Rafael Mendonça França*
754
693
 
755
- config = { "adapter" => "sqlite3", "database" => "db/readonly.sqlite3" }
756
- User.connected_to(database: { reading: config }) do
757
- User.count
758
- end
759
- ````
694
+ * Allow users to silence the "Rails couldn't infer whether you are using multiple databases..."
695
+ message using `config.active_record.suppress_multiple_database_warning`.
760
696
 
761
- *Gannon McGibbon*
697
+ *Omri Gabay*
762
698
 
763
- * Support default expression for MySQL.
699
+ * Connections can be granularly switched for abstract classes when `connected_to` is called.
764
700
 
765
- MySQL 8.0.13 and higher supports default value to be a function or expression.
701
+ This change allows `connected_to` to switch a `role` and/or `shard` for a single abstract class instead of all classes globally. Applications that want to use the new feature need to set `config.active_record.legacy_connection_handling` to `false` in their application configuration.
766
702
 
767
- https://dev.mysql.com/doc/refman/8.0/en/create-table.html
703
+ Example usage:
768
704
 
769
- *Ryuta Kamizono*
705
+ Given an application we have a `User` model that inherits from `ApplicationRecord` and a `Dog` model that inherits from `AnimalsRecord`. `AnimalsRecord` and `ApplicationRecord` have writing and reading connections as well as shard `default`, `one`, and `two`.
770
706
 
771
- * Support expression indexes for MySQL.
707
+ ```ruby
708
+ ActiveRecord::Base.connected_to(role: :reading) do
709
+ User.first # reads from default replica
710
+ Dog.first # reads from default replica
772
711
 
773
- MySQL 8.0.13 and higher supports functional key parts that index
774
- expression values rather than column or column prefix values.
712
+ AnimalsRecord.connected_to(role: :writing, shard: :one) do
713
+ User.first # reads from default replica
714
+ Dog.first # reads from shard one primary
715
+ end
775
716
 
776
- https://dev.mysql.com/doc/refman/8.0/en/create-index.html
717
+ User.first # reads from default replica
718
+ Dog.first # reads from default replica
777
719
 
778
- *Ryuta Kamizono*
720
+ ApplicationRecord.connected_to(role: :writing, shard: :two) do
721
+ User.first # reads from shard two primary
722
+ Dog.first # reads from default replica
723
+ end
724
+ end
725
+ ```
779
726
 
780
- * Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
727
+ *Eileen M. Uchitelle*, *John Crepezzi*
781
728
 
782
- Fixes #33056.
729
+ * Allow double-dash comment syntax when querying read-only databases
783
730
 
784
- *Federico Martinez*
731
+ *James Adam*
785
732
 
786
- * Add basic API for connection switching to support multiple databases.
733
+ * Add `values_at` method.
787
734
 
788
- 1) Adds a `connects_to` method for models to connect to multiple databases. Example:
735
+ Returns an array containing the values associated with the given methods.
789
736
 
737
+ ```ruby
738
+ topic = Topic.first
739
+ topic.values_at(:title, :author_name)
740
+ # => ["Budget", "Jason"]
790
741
  ```
791
- class AnimalsModel < ApplicationRecord
792
- self.abstract_class = true
793
742
 
794
- connects_to database: { writing: :animals_primary, reading: :animals_replica }
795
- end
743
+ Similar to `Hash#values_at` but on an Active Record instance.
796
744
 
797
- class Dog < AnimalsModel
798
- # connected to both the animals_primary db for writing and the animals_replica for reading
799
- end
800
- ```
745
+ *Guillaume Briday*
801
746
 
802
- 2) Adds a `connected_to` block method for switching connection roles or connecting to
803
- a database that the model didn't connect to. Connecting to the database in this block is
804
- useful when you have another defined connection, for example `slow_replica` that you don't
805
- want to connect to by default but need in the console, or a specific code block.
747
+ * Fix `read_attribute_before_type_cast` to consider attribute aliases.
806
748
 
807
- ```
808
- ActiveRecord::Base.connected_to(role: :reading) do
809
- Dog.first # finds dog from replica connected to AnimalsBase
810
- Book.first # doesn't have a reading connection, will raise an error
811
- end
812
- ```
749
+ *Marcelo Lauxen*
813
750
 
814
- ```
815
- ActiveRecord::Base.connected_to(database: :slow_replica) do
816
- 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
751
+ * Support passing record to uniqueness validator `:conditions` callable:
752
+
753
+ ```ruby
754
+ class Article < ApplicationRecord
755
+ validates_uniqueness_of :title, conditions: ->(article) {
756
+ published_at = article.published_at
757
+ where(published_at: published_at.beginning_of_year..published_at.end_of_year)
758
+ }
817
759
  end
818
760
  ```
819
761
 
820
- *Eileen M. Uchitelle*
762
+ *Eliot Sykes*
821
763
 
822
- * Enum raises on invalid definition values
764
+ * `BatchEnumerator#update_all` and `BatchEnumerator#delete_all` now return the
765
+ total number of rows affected, just like their non-batched counterparts.
823
766
 
824
- When defining a Hash enum it can be easy to use `[]` instead of `{}`. This
825
- commit checks that only valid definition values are provided, those can
826
- be a Hash, an array of Symbols or an array of Strings. Otherwise it
827
- raises an `ArgumentError`.
767
+ ```ruby
768
+ Person.in_batches.update_all("first_name = 'Eugene'") # => 42
769
+ Person.in_batches.delete_all # => 42
770
+ ```
828
771
 
829
- Fixes #33961
772
+ Fixes #40287.
830
773
 
831
- *Alberto Almagro*
774
+ *Eugene Kenny*
832
775
 
833
- * Reloading associations now clears the Query Cache like `Persistence#reload` does.
776
+ * Add support for PostgreSQL `interval` data type with conversion to
777
+ `ActiveSupport::Duration` when loading records from database and
778
+ serialization to ISO 8601 formatted duration string on save.
779
+ Add support to define a column in migrations and get it in a schema dump.
780
+ Optional column precision is supported.
834
781
 
835
- ```
836
- class Post < ActiveRecord::Base
837
- has_one :category
838
- belongs_to :author
839
- has_many :comments
840
- end
782
+ To use this in 6.1, you need to place the next string to your model file:
841
783
 
842
- # Each of the following will now clear the query cache.
843
- post.reload_category
844
- post.reload_author
845
- post.comments.reload
846
- ```
784
+ attribute :duration, :interval
847
785
 
848
- *Christophe Maximin*
786
+ To keep old behavior until 7.0 is released:
849
787
 
850
- * Added `index` option for `change_table` migration helpers.
851
- With this change you can create indexes while adding new
852
- columns into the existing tables.
788
+ attribute :duration, :string
853
789
 
854
790
  Example:
855
791
 
856
- change_table(:languages) do |t|
857
- t.string :country_code, index: true
792
+ create_table :events do |t|
793
+ t.string :name
794
+ t.interval :duration
858
795
  end
859
796
 
860
- *Mehmet Emin İNAÇ*
861
-
862
- * Fix `transaction` reverting for migrations.
863
-
864
- Before: Commands inside a `transaction` in a reverted migration ran uninverted.
865
- Now: This change fixes that by reverting commands inside `transaction` block.
866
-
867
- *fatkodima*, *David Verhasselt*
797
+ class Event < ApplicationRecord
798
+ attribute :duration, :interval
799
+ end
868
800
 
869
- * Raise an error instead of scanning the filesystem root when `fixture_path` is blank.
801
+ Event.create!(name: 'Rock Fest', duration: 2.days)
802
+ Event.last.duration # => 2 days
803
+ Event.last.duration.iso8601 # => "P2D"
804
+ Event.new(duration: 'P1DT12H3S').duration # => 1 day, 12 hours, and 3 seconds
805
+ Event.new(duration: '1 day') # Unknown value will be ignored and NULL will be written to database
870
806
 
871
- *Gannon McGibbon*, *Max Albrecht*
807
+ *Andrey Novikov*
872
808
 
873
- * Allow `ActiveRecord::Base.configurations=` to be set with a symbolized hash.
809
+ * Allow associations supporting the `dependent:` key to take `dependent: :destroy_async`.
874
810
 
875
- *Gannon McGibbon*
811
+ ```ruby
812
+ class Account < ActiveRecord::Base
813
+ belongs_to :supplier, dependent: :destroy_async
814
+ end
815
+ ```
876
816
 
877
- * Don't update counter cache unless the record is actually saved.
817
+ `:destroy_async` will enqueue a job to destroy associated records in the background.
878
818
 
879
- Fixes #31493, #33113, #33117.
819
+ *DHH*, *George Claghorn*, *Cory Gwin*, *Rafael Mendonça França*, *Adrianna Chang*
880
820
 
881
- *Ryuta Kamizono*
821
+ * Add `SKIP_TEST_DATABASE` environment variable to disable modifying the test database when `rails db:create` and `rails db:drop` are called.
882
822
 
883
- * Deprecate `ActiveRecord::Result#to_hash` in favor of `ActiveRecord::Result#to_a`.
823
+ *Jason Schweier*
884
824
 
885
- *Gannon McGibbon*, *Kevin Cheng*
825
+ * `connects_to` can only be called on `ActiveRecord::Base` or abstract classes.
886
826
 
887
- * SQLite3 adapter supports expression indexes.
827
+ Ensure that `connects_to` can only be called from `ActiveRecord::Base` or abstract classes. This protects the application from opening duplicate or too many connections.
888
828
 
889
- ```
890
- create_table :users do |t|
891
- t.string :email
892
- end
829
+ *Eileen M. Uchitelle*, *John Crepezzi*
893
830
 
894
- add_index :users, 'lower(email)', name: 'index_users_on_email', unique: true
895
- ```
831
+ * All connection adapters `execute` now raises `ActiveRecord::ConnectionNotEstablished` rather than
832
+ `ActiveRecord::StatementInvalid` when they encounter a connection error.
896
833
 
897
- *Gray Kemmey*
834
+ *Jean Boussier*
898
835
 
899
- * Allow subclasses to redefine autosave callbacks for associated records.
836
+ * `Mysql2Adapter#quote_string` now raises `ActiveRecord::ConnectionNotEstablished` rather than
837
+ `ActiveRecord::StatementInvalid` when it can't connect to the MySQL server.
900
838
 
901
- Fixes #33305.
839
+ *Jean Boussier*
902
840
 
903
- *Andrey Subbota*
841
+ * Add support for check constraints that are `NOT VALID` via `validate: false` (PostgreSQL-only).
904
842
 
905
- * Bump minimum MySQL version to 5.5.8.
843
+ *Alex Robbin*
906
844
 
907
- *Yasuo Honda*
845
+ * Ensure the default configuration is considered primary or first for an environment
908
846
 
909
- * Use MySQL utf8mb4 character set by default.
847
+ If a multiple database application provides a configuration named primary, that will be treated as default. In applications that do not have a primary entry, the default database configuration will be the first configuration for an environment.
910
848
 
911
- `utf8mb4` character set with 4-Byte encoding supports supplementary characters including emoji.
912
- The previous default 3-Byte encoding character set `utf8` is not enough to support them.
849
+ *Eileen M. Uchitelle*
913
850
 
914
- *Yasuo Honda*
851
+ * Allow `where` references association names as joined table name aliases.
915
852
 
916
- * Fix duplicated record creation when using nested attributes with `create_with`.
853
+ ```ruby
854
+ class Comment < ActiveRecord::Base
855
+ enum label: [:default, :child]
856
+ has_many :children, class_name: "Comment", foreign_key: :parent_id
857
+ end
917
858
 
918
- *Darwin Wu*
859
+ # ... FROM comments LEFT OUTER JOIN comments children ON ... WHERE children.label = 1
860
+ Comment.includes(:children).where("children.label": "child")
861
+ ```
919
862
 
920
- * Configuration item `config.filter_parameters` could also filter out
921
- sensitive values of database columns when calling `#inspect`.
922
- We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
923
- specify sensitive attributes to specific model.
863
+ *Ryuta Kamizono*
924
864
 
925
- ```
926
- Rails.application.config.filter_parameters += [:credit_card_number, /phone/]
927
- Account.last.inspect # => #<Account id: 123, name: "DHH", credit_card_number: [FILTERED], telephone_number: [FILTERED] ...>
928
- SecureAccount.filter_attributes += [:name]
929
- SecureAccount.last.inspect # => #<SecureAccount id: 42, name: [FILTERED], credit_card_number: [FILTERED] ...>
930
- ```
865
+ * Support storing demodulized class name for polymorphic type.
931
866
 
932
- *Zhang Kang*, *Yoshiyuki Kinjo*
867
+ Before Rails 6.1, storing demodulized class name is supported only for STI type
868
+ by `store_full_sti_class` class attribute.
933
869
 
934
- * Deprecate `column_name_length`, `table_name_length`, `columns_per_table`,
935
- `indexes_per_table`, `columns_per_multicolumn_index`, `sql_query_length`,
936
- and `joins_per_query` methods in `DatabaseLimits`.
870
+ Now `store_full_class_name` class attribute can handle both STI and polymorphic types.
937
871
 
938
872
  *Ryuta Kamizono*
939
873
 
940
- * `ActiveRecord::Base.configurations` now returns an object.
874
+ * Deprecate `rails db:structure:{load, dump}` tasks and extend
875
+ `rails db:schema:{load, dump}` tasks to work with either `:ruby` or `:sql` format,
876
+ depending on `config.active_record.schema_format` configuration value.
941
877
 
942
- `ActiveRecord::Base.configurations` used to return a hash, but this
943
- is an inflexible data model. In order to improve multiple-database
944
- handling in Rails, we've changed this to return an object. Some methods
945
- are provided to make the object behave hash-like in order to ease the
946
- transition process. Since most applications don't manipulate the hash
947
- we've decided to add backwards-compatible functionality that will throw
948
- a deprecation warning if used, however calling `ActiveRecord::Base.configurations`
949
- will use the new version internally and externally.
878
+ *fatkodima*
950
879
 
951
- For example, the following `database.yml`:
880
+ * Respect the `select` values for eager loading.
952
881
 
882
+ ```ruby
883
+ post = Post.select("UPPER(title) AS title").first
884
+ post.title # => "WELCOME TO THE WEBLOG"
885
+ post.body # => ActiveModel::MissingAttributeError
886
+
887
+ # Rails 6.0 (ignore the `select` values)
888
+ post = Post.select("UPPER(title) AS title").eager_load(:comments).first
889
+ post.title # => "Welcome to the weblog"
890
+ post.body # => "Such a lovely day"
891
+
892
+ # Rails 6.1 (respect the `select` values)
893
+ post = Post.select("UPPER(title) AS title").eager_load(:comments).first
894
+ post.title # => "WELCOME TO THE WEBLOG"
895
+ post.body # => ActiveModel::MissingAttributeError
953
896
  ```
954
- development:
955
- adapter: sqlite3
956
- database: db/development.sqlite3
897
+
898
+ *Ryuta Kamizono*
899
+
900
+ * Allow attribute's default to be configured but keeping its own type.
901
+
902
+ ```ruby
903
+ class Post < ActiveRecord::Base
904
+ attribute :written_at, default: -> { Time.now.utc }
905
+ end
906
+
907
+ # Rails 6.0
908
+ Post.type_for_attribute(:written_at) # => #<Type::Value ... precision: nil, ...>
909
+
910
+ # Rails 6.1
911
+ Post.type_for_attribute(:written_at) # => #<Type::DateTime ... precision: 6, ...>
957
912
  ```
958
913
 
959
- Used to become a hash:
914
+ *Ryuta Kamizono*
960
915
 
916
+ * Allow default to be configured for Enum.
917
+
918
+ ```ruby
919
+ class Book < ActiveRecord::Base
920
+ enum status: [:proposed, :written, :published], _default: :published
921
+ end
922
+
923
+ Book.new.status # => "published"
961
924
  ```
962
- { "development" => { "adapter" => "sqlite3", "database" => "db/development.sqlite3" } }
925
+
926
+ *Ryuta Kamizono*
927
+
928
+ * Deprecate YAML loading from legacy format older than Rails 5.0.
929
+
930
+ *Ryuta Kamizono*
931
+
932
+ * Added the setting `ActiveRecord::Base.immutable_strings_by_default`, which
933
+ allows you to specify that all string columns should be frozen unless
934
+ otherwise specified. This will reduce memory pressure for applications which
935
+ do not generally mutate string properties of Active Record objects.
936
+
937
+ *Sean Griffin*, *Ryuta Kamizono*
938
+
939
+ * Deprecate `map!` and `collect!` on `ActiveRecord::Result`.
940
+
941
+ *Ryuta Kamizono*
942
+
943
+ * Support `relation.and` for intersection as Set theory.
944
+
945
+ ```ruby
946
+ david_and_mary = Author.where(id: [david, mary])
947
+ mary_and_bob = Author.where(id: [mary, bob])
948
+
949
+ david_and_mary.merge(mary_and_bob) # => [mary, bob]
950
+
951
+ david_and_mary.and(mary_and_bob) # => [mary]
952
+ david_and_mary.or(mary_and_bob) # => [david, mary, bob]
963
953
  ```
964
954
 
965
- Is now converted into the following object:
955
+ *Ryuta Kamizono*
956
+
957
+ * Merging conditions on the same column no longer maintain both conditions,
958
+ and will be consistently replaced by the latter condition in Rails 7.0.
959
+ To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`.
960
+
961
+ ```ruby
962
+ # Rails 6.1 (IN clause is replaced by merger side equality condition)
963
+ Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
964
+
965
+ # Rails 6.1 (both conflict conditions exists, deprecated)
966
+ Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
967
+
968
+ # Rails 6.1 with rewhere to migrate to Rails 7.0's behavior
969
+ Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob]
966
970
 
971
+ # Rails 7.0 (same behavior with IN clause, mergee side condition is consistently replaced)
972
+ Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
973
+ Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]
967
974
  ```
968
- #<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800 @configurations=[
969
- #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",
970
- @spec_name="primary", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
971
- ]
975
+
976
+ *Ryuta Kamizono*
977
+
978
+ * Do not mark Postgresql MAC address and UUID attributes as changed when the assigned value only varies by case.
979
+
980
+ *Peter Fry*
981
+
982
+ * Resolve issue with insert_all unique_by option when used with expression index.
983
+
984
+ When the `:unique_by` option of `ActiveRecord::Persistence.insert_all` and
985
+ `ActiveRecord::Persistence.upsert_all` was used with the name of an expression index, an error
986
+ was raised. Adding a guard around the formatting behavior for the `:unique_by` corrects this.
987
+
988
+ Usage:
989
+
990
+ ```ruby
991
+ create_table :books, id: :integer, force: true do |t|
992
+ t.column :name, :string
993
+ t.index "lower(name)", unique: true
994
+ end
995
+
996
+ Book.insert_all [{ name: "MyTest" }], unique_by: :index_books_on_lower_name
972
997
  ```
973
998
 
974
- Iterating over the database configurations has also changed. Instead of
975
- calling hash methods on the `configurations` hash directly, a new method `configs_for` has
976
- been provided that allows you to select the correct configuration. `env_name` and
977
- `spec_name` arguments are optional. For example, these return an array of
978
- database config objects for the requested environment and a single database config object
979
- will be returned for the requested environment and specification name respectively.
999
+ Fixes #39516.
1000
+
1001
+ *Austen Madden*
1002
+
1003
+ * Add basic support for CHECK constraints to database migrations.
1004
+
1005
+ Usage:
980
1006
 
1007
+ ```ruby
1008
+ add_check_constraint :products, "price > 0", name: "price_check"
1009
+ remove_check_constraint :products, name: "price_check"
981
1010
  ```
982
- ActiveRecord::Base.configurations.configs_for(env_name: "development")
983
- ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
1011
+
1012
+ *fatkodima*
1013
+
1014
+ * Add `ActiveRecord::Base.strict_loading_by_default` and `ActiveRecord::Base.strict_loading_by_default=`
1015
+ to enable/disable strict_loading mode by default for a model. The configuration's value is
1016
+ inheritable by subclasses, but they can override that value and it will not impact parent class.
1017
+
1018
+ Usage:
1019
+
1020
+ ```ruby
1021
+ class Developer < ApplicationRecord
1022
+ self.strict_loading_by_default = true
1023
+
1024
+ has_many :projects
1025
+ end
1026
+
1027
+ dev = Developer.first
1028
+ dev.projects.first
1029
+ # => ActiveRecord::StrictLoadingViolationError Exception: Developer is marked as strict_loading and Project cannot be lazily loaded.
984
1030
  ```
985
1031
 
986
- *Eileen M. Uchitelle*, *Aaron Patterson*
1032
+ *bogdanvlviv*
987
1033
 
988
- * Add database configuration to disable advisory locks.
1034
+ * Deprecate passing an Active Record object to `quote`/`type_cast` directly.
989
1035
 
1036
+ *Ryuta Kamizono*
1037
+
1038
+ * Default engine `ENGINE=InnoDB` is no longer dumped to make schema more agnostic.
1039
+
1040
+ Before:
1041
+
1042
+ ```ruby
1043
+ create_table "accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
1044
+ end
990
1045
  ```
1046
+
1047
+ After:
1048
+
1049
+ ```ruby
1050
+ create_table "accounts", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
1051
+ end
1052
+ ```
1053
+
1054
+ *Ryuta Kamizono*
1055
+
1056
+ * Added delegated type as an alternative to single-table inheritance for representing class hierarchies.
1057
+ See ActiveRecord::DelegatedType for the full description.
1058
+
1059
+ *DHH*
1060
+
1061
+ * Deprecate aggregations with group by duplicated fields.
1062
+
1063
+ To migrate to Rails 7.0's behavior, use `uniq!(:group)` to deduplicate group fields.
1064
+
1065
+ ```ruby
1066
+ accounts = Account.group(:firm_id)
1067
+
1068
+ # duplicated group fields, deprecated.
1069
+ accounts.merge(accounts.where.not(credit_limit: nil)).sum(:credit_limit)
1070
+ # => {
1071
+ # [1, 1] => 50,
1072
+ # [2, 2] => 60
1073
+ # }
1074
+
1075
+ # use `uniq!(:group)` to deduplicate group fields.
1076
+ accounts.merge(accounts.where.not(credit_limit: nil)).uniq!(:group).sum(:credit_limit)
1077
+ # => {
1078
+ # 1 => 50,
1079
+ # 2 => 60
1080
+ # }
1081
+ ```
1082
+
1083
+ *Ryuta Kamizono*
1084
+
1085
+ * Deprecate duplicated query annotations.
1086
+
1087
+ To migrate to Rails 7.0's behavior, use `uniq!(:annotate)` to deduplicate query annotations.
1088
+
1089
+ ```ruby
1090
+ accounts = Account.where(id: [1, 2]).annotate("david and mary")
1091
+
1092
+ # duplicated annotations, deprecated.
1093
+ accounts.merge(accounts.rewhere(id: 3))
1094
+ # SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */ /* david and mary */
1095
+
1096
+ # use `uniq!(:annotate)` to deduplicate annotations.
1097
+ accounts.merge(accounts.rewhere(id: 3)).uniq!(:annotate)
1098
+ # SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */
1099
+ ```
1100
+
1101
+ *Ryuta Kamizono*
1102
+
1103
+ * Resolve conflict between counter cache and optimistic locking.
1104
+
1105
+ Bump an Active Record instance's lock version after updating its counter
1106
+ cache. This avoids raising an unnecessary `ActiveRecord::StaleObjectError`
1107
+ upon subsequent transactions by maintaining parity with the corresponding
1108
+ database record's `lock_version` column.
1109
+
1110
+ Fixes #16449.
1111
+
1112
+ *Aaron Lipman*
1113
+
1114
+ * Support merging option `:rewhere` to allow mergee side condition to be replaced exactly.
1115
+
1116
+ ```ruby
1117
+ david_and_mary = Author.where(id: david.id..mary.id)
1118
+
1119
+ # both conflict conditions exists
1120
+ david_and_mary.merge(Author.where(id: bob)) # => []
1121
+
1122
+ # mergee side condition is replaced by rewhere
1123
+ david_and_mary.merge(Author.rewhere(id: bob)) # => [bob]
1124
+
1125
+ # mergee side condition is replaced by rewhere option
1126
+ david_and_mary.merge(Author.where(id: bob), rewhere: true) # => [bob]
1127
+ ```
1128
+
1129
+ *Ryuta Kamizono*
1130
+
1131
+ * Add support for finding records based on signed ids, which are tamper-proof, verified ids that can be
1132
+ set to expire and scoped with a purpose. This is particularly useful for things like password reset
1133
+ or email verification, where you want the bearer of the signed id to be able to interact with the
1134
+ underlying record, but usually only within a certain time period.
1135
+
1136
+ ```ruby
1137
+ signed_id = User.first.signed_id expires_in: 15.minutes, purpose: :password_reset
1138
+
1139
+ User.find_signed signed_id # => nil, since the purpose does not match
1140
+
1141
+ travel 16.minutes
1142
+ User.find_signed signed_id, purpose: :password_reset # => nil, since the signed id has expired
1143
+
1144
+ travel_back
1145
+ User.find_signed signed_id, purpose: :password_reset # => User.first
1146
+
1147
+ User.find_signed! "bad data" # => ActiveSupport::MessageVerifier::InvalidSignature
1148
+ ```
1149
+
1150
+ *DHH*
1151
+
1152
+ * Support `ALGORITHM = INSTANT` DDL option for index operations on MySQL.
1153
+
1154
+ *Ryuta Kamizono*
1155
+
1156
+ * Fix index creation to preserve index comment in bulk change table on MySQL.
1157
+
1158
+ *Ryuta Kamizono*
1159
+
1160
+ * Allow `unscope` to be aware of table name qualified values.
1161
+
1162
+ It is possible to unscope only the column in the specified table.
1163
+
1164
+ ```ruby
1165
+ posts = Post.joins(:comments).group(:"posts.hidden")
1166
+ posts = posts.where("posts.hidden": false, "comments.hidden": false)
1167
+
1168
+ posts.count
1169
+ # => { false => 10 }
1170
+
1171
+ # unscope both hidden columns
1172
+ posts.unscope(where: :hidden).count
1173
+ # => { false => 11, true => 1 }
1174
+
1175
+ # unscope only comments.hidden column
1176
+ posts.unscope(where: :"comments.hidden").count
1177
+ # => { false => 11 }
1178
+ ```
1179
+
1180
+ *Ryuta Kamizono*, *Slava Korolev*
1181
+
1182
+ * Fix `rewhere` to truly overwrite collided where clause by new where clause.
1183
+
1184
+ ```ruby
1185
+ steve = Person.find_by(name: "Steve")
1186
+ david = Author.find_by(name: "David")
1187
+
1188
+ relation = Essay.where(writer: steve)
1189
+
1190
+ # Before
1191
+ relation.rewhere(writer: david).to_a # => []
1192
+
1193
+ # After
1194
+ relation.rewhere(writer: david).to_a # => [david]
1195
+ ```
1196
+
1197
+ *Ryuta Kamizono*
1198
+
1199
+ * Inspect time attributes with subsec and time zone offset.
1200
+
1201
+ ```ruby
1202
+ p Knot.create
1203
+ => #<Knot id: 1, created_at: "2016-05-05 01:29:47.116928000 +0000">
1204
+ ```
1205
+
1206
+ *akinomaeni*, *Jonathan Hefner*
1207
+
1208
+ * Deprecate passing a column to `type_cast`.
1209
+
1210
+ *Ryuta Kamizono*
1211
+
1212
+ * Deprecate `in_clause_length` and `allowed_index_name_length` in `DatabaseLimits`.
1213
+
1214
+ *Ryuta Kamizono*
1215
+
1216
+ * Support bulk insert/upsert on relation to preserve scope values.
1217
+
1218
+ *Josef Šimánek*, *Ryuta Kamizono*
1219
+
1220
+ * Preserve column comment value on changing column name on MySQL.
1221
+
1222
+ *Islam Taha*
1223
+
1224
+ * Add support for `if_exists` option for removing an index.
1225
+
1226
+ The `remove_index` method can take an `if_exists` option. If this is set to true an error won't be raised if the index doesn't exist.
1227
+
1228
+ *Eileen M. Uchitelle*
1229
+
1230
+ * Remove ibm_db, informix, mssql, oracle, and oracle12 Arel visitors which are not used in the code base.
1231
+
1232
+ *Ryuta Kamizono*
1233
+
1234
+ * Prevent `build_association` from `touching` a parent record if the record isn't persisted for `has_one` associations.
1235
+
1236
+ Fixes #38219.
1237
+
1238
+ *Josh Brody*
1239
+
1240
+ * Add support for `if_not_exists` option for adding index.
1241
+
1242
+ The `add_index` method respects `if_not_exists` option. If it is set to true
1243
+ index won't be added.
1244
+
1245
+ Usage:
1246
+
1247
+ ```ruby
1248
+ add_index :users, :account_id, if_not_exists: true
1249
+ ```
1250
+
1251
+ The `if_not_exists` option passed to `create_table` also gets propagated to indexes
1252
+ created within that migration so that if table and its indexes exist then there is no
1253
+ attempt to create them again.
1254
+
1255
+ *Prathamesh Sonpatki*
1256
+
1257
+ * Add `ActiveRecord::Base#previously_new_record?` to show if a record was new before the last save.
1258
+
1259
+ *Tom Ward*
1260
+
1261
+ * Support descending order for `find_each`, `find_in_batches`, and `in_batches`.
1262
+
1263
+ Batch processing methods allow you to work with the records in batches, greatly reducing memory consumption, but records are always batched from oldest id to newest.
1264
+
1265
+ This change allows reversing the order, batching from newest to oldest. This is useful when you need to process newer batches of records first.
1266
+
1267
+ Pass `order: :desc` to yield batches in descending order. The default remains `order: :asc`.
1268
+
1269
+ ```ruby
1270
+ Person.find_each(order: :desc) do |person|
1271
+ person.party_all_night!
1272
+ end
1273
+ ```
1274
+
1275
+ *Alexey Vasiliev*
1276
+
1277
+ * Fix `insert_all` with enum values.
1278
+
1279
+ Fixes #38716.
1280
+
1281
+ *Joel Blum*
1282
+
1283
+ * Add support for `db:rollback:name` for multiple database applications.
1284
+
1285
+ Multiple database applications will now raise if `db:rollback` is call and recommend using the `db:rollback:[NAME]` to rollback migrations.
1286
+
1287
+ *Eileen M. Uchitelle*
1288
+
1289
+ * `Relation#pick` now uses already loaded results instead of making another query.
1290
+
1291
+ *Eugene Kenny*
1292
+
1293
+ * Deprecate using `return`, `break` or `throw` to exit a transaction block after writes.
1294
+
1295
+ *Dylan Thacker-Smith*
1296
+
1297
+ * Dump the schema or structure of a database when calling `db:migrate:name`.
1298
+
1299
+ In previous versions of Rails, `rails db:migrate` would dump the schema of the database. In Rails 6, that holds true (`rails db:migrate` dumps all databases' schemas), but `rails db:migrate:name` does not share that behavior.
1300
+
1301
+ Going forward, calls to `rails db:migrate:name` will dump the schema (or structure) of the database being migrated.
1302
+
1303
+ *Kyle Thompson*
1304
+
1305
+ * Reset the `ActiveRecord::Base` connection after `rails db:migrate:name`.
1306
+
1307
+ When `rails db:migrate` has finished, it ensures the `ActiveRecord::Base` connection is reset to its original configuration. Going forward, `rails db:migrate:name` will have the same behavior.
1308
+
1309
+ *Kyle Thompson*
1310
+
1311
+ * Disallow calling `connected_to` on subclasses of `ActiveRecord::Base`.
1312
+
1313
+ Behavior has not changed here but the previous API could be misleading to people who thought it would switch connections for only that class. `connected_to` switches the context from which we are getting connections, not the connections themselves.
1314
+
1315
+ *Eileen M. Uchitelle*, *John Crepezzi*
1316
+
1317
+ * Add support for horizontal sharding to `connects_to` and `connected_to`.
1318
+
1319
+ Applications can now connect to multiple shards and switch between their shards in an application. Note that the shard swapping is still a manual process as this change does not include an API for automatic shard swapping.
1320
+
1321
+ Usage:
1322
+
1323
+ Given the following configuration:
1324
+
1325
+ ```yaml
1326
+ # config/database.yml
991
1327
  production:
1328
+ primary:
1329
+ database: my_database
1330
+ primary_shard_one:
1331
+ database: my_database_shard_one
1332
+ ```
1333
+
1334
+ Connect to multiple shards:
1335
+
1336
+ ```ruby
1337
+ class ApplicationRecord < ActiveRecord::Base
1338
+ self.abstract_class = true
1339
+
1340
+ connects_to shards: {
1341
+ default: { writing: :primary },
1342
+ shard_one: { writing: :primary_shard_one }
1343
+ }
1344
+ ```
1345
+
1346
+ Swap between shards in your controller / model code:
1347
+
1348
+ ```ruby
1349
+ ActiveRecord::Base.connected_to(shard: :shard_one) do
1350
+ # Read from shard one
1351
+ end
1352
+ ```
1353
+
1354
+ The horizontal sharding API also supports read replicas. See guides for more details.
1355
+
1356
+ *Eileen M. Uchitelle*, *John Crepezzi*
1357
+
1358
+ * Deprecate `spec_name` in favor of `name` on database configurations.
1359
+
1360
+ The accessors for `spec_name` on `configs_for` and `DatabaseConfig` are deprecated. Please use `name` instead.
1361
+
1362
+ Deprecated behavior:
1363
+
1364
+ ```ruby
1365
+ db_config = ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
1366
+ db_config.spec_name
1367
+ ```
1368
+
1369
+ New behavior:
1370
+
1371
+ ```ruby
1372
+ db_config = ActiveRecord::Base.configurations.configs_for(env_name: "development", name: "primary")
1373
+ db_config.name
1374
+ ```
1375
+
1376
+ *Eileen M. Uchitelle*
1377
+
1378
+ * Add additional database-specific rake tasks for multi-database users.
1379
+
1380
+ Previously, `rails db:create`, `rails db:drop`, and `rails db:migrate` were the only rails tasks that could operate on a single
1381
+ database. For example:
1382
+
1383
+ ```
1384
+ rails db:create
1385
+ rails db:create:primary
1386
+ rails db:create:animals
1387
+ rails db:drop
1388
+ rails db:drop:primary
1389
+ rails db:drop:animals
1390
+ rails db:migrate
1391
+ rails db:migrate:primary
1392
+ rails db:migrate:animals
1393
+ ```
1394
+
1395
+ With these changes, `rails db:schema:dump`, `rails db:schema:load`, `rails db:structure:dump`, `rails db:structure:load` and
1396
+ `rails db:test:prepare` can additionally operate on a single database. For example:
1397
+
1398
+ ```
1399
+ rails db:schema:dump
1400
+ rails db:schema:dump:primary
1401
+ rails db:schema:dump:animals
1402
+ rails db:schema:load
1403
+ rails db:schema:load:primary
1404
+ rails db:schema:load:animals
1405
+ rails db:structure:dump
1406
+ rails db:structure:dump:primary
1407
+ rails db:structure:dump:animals
1408
+ rails db:structure:load
1409
+ rails db:structure:load:primary
1410
+ rails db:structure:load:animals
1411
+ rails db:test:prepare
1412
+ rails db:test:prepare:primary
1413
+ rails db:test:prepare:animals
1414
+ ```
1415
+
1416
+ *Kyle Thompson*
1417
+
1418
+ * Add support for `strict_loading` mode on association declarations.
1419
+
1420
+ Raise an error if attempting to load a record from an association that has been marked as `strict_loading` unless it was explicitly eager loaded.
1421
+
1422
+ Usage:
1423
+
1424
+ ```ruby
1425
+ class Developer < ApplicationRecord
1426
+ has_many :projects, strict_loading: true
1427
+ end
1428
+
1429
+ dev = Developer.first
1430
+ dev.projects.first
1431
+ # => ActiveRecord::StrictLoadingViolationError: The projects association is marked as strict_loading and cannot be lazily loaded.
1432
+ ```
1433
+
1434
+ *Kevin Deisz*
1435
+
1436
+ * Add support for `strict_loading` mode to prevent lazy loading of records.
1437
+
1438
+ Raise an error if a parent record is marked as `strict_loading` and attempts to lazily load its associations. This is useful for finding places you may want to preload an association and avoid additional queries.
1439
+
1440
+ Usage:
1441
+
1442
+ ```ruby
1443
+ dev = Developer.strict_loading.first
1444
+ dev.audit_logs.to_a
1445
+ # => ActiveRecord::StrictLoadingViolationError: Developer is marked as strict_loading and AuditLog cannot be lazily loaded.
1446
+ ```
1447
+
1448
+ *Eileen M. Uchitelle*, *Aaron Patterson*
1449
+
1450
+ * Add support for PostgreSQL 11+ partitioned indexes when using `upsert_all`.
1451
+
1452
+ *Sebastián Palma*
1453
+
1454
+ * Adds support for `if_not_exists` to `add_column` and `if_exists` to `remove_column`.
1455
+
1456
+ Applications can set their migrations to ignore exceptions raised when adding a column that already exists or when removing a column that does not exist.
1457
+
1458
+ Example Usage:
1459
+
1460
+ ```ruby
1461
+ class AddColumnTitle < ActiveRecord::Migration[6.1]
1462
+ def change
1463
+ add_column :posts, :title, :string, if_not_exists: true
1464
+ end
1465
+ end
1466
+ ```
1467
+
1468
+ ```ruby
1469
+ class RemoveColumnTitle < ActiveRecord::Migration[6.1]
1470
+ def change
1471
+ remove_column :posts, :title, if_exists: true
1472
+ end
1473
+ end
1474
+ ```
1475
+
1476
+ *Eileen M. Uchitelle*
1477
+
1478
+ * Regexp-escape table name for MS SQL Server.
1479
+
1480
+ 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.
1481
+
1482
+ *Larry Reid*
1483
+
1484
+ * Store advisory locks on their own named connection.
1485
+
1486
+ 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.
1487
+
1488
+ In order to fix this we are storing the advisory lock on a new connection with the connection specification name `AdvisoryLockBase`. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.
1489
+
1490
+ *Eileen M. Uchitelle*, *John Crepezzi*
1491
+
1492
+ * Allow schema cache path to be defined in the database configuration file.
1493
+
1494
+ For example:
1495
+
1496
+ ```yaml
1497
+ development:
992
1498
  adapter: postgresql
993
- advisory_locks: false
1499
+ database: blog_development
1500
+ pool: 5
1501
+ schema_cache_path: tmp/schema/main.yml
994
1502
  ```
995
1503
 
996
- *Guo Xiang*
1504
+ *Katrina Owen*
997
1505
 
998
- * SQLite3 adapter `alter_table` method restores foreign keys.
1506
+ * Deprecate `#remove_connection` in favor of `#remove_connection_pool` when called on the handler.
999
1507
 
1000
- *Yasuo Honda*
1508
+ `#remove_connection` is deprecated in order to support returning a `DatabaseConfig` object instead of a `Hash`. Use `#remove_connection_pool`, `#remove_connection` will be removed in Rails 7.0.
1001
1509
 
1002
- * Allow `:to_table` option to `invert_remove_foreign_key`.
1510
+ *Eileen M. Uchitelle*, *John Crepezzi*
1003
1511
 
1004
- Example:
1512
+ * Deprecate `#default_hash` and it's alias `#[]` on database configurations.
1513
+
1514
+ Applications should use `configs_for`. `#default_hash` and `#[]` will be removed in Rails 7.0.
1515
+
1516
+ *Eileen M. Uchitelle*, *John Crepezzi*
1517
+
1518
+ * Add scale support to `ActiveRecord::Validations::NumericalityValidator`.
1519
+
1520
+ *Gannon McGibbon*
1521
+
1522
+ * Find orphans by looking for missing relations through chaining `where.missing`:
1523
+
1524
+ Before:
1525
+
1526
+ ```ruby
1527
+ Post.left_joins(:author).where(authors: { id: nil })
1528
+ ```
1529
+
1530
+ After:
1531
+
1532
+ ```ruby
1533
+ Post.where.missing(:author)
1534
+ ```
1535
+
1536
+ *Tom Rossi*
1537
+
1538
+ * Ensure `:reading` connections always raise if a write is attempted.
1539
+
1540
+ 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`.
1541
+
1542
+ *Eileen M. Uchitelle*
1543
+
1544
+ * Deprecate `"primary"` as the `connection_specification_name` for `ActiveRecord::Base`.
1545
+
1546
+ `"primary"` has been deprecated as the `connection_specification_name` for `ActiveRecord::Base` in favor of using `"ActiveRecord::Base"`. This change affects calls to `ActiveRecord::Base.connection_handler.retrieve_connection` and `ActiveRecord::Base.connection_handler.remove_connection`. If you're calling these methods with `"primary"`, please switch to `"ActiveRecord::Base"`.
1547
+
1548
+ *Eileen M. Uchitelle*, *John Crepezzi*
1549
+
1550
+ * Add `ActiveRecord::Validations::NumericalityValidator` with
1551
+ support for casting floats using a database columns' precision value.
1552
+
1553
+ *Gannon McGibbon*
1554
+
1555
+ * Enforce fresh ETag header after a collection's contents change by adding
1556
+ ActiveRecord::Relation#cache_key_with_version. This method will be used by
1557
+ ActionController::ConditionalGet to ensure that when collection cache versioning
1558
+ is enabled, requests using ConditionalGet don't return the same ETag header
1559
+ after a collection is modified.
1560
+
1561
+ Fixes #38078.
1562
+
1563
+ *Aaron Lipman*
1564
+
1565
+ * Skip test database when running `db:create` or `db:drop` in development
1566
+ with `DATABASE_URL` set.
1567
+
1568
+ *Brian Buchalter*
1569
+
1570
+ * Don't allow mutations on the database configurations hash.
1571
+
1572
+ Freeze the configurations hash to disallow directly changing it. If applications need to change the hash, for example to create databases for parallelization, they should use the `DatabaseConfig` object directly.
1573
+
1574
+ Before:
1575
+
1576
+ ```ruby
1577
+ @db_config = ActiveRecord::Base.configurations.configs_for(env_name: "test", spec_name: "primary")
1578
+ @db_config.configuration_hash.merge!(idle_timeout: "0.02")
1579
+ ```
1580
+
1581
+ After:
1582
+
1583
+ ```ruby
1584
+ @db_config = ActiveRecord::Base.configurations.configs_for(env_name: "test", spec_name: "primary")
1585
+ config = @db_config.configuration_hash.merge(idle_timeout: "0.02")
1586
+ db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(@db_config.env_name, @db_config.spec_name, config)
1587
+ ```
1005
1588
 
1006
- remove_foreign_key :accounts, to_table: :owners
1589
+ *Eileen M. Uchitelle*, *John Crepezzi*
1007
1590
 
1008
- *Nikolay Epifanov*, *Rich Chen*
1591
+ * Remove `:connection_id` from the `sql.active_record` notification.
1009
1592
 
1010
- * Add environment & load_config dependency to `bin/rake db:seed` to enable
1011
- seed load in environments without Rails and custom DB configuration
1593
+ *Aaron Patterson*, *Rafael Mendonça França*
1012
1594
 
1013
- *Tobias Bielohlawek*
1595
+ * The `:name` key will no longer be returned as part of `DatabaseConfig#configuration_hash`. Please use `DatabaseConfig#owner_name` instead.
1014
1596
 
1015
- * Fix default value for mysql time types with specified precision.
1597
+ *Eileen M. Uchitelle*, *John Crepezzi*
1016
1598
 
1017
- *Nikolay Kondratyev*
1599
+ * ActiveRecord's `belongs_to_required_by_default` flag can now be set per model.
1018
1600
 
1019
- * Fix `touch` option to behave consistently with `Persistence#touch` method.
1601
+ You can now opt-out/opt-in specific models from having their associations required
1602
+ by default.
1603
+
1604
+ This change is meant to ease the process of migrating all your models to have
1605
+ their association required.
1606
+
1607
+ *Edouard Chin*
1608
+
1609
+ * The `connection_config` method has been deprecated, please use `connection_db_config` instead which will return a `DatabaseConfigurations::DatabaseConfig` instead of a `Hash`.
1610
+
1611
+ *Eileen M. Uchitelle*, *John Crepezzi*
1612
+
1613
+ * Retain explicit selections on the base model after applying `includes` and `joins`.
1614
+
1615
+ Resolves #34889.
1616
+
1617
+ *Patrick Rebsch*
1618
+
1619
+ * The `database` kwarg is deprecated without replacement because it can't be used for sharding and creates an issue if it's used during a request. Applications that need to create new connections should use `connects_to` instead.
1620
+
1621
+ *Eileen M. Uchitelle*, *John Crepezzi*
1622
+
1623
+ * Allow attributes to be fetched from Arel node groupings.
1624
+
1625
+ *Jeff Emminger*, *Gannon McGibbon*
1626
+
1627
+ * A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgreSQL `options`.
1628
+
1629
+ *Joshua Flanagan*
1630
+
1631
+ * Calling methods like `establish_connection` with a `Hash` which is invalid (eg: no `adapter`) will now raise an error the same way as connections defined in `config/database.yml`.
1632
+
1633
+ *John Crepezzi*
1634
+
1635
+ * Specifying `implicit_order_column` now subsorts the records by primary key if available to ensure deterministic results.
1636
+
1637
+ *Paweł Urbanek*
1638
+
1639
+ * `where(attr => [])` now loads an empty result without making a query.
1640
+
1641
+ *John Hawthorn*
1642
+
1643
+ * Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
1644
+
1645
+ *Hiroyuki Ishii*
1646
+
1647
+ * Add support for `belongs_to` to `has_many` inversing.
1648
+
1649
+ *Gannon McGibbon*
1650
+
1651
+ * Allow length configuration for `has_secure_token` method. The minimum length
1652
+ is set at 24 characters.
1653
+
1654
+ Before:
1655
+
1656
+ ```ruby
1657
+ has_secure_token :auth_token
1658
+ ```
1659
+
1660
+ After:
1661
+
1662
+ ```ruby
1663
+ has_secure_token :default_token # 24 characters
1664
+ has_secure_token :auth_token, length: 36 # 36 characters
1665
+ has_secure_token :invalid_token, length: 12 # => ActiveRecord::SecureToken::MinimumLengthError
1666
+ ```
1667
+
1668
+ *Bernardo de Araujo*
1669
+
1670
+ * Deprecate `DatabaseConfigurations#to_h`. These connection hashes are still available via `ActiveRecord::Base.configurations.configs_for`.
1671
+
1672
+ *Eileen Uchitelle*, *John Crepezzi*
1673
+
1674
+ * Add `DatabaseConfig#configuration_hash` to return database configuration hashes with symbol keys, and use all symbol-key configuration hashes internally. Deprecate `DatabaseConfig#config` which returns a String-keyed `Hash` with the same values.
1675
+
1676
+ *John Crepezzi*, *Eileen Uchitelle*
1677
+
1678
+ * Allow column names to be passed to `remove_index` positionally along with other options.
1679
+
1680
+ Passing other options can be necessary to make `remove_index` correctly reversible.
1681
+
1682
+ Before:
1683
+
1684
+ add_index :reports, :report_id # => works
1685
+ add_index :reports, :report_id, unique: true # => works
1686
+ remove_index :reports, :report_id # => works
1687
+ remove_index :reports, :report_id, unique: true # => ArgumentError
1688
+
1689
+ After:
1690
+
1691
+ remove_index :reports, :report_id, unique: true # => works
1692
+
1693
+ *Eugene Kenny*
1694
+
1695
+ * Allow bulk `ALTER` statements to drop and recreate indexes with the same name.
1696
+
1697
+ *Eugene Kenny*
1698
+
1699
+ * `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
1700
+
1701
+ *Eugene Kenny*
1702
+
1703
+ * Call `while_preventing_writes` directly from `connected_to`.
1704
+
1705
+ 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)`.
1706
+
1707
+ 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.
1708
+
1709
+ *Eileen M. Uchitelle*
1710
+
1711
+ * Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
1712
+
1713
+ *Kir Shatrov*
1714
+
1715
+ * Stop trying to read yaml file fixtures when loading Active Record fixtures.
1716
+
1717
+ *Gannon McGibbon*
1718
+
1719
+ * Deprecate `.reorder(nil)` with `.first` / `.first!` taking non-deterministic result.
1720
+
1721
+ To continue taking non-deterministic result, use `.take` / `.take!` instead.
1020
1722
 
1021
1723
  *Ryuta Kamizono*
1022
1724
 
1023
- * Migrations raise when duplicate column definition.
1725
+ * Preserve user supplied joins order as much as possible.
1024
1726
 
1025
- Fixes #33024.
1727
+ Fixes #36761, #34328, #24281, #12953.
1026
1728
 
1027
- *Federico Martinez*
1729
+ *Ryuta Kamizono*
1028
1730
 
1029
- * Bump minimum SQLite version to 3.8
1731
+ * Allow `matches_regex` and `does_not_match_regexp` on the MySQL Arel visitor.
1030
1732
 
1031
- *Yasuo Honda*
1733
+ *James Pearson*
1032
1734
 
1033
- * Fix parent record should not get saved with duplicate children records.
1735
+ * Allow specifying fixtures to be ignored by setting `ignore` in YAML file's '_fixture' section.
1034
1736
 
1035
- Fixes #32940.
1737
+ *Tongfei Gao*
1036
1738
 
1037
- *Santosh Wadghule*
1739
+ * Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
1038
1740
 
1039
- * Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
1741
+ *John Crepezzi*, *Eileen Uchitelle*
1040
1742
 
1041
- *Brian Durand*
1743
+ * Add a warning for enum elements with 'not_' prefix.
1042
1744
 
1043
- * Ensure `Associations::CollectionAssociation#size` and `Associations::CollectionAssociation#empty?`
1044
- use loaded association ids if present.
1745
+ class Foo
1746
+ enum status: [:sent, :not_sent]
1747
+ end
1045
1748
 
1046
- *Graham Turner*
1749
+ *Edu Depetris*
1047
1750
 
1048
- * Add support to preload associations of polymorphic associations when not all the records have the requested associations.
1751
+ * Make currency symbols optional for money column type in PostgreSQL.
1049
1752
 
1050
- *Dana Sherson*
1753
+ *Joel Schneider*
1051
1754
 
1052
- * Add `touch_all` method to `ActiveRecord::Relation`.
1755
+ * Add support for beginless ranges, introduced in Ruby 2.7.
1053
1756
 
1054
- Example:
1757
+ *Josh Goodall*
1758
+
1759
+ * Add `database_exists?` method to connection adapters to check if a database exists.
1055
1760
 
1056
- Person.where(name: "David").touch_all(time: Time.new(2020, 5, 16, 0, 0, 0))
1761
+ *Guilherme Mansur*
1057
1762
 
1058
- *fatkodima*, *duggiefresh*
1763
+ * Loading the schema for a model that has no `table_name` raises a `TableNotSpecified` error.
1059
1764
 
1060
- * Add `ActiveRecord::Base.base_class?` predicate.
1765
+ *Guilherme Mansur*, *Eugene Kenny*
1061
1766
 
1062
- *Bogdan Gusiev*
1767
+ * PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
1063
1768
 
1064
- * Add custom prefix/suffix options to `ActiveRecord::Store.store_accessor`.
1769
+ Fixes #36022.
1065
1770
 
1066
- *Tan Huynh*, *Yukio Mizuta*
1771
+ *Ryuta Kamizono*
1067
1772
 
1068
- * Rails 6 requires Ruby 2.5.0 or newer.
1773
+ * Make ActiveRecord `ConnectionPool.connections` method thread-safe.
1069
1774
 
1070
- *Jeremy Daer*, *Kasper Timm Hansen*
1775
+ Fixes #36465.
1071
1776
 
1072
- * Deprecate `update_attributes`/`!` in favor of `update`/`!`.
1777
+ *Jeff Doering*
1073
1778
 
1074
- *Eddie Lebow*
1779
+ * Add support for multiple databases to `rails db:abort_if_pending_migrations`.
1075
1780
 
1076
- * Add `ActiveRecord::Base.create_or_find_by`/`!` to deal with the SELECT/INSERT race condition in
1077
- `ActiveRecord::Base.find_or_create_by`/`!` by leaning on unique constraints in the database.
1781
+ *Mark Lee*
1078
1782
 
1079
- *DHH*
1783
+ * Fix sqlite3 collation parsing when using decimal columns.
1080
1784
 
1081
- * Add `Relation#pick` as short-hand for single-value plucks.
1785
+ *Martin R. Schuster*
1082
1786
 
1083
- *DHH*
1787
+ * Fix invalid schema when primary key column has a comment.
1788
+
1789
+ Fixes #29966.
1790
+
1791
+ *Guilherme Goettems Schneider*
1792
+
1793
+ * Fix table comment also being applied to the primary key column.
1794
+
1795
+ *Guilherme Goettems Schneider*
1796
+
1797
+ * Allow generated `create_table` migrations to include or skip timestamps.
1798
+
1799
+ *Michael Duchemin*
1084
1800
 
1085
1801
 
1086
- Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activerecord/CHANGELOG.md) for previous changes.
1802
+ Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activerecord/CHANGELOG.md) for previous changes.