activerecord 7.2.3.1 → 8.0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +475 -946
  3. data/README.rdoc +1 -1
  4. data/lib/active_record/association_relation.rb +1 -0
  5. data/lib/active_record/associations/association.rb +34 -10
  6. data/lib/active_record/associations/builder/association.rb +7 -6
  7. data/lib/active_record/associations/collection_association.rb +1 -1
  8. data/lib/active_record/associations/disable_joins_association_scope.rb +1 -1
  9. data/lib/active_record/associations/has_many_through_association.rb +3 -2
  10. data/lib/active_record/associations/join_dependency.rb +2 -2
  11. data/lib/active_record/associations/preloader/association.rb +2 -2
  12. data/lib/active_record/associations/preloader/batch.rb +7 -1
  13. data/lib/active_record/associations/singular_association.rb +8 -3
  14. data/lib/active_record/associations.rb +34 -4
  15. data/lib/active_record/asynchronous_queries_tracker.rb +28 -24
  16. data/lib/active_record/attribute_methods/primary_key.rb +4 -8
  17. data/lib/active_record/attribute_methods/query.rb +34 -0
  18. data/lib/active_record/attribute_methods/time_zone_conversion.rb +2 -12
  19. data/lib/active_record/autosave_association.rb +69 -27
  20. data/lib/active_record/connection_adapters/abstract/connection_handler.rb +34 -25
  21. data/lib/active_record/connection_adapters/abstract/connection_pool/queue.rb +0 -1
  22. data/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb +0 -1
  23. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +8 -17
  24. data/lib/active_record/connection_adapters/abstract/database_statements.rb +91 -44
  25. data/lib/active_record/connection_adapters/abstract/query_cache.rb +8 -2
  26. data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
  27. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +4 -5
  28. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +7 -2
  29. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +37 -10
  30. data/lib/active_record/connection_adapters/abstract/transaction.rb +15 -5
  31. data/lib/active_record/connection_adapters/abstract_adapter.rb +67 -74
  32. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +21 -40
  33. data/lib/active_record/connection_adapters/mysql/quoting.rb +0 -8
  34. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +2 -8
  35. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +50 -45
  36. data/lib/active_record/connection_adapters/mysql2/database_statements.rb +84 -94
  37. data/lib/active_record/connection_adapters/mysql2_adapter.rb +1 -8
  38. data/lib/active_record/connection_adapters/pool_config.rb +7 -7
  39. data/lib/active_record/connection_adapters/postgresql/column.rb +4 -2
  40. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +72 -43
  41. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -1
  42. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +10 -0
  43. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +2 -4
  44. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +1 -11
  45. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +6 -12
  46. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +2 -1
  47. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +59 -16
  48. data/lib/active_record/connection_adapters/postgresql_adapter.rb +53 -96
  49. data/lib/active_record/connection_adapters/schema_cache.rb +1 -3
  50. data/lib/active_record/connection_adapters/sqlite3/column.rb +8 -2
  51. data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +80 -100
  52. data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +0 -6
  53. data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +27 -2
  54. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +9 -1
  55. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +53 -12
  56. data/lib/active_record/connection_adapters/statement_pool.rb +4 -2
  57. data/lib/active_record/connection_adapters/trilogy/database_statements.rb +37 -67
  58. data/lib/active_record/connection_adapters/trilogy_adapter.rb +0 -17
  59. data/lib/active_record/connection_adapters.rb +0 -56
  60. data/lib/active_record/connection_handling.rb +23 -1
  61. data/lib/active_record/core.rb +29 -14
  62. data/lib/active_record/database_configurations/database_config.rb +4 -0
  63. data/lib/active_record/database_configurations/hash_config.rb +16 -2
  64. data/lib/active_record/encryption/config.rb +3 -1
  65. data/lib/active_record/encryption/encryptable_record.rb +4 -4
  66. data/lib/active_record/encryption/encrypted_attribute_type.rb +10 -1
  67. data/lib/active_record/encryption/encryptor.rb +16 -8
  68. data/lib/active_record/encryption/extended_deterministic_queries.rb +4 -2
  69. data/lib/active_record/encryption/scheme.rb +8 -1
  70. data/lib/active_record/enum.rb +9 -22
  71. data/lib/active_record/errors.rb +13 -5
  72. data/lib/active_record/fixtures.rb +0 -2
  73. data/lib/active_record/future_result.rb +15 -9
  74. data/lib/active_record/gem_version.rb +3 -3
  75. data/lib/active_record/insert_all.rb +3 -3
  76. data/lib/active_record/locking/optimistic.rb +1 -1
  77. data/lib/active_record/log_subscriber.rb +5 -11
  78. data/lib/active_record/migration/command_recorder.rb +32 -12
  79. data/lib/active_record/migration/compatibility.rb +5 -2
  80. data/lib/active_record/migration.rb +38 -42
  81. data/lib/active_record/model_schema.rb +3 -4
  82. data/lib/active_record/nested_attributes.rb +4 -6
  83. data/lib/active_record/persistence.rb +128 -130
  84. data/lib/active_record/query_logs.rb +102 -50
  85. data/lib/active_record/query_logs_formatter.rb +17 -28
  86. data/lib/active_record/querying.rb +8 -8
  87. data/lib/active_record/railtie.rb +2 -26
  88. data/lib/active_record/railties/databases.rake +11 -35
  89. data/lib/active_record/reflection.rb +18 -21
  90. data/lib/active_record/relation/batches/batch_enumerator.rb +4 -3
  91. data/lib/active_record/relation/batches.rb +132 -72
  92. data/lib/active_record/relation/calculations.rb +40 -39
  93. data/lib/active_record/relation/delegation.rb +25 -14
  94. data/lib/active_record/relation/finder_methods.rb +18 -18
  95. data/lib/active_record/relation/merger.rb +8 -8
  96. data/lib/active_record/relation/predicate_builder/array_handler.rb +3 -1
  97. data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +1 -1
  98. data/lib/active_record/relation/predicate_builder/relation_handler.rb +4 -3
  99. data/lib/active_record/relation/predicate_builder.rb +13 -0
  100. data/lib/active_record/relation/query_methods.rb +105 -61
  101. data/lib/active_record/relation/spawn_methods.rb +7 -7
  102. data/lib/active_record/relation/where_clause.rb +1 -1
  103. data/lib/active_record/relation.rb +80 -62
  104. data/lib/active_record/result.rb +66 -4
  105. data/lib/active_record/sanitization.rb +7 -6
  106. data/lib/active_record/schema_dumper.rb +5 -0
  107. data/lib/active_record/schema_migration.rb +2 -1
  108. data/lib/active_record/scoping/named.rb +5 -2
  109. data/lib/active_record/statement_cache.rb +14 -14
  110. data/lib/active_record/store.rb +7 -3
  111. data/lib/active_record/table_metadata.rb +1 -3
  112. data/lib/active_record/tasks/database_tasks.rb +69 -60
  113. data/lib/active_record/tasks/mysql_database_tasks.rb +0 -2
  114. data/lib/active_record/tasks/postgresql_database_tasks.rb +2 -1
  115. data/lib/active_record/tasks/sqlite_database_tasks.rb +2 -2
  116. data/lib/active_record/test_databases.rb +1 -1
  117. data/lib/active_record/test_fixtures.rb +12 -0
  118. data/lib/active_record/token_for.rb +1 -1
  119. data/lib/active_record/transactions.rb +5 -6
  120. data/lib/active_record/type/serialized.rb +5 -0
  121. data/lib/active_record/validations/uniqueness.rb +8 -8
  122. data/lib/active_record.rb +21 -48
  123. data/lib/arel/collectors/bind.rb +2 -2
  124. data/lib/arel/collectors/sql_string.rb +1 -1
  125. data/lib/arel/collectors/substitute_binds.rb +2 -2
  126. data/lib/arel/nodes/binary.rb +1 -1
  127. data/lib/arel/nodes/node.rb +1 -1
  128. data/lib/arel/nodes/sql_literal.rb +1 -1
  129. data/lib/arel/predications.rb +1 -3
  130. data/lib/arel/table.rb +3 -7
  131. metadata +10 -11
  132. data/lib/active_record/relation/record_fetch_warning.rb +0 -52
data/CHANGELOG.md CHANGED
@@ -1,9 +1,105 @@
1
- ## Rails 7.2.3.1 (March 23, 2026) ##
1
+ ## Rails 8.0.5.1 (July 29, 2026) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 7.2.3 (October 28, 2025) ##
6
+ ## Rails 8.0.5 (March 24, 2026) ##
7
+
8
+ * Fix `insert_all` and `upsert_all` log message when called on anonymous classes.
9
+
10
+ *Gabriel Sobrinho*
11
+
12
+ * Respect `ActiveRecord::SchemaDumper.ignore_tables` when dumping SQLite virtual tables.
13
+
14
+ *Hans Schnedlitz*
15
+
16
+ * Restore previous instrumenter after `execute_or_skip`
17
+
18
+ `FutureResult#execute_or_skip` replaces the thread's instrumenter with an
19
+ `EventBuffer` to collect events published during async query execution.
20
+ If the global async executor is saturated and the `caller_runs` fallback
21
+ executes the task on the calling thread, we need to make sure the previous
22
+ instrumenter is restored or the stale `EventBuffer` would stay in place and
23
+ permanently swallow all subsequent `sql.active_record` notifications on
24
+ that thread.
25
+
26
+ *Rosa Gutierrez*
27
+
28
+ * Fix Ruby 4.0 delegator warning when calling inspect on ActiveRecord::Type::Serialized.
29
+
30
+ *Hammad Khan*
31
+
32
+ * Fix support for table names containing hyphens.
33
+
34
+ *Evgeniy Demin*
35
+
36
+ * Fix column deduplication for SQLite3 and PostgreSQL virtual (generated) columns.
37
+
38
+ `Column#==` and `Column#hash` now account for `virtual?` so that the
39
+ `Deduplicable` registry does not treat a generated column and a regular
40
+ column with the same name and type as identical. Previously, if a
41
+ generated column was registered first, a regular column on a different
42
+ table could be deduplicated to the generated instance, silently
43
+ excluding it from INSERT/UPDATE statements.
44
+
45
+ *Jay Huber*
46
+
47
+ * Fix merging relations with arel equality predicates with null relations.
48
+
49
+ *fatkodima*
50
+
51
+ * Fix SQLite3 schema dump for non-autoincrement integer primary keys.
52
+
53
+ Previously, `schema.rb` should incorrectly restore that table with an auto incrementing
54
+ primary key.
55
+
56
+ *Chris Hasiński*
57
+
58
+ * Fix PostgreSQL `schema_search_path` not being reapplied after `reset!` or `reconnect!`.
59
+
60
+ The `schema_search_path` configured in `database.yml` is now correctly
61
+ reapplied instead of falling back to PostgreSQL defaults.
62
+
63
+ *Tobias Egli*
64
+
65
+ * Ensure batched preloaded associations accounts for klass when grouping to avoid issues with STI.
66
+
67
+ *zzak*, *Stjepan Hadjic*
68
+
69
+ * Fix `ActiveRecord::SoleRecordExceeded#record` to return the relation.
70
+
71
+ This was the case until Rails 7.2, but starting from 8.0 it
72
+ started mistakenly returning the model class.
73
+
74
+ *Jean Boussier*
75
+
76
+ * Improve PostgreSQLAdapter resilience to Timeout.timeout.
77
+
78
+ Better handle asynchronous exceptions being thrown inside
79
+ the `reconnect!` method.
80
+
81
+ This may fixes some deep errors such as:
82
+
83
+ ```
84
+ undefined method `key?' for nil:NilClass (NoMethodError)
85
+ if !type_map.key?(oid)
86
+ ```
87
+
88
+ *Jean Boussier*
89
+
90
+ * Fix `eager_load` when loading `has_many` assocations with composite primary keys.
91
+
92
+ This would result in some records being loaded multiple times.
93
+
94
+ *Martin-Alexander*
95
+
96
+
97
+ ## Rails 8.0.4.1 (March 23, 2026) ##
98
+
99
+ * No changes.
100
+
101
+
102
+ ## Rails 8.0.4 (October 28, 2025) ##
7
103
 
8
104
  * Fix SQLite3 data loss during table alterations with CASCADE foreign keys.
9
105
 
@@ -27,6 +123,10 @@
27
123
 
28
124
  *Ruy Rocha*
29
125
 
126
+ * Add support for bound SQL literals in CTEs.
127
+
128
+ *Nicolas Bachschmidt*
129
+
30
130
  * Fix `belongs_to` associations not to clear the entire composite primary key.
31
131
 
32
132
  When clearing a `belongs_to` association that references a model with composite primary key,
@@ -38,23 +138,10 @@
38
138
 
39
139
  *Ian Terrell*, *axlekb AB*
40
140
 
41
- * Prevent persisting invalid record.
42
-
43
- *Edouard Chin*
44
-
45
- * Fix count with group by qualified name on loaded relation.
46
-
47
- *Ryuta Kamizono*
48
-
49
- * Fix `sum` with qualified name on loaded relation.
50
-
51
- *Chris Gunther*
52
-
53
- * Fix prepared statements on mysql2 adapter.
54
141
 
55
- *Jean Boussier*
142
+ ## Rails 8.0.3 (September 22, 2025) ##
56
143
 
57
- * Fix query cache for pinned connections in multi threaded transactional tests.
144
+ * Fix query cache for pinned connections in multi threaded transactional tests
58
145
 
59
146
  When a pinned connection is used across separate threads, they now use a separate cache store
60
147
  for each thread.
@@ -67,21 +154,42 @@
67
154
 
68
155
  *Rob Lewis*
69
156
 
70
- * Fix false positive change detection involving STI and polymorhic has one relationships.
157
+ * Fix false positive change detection involving STI and polymorphic has one relationships.
71
158
 
72
159
  Polymorphic `has_one` relationships would always be considered changed when defined in a STI child
73
160
  class, causing nedless extra autosaves.
74
161
 
75
162
  *David Fritsch*
76
163
 
77
- * Fix stale associaton detection for polymophic `belong_to`.
164
+ * Skip calling `PG::Connection#cancel` in `cancel_any_running_query`
165
+ when using libpq >= 18 with pg < 1.6.0, due to incompatibility.
166
+ Rollback still runs, but may take longer.
167
+
168
+ *Yasuo Honda*, *Lars Kanis*
169
+
170
+ * Fix stale association detection for polymorphic `belongs_to`.
78
171
 
79
172
  *Florent Beaurain*, *Thomas Crambert*
80
173
 
81
- * Fix removal of PostgreSQL version comments in `structure.sql` for latest PostgreSQL versions which include `\restrict`.
174
+ * Fix removal of PostgreSQL version comments in `structure.sql` for latest PostgreSQL versions which include `\restrict`
82
175
 
83
176
  *Brendan Weibrecht*
84
177
 
178
+ * Allow setting `schema_format` in database configuration.
179
+
180
+ ```
181
+ primary:
182
+ schema_format: ruby
183
+ ```
184
+
185
+ Useful in multi-database setups to have different formats per-database.
186
+
187
+ *T S Vallender*
188
+
189
+ * Use ntuples to populate row_count instead of count for Postgres
190
+
191
+ *Jonathan Calvert*
192
+
85
193
  * Fix `#merge` with `#or` or `#and` and a mixture of attributes and SQL strings resulting in an incorrect query.
86
194
 
87
195
  ```ruby
@@ -124,6 +232,18 @@
124
232
 
125
233
  *fatkodima*
126
234
 
235
+ * Fix migration log message for down operations.
236
+
237
+ *Bernardo Barreto*
238
+
239
+ * Prepend `extra_flags` in postgres' `structure_load`
240
+
241
+ When specifying `structure_load_flags` with a postgres adapter, the flags
242
+ were appended to the default flags, instead of prepended.
243
+ This caused issues with flags not being taken into account by postgres.
244
+
245
+ *Alice Loeser*
246
+
127
247
  * Fix `annotate` comments to propagate to `update_all`/`delete_all`.
128
248
 
129
249
  *fatkodima*
@@ -133,10 +253,6 @@
133
253
 
134
254
  *Hartley McGuire*
135
255
 
136
- * Fix inline has_and_belongs_to_many fixtures for tables with composite primary keys.
137
-
138
- *fatkodima*
139
-
140
256
  * `create_or_find_by` will now correctly rollback a transaction.
141
257
 
142
258
  When using `create_or_find_by`, raising a ActiveRecord::Rollback error
@@ -155,6 +271,42 @@
155
271
 
156
272
  *Jean Boussier*
157
273
 
274
+ * Fix stale state for composite foreign keys in belongs_to associations.
275
+
276
+ *Varun Sharma*
277
+
278
+
279
+ ## Rails 8.0.2.1 (August 13, 2025) ##
280
+
281
+ * Call inspect on ids in RecordNotFound error
282
+
283
+ [CVE-2025-55193]
284
+
285
+ *Gannon McGibbon*, *John Hawthorn*
286
+
287
+
288
+ ## Rails 8.0.2 (March 12, 2025) ##
289
+
290
+ * Fix inverting `rename_enum_value` when `:from`/`:to` are provided.
291
+
292
+ *fatkodima*
293
+
294
+ * Prevent persisting invalid record.
295
+
296
+ *Edouard Chin*
297
+
298
+ * Fix inverting `drop_table` without options.
299
+
300
+ *fatkodima*
301
+
302
+ * Fix count with group by qualified name on loaded relation.
303
+
304
+ *Ryuta Kamizono*
305
+
306
+ * Fix `sum` with qualified name on loaded relation.
307
+
308
+ *Chris Gunther*
309
+
158
310
  * The SQLite3 adapter quotes non-finite Numeric values like "Infinity" and "NaN".
159
311
 
160
312
  *Mike Dalessio*
@@ -187,7 +339,25 @@
187
339
 
188
340
  *zzak*
189
341
 
190
- * Prevent persisting invalid record.
342
+ * PoolConfig no longer keeps a reference to the connection class.
343
+
344
+ Keeping a reference to the class caused subtle issues when combined with reloading in
345
+ development. Fixes #54343.
346
+
347
+ *Mike Dalessio*
348
+
349
+ * Fix SQL notifications sometimes not sent when using async queries.
350
+
351
+ ```ruby
352
+ Post.async_count
353
+ ActiveSupport::Notifications.subscribed(->(*) { "Will never reach here" }) do
354
+ Post.count
355
+ end
356
+ ```
357
+
358
+ In rare circumstances and under the right race condition, Active Support notifications
359
+ would no longer be dispatched after using an asynchronous query.
360
+ This is now fixed.
191
361
 
192
362
  *Edouard Chin*
193
363
 
@@ -225,14 +395,6 @@
225
395
 
226
396
  *Sjoerd Lagarde*
227
397
 
228
- * Fix count with group by qualified name on loaded relation.
229
-
230
- *Ryuta Kamizono*
231
-
232
- * Fix sum with qualified name on loaded relation.
233
-
234
- *Chris Gunther*
235
-
236
398
  * Fix autosave associations to no longer validated unmodified associated records.
237
399
 
238
400
  Active Record was incorrectly performing validation on associated record that
@@ -254,9 +416,12 @@
254
416
 
255
417
  *Matthew Draper*
256
418
 
257
- * Fix prepared statements on mysql2 adapter.
258
419
 
259
- *Jean Boussier*
420
+ ## Rails 8.0.1 (December 13, 2024) ##
421
+
422
+ * Fix removing foreign keys with :restrict action for MySQL.
423
+
424
+ *fatkodima*
260
425
 
261
426
  * Fix a race condition in `ActiveRecord::Base#method_missing` when lazily defining attributes.
262
427
 
@@ -269,8 +434,7 @@
269
434
 
270
435
  *Bastian Bartmann*
271
436
 
272
- * Fix `add_unique_constraint`/`add_check_constraint`/`/`add_foreign_key` to be revertible when
273
- given invalid options.
437
+ * Fix `add_unique_constraint`/`add_check_constraint`/`add_foreign_key` to be revertible when given invalid options.
274
438
 
275
439
  *fatkodima*
276
440
 
@@ -278,7 +442,11 @@
278
442
 
279
443
  *fatkodima*
280
444
 
281
- * NOT VALID constraints should not dump in `create_table`.
445
+ * Fix `insert_all` to not update existing records.
446
+
447
+ *fatkodima*
448
+
449
+ * `NOT VALID` constraints should not dump in `create_table`.
282
450
 
283
451
  *Ryuta Kamizono*
284
452
 
@@ -286,6 +454,16 @@
286
454
 
287
455
  *fatkodima*
288
456
 
457
+ * Properly reset composite primary key configuration when setting a primary key.
458
+
459
+ *fatkodima*
460
+
461
+ * Fix Mysql2Adapter support for prepared statements
462
+
463
+ Using prepared statements with MySQL could result in a `NoMethodError` exception.
464
+
465
+ *Jean Boussier*, *Leo Arnold*, *zzak*
466
+
289
467
  * Fix parsing of SQLite foreign key names when they contain non-ASCII characters
290
468
 
291
469
  *Zacharias Knudsen*
@@ -298,63 +476,101 @@
298
476
 
299
477
  *Joshua Young*
300
478
 
301
- * Restore back the ability to pass only database name for `DATABASE_URL`.
479
+ * Fix `sum` when performing a grouped calculation.
480
+
481
+ `User.group(:friendly).sum` no longer worked. This is fixed.
482
+
483
+ *Edouard Chin*
484
+
485
+ * Restore back the ability to pass only database name to `DATABASE_URL`.
302
486
 
303
487
  *fatkodima*
304
488
 
305
- * Fix `order` with using association name as an alias.
306
489
 
307
- *Ryuta Kamizono*
490
+ ## Rails 8.0.0.1 (December 10, 2024) ##
308
491
 
309
- * Improve invalid argument error for with.
492
+ * No changes.
493
+
494
+
495
+ ## Rails 8.0.0 (November 07, 2024) ##
496
+
497
+ * Fix support for `query_cache: false` in `database.yml`.
498
+
499
+ `query_cache: false` would no longer entirely disable the Active Record query cache.
500
+
501
+ *zzak*
502
+
503
+
504
+ ## Rails 8.0.0.rc2 (October 30, 2024) ##
505
+
506
+ * NULLS NOT DISTINCT works with UNIQUE CONSTRAINT as well as UNIQUE INDEX.
310
507
 
311
508
  *Ryuta Kamizono*
312
509
 
313
- * Deduplicate `with` CTE expressions.
510
+ * The `db:prepare` task no longer loads seeds when a non-primary database is created.
314
511
 
315
- *fatkodima*
512
+ Previously, the `db:prepare` task would load seeds whenever a new database
513
+ is created, leading to potential loss of data if a database is added to an
514
+ existing environment.
316
515
 
516
+ Introduces a new database config property `seeds` to control whether seeds
517
+ are loaded during `db:prepare` which defaults to `true` for primary database
518
+ configs and `false` otherwise.
317
519
 
318
- ## Rails 7.2.2.2 (August 13, 2025) ##
520
+ Fixes #53348.
319
521
 
320
- * Call inspect on ids in RecordNotFound error
522
+ *Mike Dalessio*
321
523
 
322
- [CVE-2025-55193]
524
+ * `PG::UnableToSend: no connection to the server` is now retryable as a connection-related exception
323
525
 
324
- *Gannon McGibbon*, *John Hawthorn*
526
+ *Kazuma Watanabe*
325
527
 
528
+ * Fix strict loading propagation even if statement cache is not used.
326
529
 
327
- ## Rails 7.2.2.1 (December 10, 2024) ##
530
+ *Ryuta Kamizono*
328
531
 
329
- * No changes.
532
+ * Allow `rename_enum` accepts two from/to name arguments as `rename_table` does so.
330
533
 
534
+ *Ryuta Kamizono*
331
535
 
332
- ## Rails 7.2.2 (October 30, 2024) ##
333
536
 
334
- * Fix support for `query_cache: false` in `database.yml`.
537
+ ## Rails 8.0.0.rc1 (October 19, 2024) ##
335
538
 
336
- `query_cache: false` would no longer entirely disable the Active Record query cache.
539
+ * Remove deprecated support to setting `ENV["SCHEMA_CACHE"]`.
337
540
 
338
- *zzak*
541
+ *Rafael Mendonça França*
339
542
 
340
- * Set `.attributes_for_inspect` to `:all` by default.
543
+ * Remove deprecated support to passing a database name to `cache_dump_filename`.
544
+
545
+ *Rafael Mendonça França*
341
546
 
342
- For new applications it is set to `[:id]` in config/environment/production.rb.
547
+ * Remove deprecated `ActiveRecord::ConnectionAdapters::ConnectionPool#connection`.
343
548
 
344
- In the console all the attributes are always shown.
549
+ *Rafael Mendonça França*
345
550
 
346
- *Andrew Novoselac*
551
+ * Remove deprecated `config.active_record.sqlite3_deprecated_warning`.
347
552
 
348
- * `PG::UnableToSend: no connection to the server` is now retryable as a connection-related exception
553
+ *Rafael Mendonça França*
349
554
 
350
- *Kazuma Watanabe*
555
+ * Remove deprecated `config.active_record.warn_on_records_fetched_greater_than`.
351
556
 
352
- * Fix marshalling of unsaved associated records in 7.1 format.
557
+ *Rafael Mendonça França*
353
558
 
354
- The 7.1 format would only marshal associated records if the association was loaded.
355
- But associations that would only contain unsaved records would be skipped.
559
+ * Remove deprecated support for defining `enum` with keyword arguments.
356
560
 
357
- *Jean Boussier*
561
+ *Rafael Mendonça França*
562
+
563
+ * Remove deprecated support to finding database adapters that aren't registered to Active Record.
564
+
565
+ *Rafael Mendonça França*
566
+
567
+ * Remove deprecated `config.active_record.allow_deprecated_singular_associations_name`.
568
+
569
+ *Rafael Mendonça França*
570
+
571
+ * Remove deprecated `config.active_record.commit_transaction_on_non_local_return`.
572
+
573
+ *Rafael Mendonça França*
358
574
 
359
575
  * Fix incorrect SQL query when passing an empty hash to `ActiveRecord::Base.insert`.
360
576
 
@@ -369,70 +585,42 @@
369
585
 
370
586
  *Joshua Young*
371
587
 
372
- * Fix `dependent: :destroy` for bi-directional has one through association.
373
-
374
- Fixes #50948.
588
+ * Allow `ActiveRecord::Base#pluck` to accept hash arguments with symbol and string values.
375
589
 
376
590
  ```ruby
377
- class Left < ActiveRecord::Base
378
- has_one :middle, dependent: :destroy
379
- has_one :right, through: :middle
380
- end
381
-
382
- class Middle < ActiveRecord::Base
383
- belongs_to :left, dependent: :destroy
384
- belongs_to :right, dependent: :destroy
385
- end
386
-
387
- class Right < ActiveRecord::Base
388
- has_one :middle, dependent: :destroy
389
- has_one :left, through: :middle
390
- end
591
+ Post.joins(:comments).pluck(:id, comments: :id)
592
+ Post.joins(:comments).pluck("id", "comments" => "id")
391
593
  ```
392
- In the above example `left.destroy` wouldn't destroy its associated `Right`
393
- record.
394
594
 
395
- *Andy Stewart*
595
+ *Joshua Young*
596
+
597
+ * Make Float distinguish between `float4` and `float8` in PostgreSQL.
396
598
 
397
- * Properly handle lazily pinned connection pools.
599
+ Fixes #52742
398
600
 
399
- Fixes #53147.
601
+ *Ryota Kitazawa*, *Takayuki Nagatomi*
400
602
 
401
- When using transactional fixtures with system tests to similar tools
402
- such as capybara, it could happen that a connection end up pinned by the
403
- server thread rather than the test thread, causing
404
- `"Cannot expire connection, it is owned by a different thread"` errors.
405
603
 
406
- *Jean Boussier*
604
+ ## Rails 8.0.0.beta1 (September 26, 2024) ##
407
605
 
408
- * Fix `ActiveRecord::Base.with` to accept more than two sub queries.
606
+ * Allow `drop_table` to accept an array of table names.
409
607
 
410
- Fixes #53110.
608
+ This will let you to drop multiple tables in a single call.
411
609
 
412
610
  ```ruby
413
- User.with(foo: [User.select(:id), User.select(:id), User.select(:id)]).to_sql
414
- undefined method `union' for an instance of Arel::Nodes::UnionAll (NoMethodError)
611
+ ActiveRecord::Base.lease_connection.drop_table(:users, :posts)
415
612
  ```
416
613
 
417
- The above now works as expected.
614
+ *Gabriel Sobrinho*
418
615
 
419
- *fatkodima*
420
-
421
- * Properly release pinned connections with non joinable connections.
422
-
423
- Fixes #52973
424
-
425
- When running system tests with transactional fixtures on, it could happen that
426
- the connection leased by the Puma thread wouldn't be properly released back to the pool,
427
- causing "Cannot expire connection, it is owned by a different thread" errors in later tests.
616
+ * Add support for PostgreSQL `IF NOT EXISTS` via the `:if_not_exists` option
617
+ on the `add_enum_value` method.
428
618
 
429
- *Jean Boussier*
430
-
431
- * Make Float distinguish between `float4` and `float8` in PostgreSQL.
619
+ *Ariel Rzezak*
432
620
 
433
- Fixes #52742
621
+ * When running `db:migrate` on a fresh database, load the databases schemas before running migrations.
434
622
 
435
- *Ryota Kitazawa*, *Takayuki Nagatomi*
623
+ *Andrew Novoselac*, *Marek Kasztelnik*
436
624
 
437
625
  * Fix an issue where `.left_outer_joins` used with multiple associations that have
438
626
  the same child association but different parents does not join all parents.
@@ -445,6 +633,39 @@
445
633
 
446
634
  *Garrett Blehm*
447
635
 
636
+ * Deprecate `unsigned_float` and `unsigned_decimal` short-hand column methods.
637
+
638
+ As of MySQL 8.0.17, the UNSIGNED attribute is deprecated for columns of type FLOAT, DOUBLE,
639
+ and DECIMAL. Consider using a simple CHECK constraint instead for such columns.
640
+
641
+ https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
642
+
643
+ *Ryuta Kamizono*
644
+
645
+ * Drop MySQL 5.5 support.
646
+
647
+ MySQL 5.5 is the only version that does not support datetime with precision,
648
+ which we have supported in the core. Now we support MySQL 5.6.4 or later, which
649
+ is the first version to support datetime with precision.
650
+
651
+ *Ryuta Kamizono*
652
+
653
+ * Make Active Record asynchronous queries compatible with transactional fixtures.
654
+
655
+ Previously transactional fixtures would disable asynchronous queries, because transactional
656
+ fixtures impose all queries use the same connection.
657
+
658
+ Now asynchronous queries will use the connection pinned by transactional fixtures, and behave
659
+ much closer to production.
660
+
661
+ *Jean Boussier*
662
+
663
+ * Deserialize binary data before decrypting
664
+
665
+ This ensures that we call `PG::Connection.unescape_bytea` on PostgreSQL before decryption.
666
+
667
+ *Donal McBreen*
668
+
448
669
  * Ensure `ActiveRecord::Encryption.config` is always ready before access.
449
670
 
450
671
  Previously, `ActiveRecord::Encryption` configuration was deferred until `ActiveRecord::Base`
@@ -467,954 +688,262 @@
467
688
 
468
689
  *Ruy Rocha*
469
690
 
691
+ * Add support for SQLite3 full-text-search and other virtual tables.
470
692
 
471
- ## Rails 7.2.1.2 (October 23, 2024) ##
693
+ Previously, adding sqlite3 virtual tables messed up `schema.rb`.
472
694
 
473
- * No changes.
695
+ Now, virtual tables can safely be added using `create_virtual_table`.
474
696
 
697
+ *Zacharias Knudsen*
475
698
 
476
- ## Rails 7.2.1.1 (October 15, 2024) ##
699
+ * Support use of alternative database interfaces via the `database_cli` ActiveRecord configuration option.
477
700
 
478
- * No changes.
701
+ ```ruby
702
+ Rails.application.configure do
703
+ config.active_record.database_cli = { postgresql: "pgcli" }
704
+ end
705
+ ```
479
706
 
707
+ *T S Vallender*
480
708
 
481
- ## Rails 7.2.1 (August 22, 2024) ##
709
+ * Add support for dumping table inheritance and native partitioning table definitions for PostgeSQL adapter
482
710
 
483
- * Fix detection for `enum` columns with parallelized tests and PostgreSQL.
711
+ *Justin Talbott*
484
712
 
485
- *Rafael Mendonça França*
713
+ * Add support for `ActiveRecord::Point` type casts using `Hash` values
486
714
 
487
- * Allow to eager load nested nil associations.
715
+ This allows `ActiveRecord::Point` to be cast or serialized from a hash
716
+ with `:x` and `:y` keys of numeric values, mirroring the functionality of
717
+ existing casts for string and array values. Both string and symbol keys are
718
+ supported.
488
719
 
489
- *fatkodima*
720
+ ```ruby
721
+ class PostgresqlPoint < ActiveRecord::Base
722
+ attribute :x, :point
723
+ attribute :y, :point
724
+ attribute :z, :point
725
+ end
490
726
 
491
- * Fix swallowing ignore order warning when batching using `BatchEnumerator`.
727
+ val = PostgresqlPoint.new({
728
+ x: '(12.34, -43.21)',
729
+ y: [12.34, '-43.21'],
730
+ z: {x: '12.34', y: -43.21}
731
+ })
732
+ ActiveRecord::Point.new(12.32, -43.21) == val.x == val.y == val.z
733
+ ```
492
734
 
493
- *fatkodima*
735
+ *Stephen Drew*
494
736
 
495
- * Fix memory bloat on the connection pool when using the Fiber `IsolatedExecutionState`.
737
+ * Replace `SQLite3::Database#busy_timeout` with `#busy_handler_timeout=`.
496
738
 
497
- *Jean Boussier*
739
+ Provides a non-GVL-blocking, fair retry interval busy handler implementation.
498
740
 
499
- * Restore inferred association class with the same modularized name.
741
+ *Stephen Margheim*
500
742
 
501
- *Justin Ko*
743
+ * SQLite3Adapter: Translate `SQLite3::BusyException` into `ActiveRecord::StatementTimeout`.
502
744
 
503
- * Fix `ActiveRecord::Base.inspect` to properly explain how to load schema information.
745
+ *Matthew Nguyen*
504
746
 
505
- *Jean Boussier*
747
+ * Include schema name in `enable_extension` statements in `db/schema.rb`.
506
748
 
507
- * Check invalid `enum` options for the new syntax.
749
+ The schema dumper will now include the schema name in generated
750
+ `enable_extension` statements if they differ from the current schema.
508
751
 
509
- The options using `_` prefix in the old syntax are invalid in the new syntax.
752
+ For example, if you have a migration:
510
753
 
511
- *Rafael Mendonça França*
754
+ ```ruby
755
+ enable_extension "heroku_ext.pgcrypto"
756
+ enable_extension "pg_stat_statements"
757
+ ```
758
+
759
+ then the generated schema dump will also contain:
760
+
761
+ ```ruby
762
+ enable_extension "heroku_ext.pgcrypto"
763
+ enable_extension "pg_stat_statements"
764
+ ```
765
+
766
+ *Tony Novak*
512
767
 
513
768
  * Fix `ActiveRecord::Encryption::EncryptedAttributeType#type` to return
514
769
  actual cast type.
515
770
 
516
771
  *Vasiliy Ermolovich*
517
772
 
518
- * Fix `create_table` with `:auto_increment` option for MySQL adapter.
519
-
520
- *fatkodima*
773
+ * SQLite3Adapter: Bulk insert fixtures.
521
774
 
775
+ Previously one insert command was executed for each fixture, now they are
776
+ aggregated in a single bulk insert command.
522
777
 
523
- ## Rails 7.2.0 (August 09, 2024) ##
778
+ *Lázaro Nixon*
524
779
 
525
- * Handle commas in Sqlite3 default function definitions.
780
+ * PostgreSQLAdapter: Allow `disable_extension` to be called with schema-qualified name.
526
781
 
527
- *Stephen Margheim*
782
+ For parity with `enable_extension`, the `disable_extension` method can be called with a schema-qualified
783
+ name (e.g. `disable_extension "myschema.pgcrypto"`). Note that PostgreSQL's `DROP EXTENSION` does not
784
+ actually take a schema name (unlike `CREATE EXTENSION`), so the resulting SQL statement will only name
785
+ the extension, e.g. `DROP EXTENSION IF EXISTS "pgcrypto"`.
528
786
 
529
- * Fixes `validates_associated` raising an exception when configured with a
530
- singular association and having `index_nested_attribute_errors` enabled.
787
+ *Tony Novak*
531
788
 
532
- *Martin Spickermann*
789
+ * Make `create_schema` / `drop_schema` reversible in migrations.
533
790
 
534
- * The constant `ActiveRecord::ImmutableRelation` has been deprecated because
535
- we want to reserve that name for a stronger sense of "immutable relation".
536
- Please use `ActiveRecord::UnmodifiableRelation` instead.
791
+ Previously, `create_schema` and `drop_schema` were irreversible migration operations.
537
792
 
538
- *Xavier Noria*
793
+ *Tony Novak*
539
794
 
540
- * Add condensed `#inspect` for `ConnectionPool`, `AbstractAdapter`, and
541
- `DatabaseConfig`.
542
-
543
- *Hartley McGuire*
544
-
545
- * Fixed a memory performance issue in Active Record attribute methods definition.
546
-
547
- *Jean Boussier*
548
-
549
- * Define the new Active Support notification event `start_transaction.active_record`.
550
-
551
- This event is fired when database transactions or savepoints start, and
552
- complements `transaction.active_record`, which is emitted when they finish.
553
-
554
- The payload has the transaction (`:transaction`) and the connection (`:connection`).
555
-
556
- *Xavier Noria*
557
-
558
- * Fix an issue where the IDs reader method did not return expected results
559
- for preloaded associations in models using composite primary keys.
560
-
561
- *Jay Ang*
562
-
563
- * The payload of `sql.active_record` Active Support notifications now has the current transaction in the `:transaction` key.
564
-
565
- *Xavier Noria*
566
-
567
- * The payload of `transaction.active_record` Active Support notifications now has the transaction the event is related to in the `:transaction` key.
568
-
569
- *Xavier Noria*
570
-
571
- * Define `ActiveRecord::Transaction#uuid`, which returns a UUID for the database transaction. This may be helpful when tracing database activity. These UUIDs are generated only on demand.
572
-
573
- *Xavier Noria*
574
-
575
- * Fix inference of association model on nested models with the same demodularized name.
576
-
577
- E.g. with the following setup:
795
+ * Support batching using custom columns.
578
796
 
579
797
  ```ruby
580
- class Nested::Post < ApplicationRecord
581
- has_one :post, through: :other
798
+ Product.in_batches(cursor: [:shop_id, :id]) do |relation|
799
+ # do something with relation
582
800
  end
583
801
  ```
584
802
 
585
- Before, `#post` would infer the model as `Nested::Post`, but now it correctly infers `Post`.
586
-
587
- *Joshua Young*
588
-
589
- * PostgreSQL `Cidr#change?` detects the address prefix change.
590
-
591
- *Taketo Takashima*
592
-
593
- * Change `BatchEnumerator#destroy_all` to return the total number of affected rows.
594
-
595
- Previously, it always returned `nil`.
596
-
597
803
  *fatkodima*
598
804
 
599
- * Support `touch_all` in batches.
600
-
601
- ```ruby
602
- Post.in_batches.touch_all
603
- ```
604
-
605
- *fatkodima*
606
-
607
- * Add support for `:if_not_exists` and `:force` options to `create_schema`.
608
-
609
- *fatkodima*
610
-
611
- * Fix `index_errors` having incorrect index in association validation errors.
612
-
613
- *lulalala*
614
-
615
- * Add `index_errors: :nested_attributes_order` mode.
616
-
617
- This indexes the association validation errors based on the order received by nested attributes setter, and respects the `reject_if` configuration. This enables API to provide enough information to the frontend to map the validation errors back to their respective form fields.
618
-
619
- *lulalala*
620
-
621
- * Add `Rails.application.config.active_record.postgresql_adapter_decode_dates` to opt out of decoding dates automatically with the postgresql adapter. Defaults to true.
622
-
623
- *Joé Dupuis*
624
-
625
- * Association option `query_constraints` is deprecated in favor of `foreign_key`.
805
+ * Use SQLite `IMMEDIATE` transactions when possible.
626
806
 
627
- *Nikita Vasilevsky*
628
-
629
- * Add `ENV["SKIP_TEST_DATABASE_TRUNCATE"]` flag to speed up multi-process test runs on large DBs when all tests run within default transaction.
630
-
631
- This cuts ~10s from the test run of HEY when run by 24 processes against the 178 tables, since ~4,000 table truncates can then be skipped.
632
-
633
- *DHH*
634
-
635
- * Added support for recursive common table expressions.
636
-
637
- ```ruby
638
- Post.with_recursive(
639
- post_and_replies: [
640
- Post.where(id: 42),
641
- Post.joins('JOIN post_and_replies ON posts.in_reply_to_id = post_and_replies.id'),
642
- ]
643
- )
644
- ```
645
-
646
- Generates the following SQL:
647
-
648
- ```sql
649
- WITH RECURSIVE "post_and_replies" AS (
650
- (SELECT "posts".* FROM "posts" WHERE "posts"."id" = 42)
651
- UNION ALL
652
- (SELECT "posts".* FROM "posts" JOIN post_and_replies ON posts.in_reply_to_id = post_and_replies.id)
653
- )
654
- SELECT "posts".* FROM "posts"
655
- ```
656
-
657
- *ClearlyClaire*
658
-
659
- * `validate_constraint` can be called in a `change_table` block.
660
-
661
- ex:
662
- ```ruby
663
- change_table :products do |t|
664
- t.check_constraint "price > discounted_price", name: "price_check", validate: false
665
- t.validate_check_constraint "price_check"
666
- end
667
- ```
668
-
669
- *Cody Cutrer*
670
-
671
- * `PostgreSQLAdapter` now decodes columns of type date to `Date` instead of string.
672
-
673
- Ex:
674
- ```ruby
675
- ActiveRecord::Base.connection
676
- .select_value("select '2024-01-01'::date").class #=> Date
677
- ```
678
-
679
- *Joé Dupuis*
680
-
681
- * Strict loading using `:n_plus_one_only` does not eagerly load child associations.
682
-
683
- With this change, child associations are no longer eagerly loaded, to
684
- match intended behavior and to prevent non-deterministic order issues caused
685
- by calling methods like `first` or `last`. As `first` and `last` don't cause
686
- an N+1 by themselves, calling child associations will no longer raise.
687
- Fixes #49473.
807
+ Transactions run against the SQLite3 adapter default to IMMEDIATE mode to improve concurrency support and avoid busy exceptions.
688
808
 
689
- Before:
690
-
691
- ```ruby
692
- person = Person.find(1)
693
- person.strict_loading!(mode: :n_plus_one_only)
694
- person.posts.first
695
- # SELECT * FROM posts WHERE person_id = 1; -- non-deterministic order
696
- person.posts.first.firm # raises ActiveRecord::StrictLoadingViolationError
697
- ```
698
-
699
- After:
700
-
701
- ```ruby
702
- person = Person.find(1)
703
- person.strict_loading!(mode: :n_plus_one_only)
704
- person.posts.first # this is 1+1, not N+1
705
- # SELECT * FROM posts WHERE person_id = 1 ORDER BY id LIMIT 1;
706
- person.posts.first.firm # no longer raises
707
- ```
809
+ *Stephen Margheim*
708
810
 
709
- *Reid Lynch*
811
+ * Raise specific exception when a connection is not defined.
710
812
 
711
- * Allow `Sqlite3Adapter` to use `sqlite3` gem version `2.x`.
813
+ The new `ConnectionNotDefined` exception provides connection name, shard and role accessors indicating the details of the connection that was requested.
712
814
 
713
- *Mike Dalessio*
815
+ *Hana Harencarova*, *Matthew Draper*
714
816
 
715
- * Allow `ActiveRecord::Base#pluck` to accept hash values.
817
+ * Delete the deprecated constant `ActiveRecord::ImmutableRelation`.
716
818
 
717
- ```ruby
718
- # Before
719
- Post.joins(:comments).pluck("posts.id", "comments.id", "comments.body")
720
-
721
- # After
722
- Post.joins(:comments).pluck(posts: [:id], comments: [:id, :body])
723
- ```
819
+ *Xavier Noria*
724
820
 
725
- *fatkodima*
821
+ * Fix duplicate callback execution when child autosaves parent with `has_one` and `belongs_to`.
726
822
 
727
- * Raise an `ActiveRecord::ActiveRecordError` error when the MySQL database returns an invalid version string.
823
+ Before, persisting a new child record with a new associated parent record would run `before_validation`,
824
+ `after_validation`, `before_save` and `after_save` callbacks twice.
728
825
 
729
- *Kevin McPhillips*
826
+ Now, these callbacks are only executed once as expected.
730
827
 
731
- * `ActiveRecord::Base.transaction` now yields an `ActiveRecord::Transaction` object.
828
+ *Joshua Young*
732
829
 
733
- This allows to register callbacks on it.
830
+ * `ActiveRecord::Encryption::Encryptor` now supports a `:compressor` option to customize the compression algorithm used.
734
831
 
735
832
  ```ruby
736
- Article.transaction do |transaction|
737
- article.update(published: true)
738
- transaction.after_commit do
739
- PublishNotificationMailer.with(article: article).deliver_later
833
+ module ZstdCompressor
834
+ def self.deflate(data)
835
+ Zstd.compress(data)
740
836
  end
741
- end
742
- ```
743
-
744
- *Jean Boussier*
745
-
746
- * Add `ActiveRecord::Base.current_transaction`.
747
-
748
- Returns the current transaction, to allow registering callbacks on it.
749
-
750
- ```ruby
751
- Article.current_transaction.after_commit do
752
- PublishNotificationMailer.with(article: article).deliver_later
753
- end
754
- ```
755
837
 
756
- *Jean Boussier*
757
-
758
- * Add `ActiveRecord.after_all_transactions_commit` callback.
759
-
760
- Useful for code that may run either inside or outside a transaction and needs
761
- to perform work after the state changes have been properly persisted.
762
-
763
- ```ruby
764
- def publish_article(article)
765
- article.update(published: true)
766
- ActiveRecord.after_all_transactions_commit do
767
- PublishNotificationMailer.with(article: article).deliver_later
838
+ def self.inflate(data)
839
+ Zstd.decompress(data)
768
840
  end
769
841
  end
770
- ```
771
-
772
- In the above example, the block is either executed immediately if called outside
773
- of a transaction, or called after the open transaction is committed.
774
842
 
775
- If the transaction is rolled back, the block isn't called.
776
-
777
- *Jean Boussier*
778
-
779
- * Add the ability to ignore counter cache columns until they are backfilled.
780
-
781
- Starting to use counter caches on existing large tables can be troublesome, because the column
782
- values must be backfilled separately of the column addition (to not lock the table for too long)
783
- and before the use of `:counter_cache` (otherwise methods like `size`/`any?`/etc, which use
784
- counter caches internally, can produce incorrect results). People usually use database triggers
785
- or callbacks on child associations while backfilling before introducing a counter cache
786
- configuration to the association.
787
-
788
- Now, to safely backfill the column, while keeping the column updated with child records added/removed, use:
789
-
790
- ```ruby
791
- class Comment < ApplicationRecord
792
- belongs_to :post, counter_cache: { active: false }
843
+ class User
844
+ encrypts :name, compressor: ZstdCompressor
793
845
  end
794
846
  ```
795
847
 
796
- While the counter cache is not "active", the methods like `size`/`any?`/etc will not use it,
797
- but get the results directly from the database. After the counter cache column is backfilled, simply
798
- remove the `{ active: false }` part from the counter cache definition, and it will now be used by the
799
- mentioned methods.
800
-
801
- *fatkodima*
802
-
803
- * Retry known idempotent SELECT queries on connection-related exceptions.
804
-
805
- SELECT queries we construct by walking the Arel tree and / or with known model attributes
806
- are idempotent and can safely be retried in the case of a connection error. Previously,
807
- adapters such as `TrilogyAdapter` would raise `ActiveRecord::ConnectionFailed: Trilogy::EOFError`
808
- when encountering a connection error mid-request.
809
-
810
- *Adrianna Chang*
811
-
812
- * Allow association's `foreign_key` to be composite.
813
-
814
- `query_constraints` option was the only way to configure a composite foreign key by passing an `Array`.
815
- Now it's possible to pass an Array value as `foreign_key` to achieve the same behavior of an association.
816
-
817
- *Nikita Vasilevsky*
818
-
819
- * Allow association's `primary_key` to be composite.
820
-
821
- Association's `primary_key` can be composite when derived from associated model `primary_key` or `query_constraints`.
822
- Now it's possible to explicitly set it as composite on the association.
823
-
824
- *Nikita Vasilevsky*
825
-
826
- * Add `config.active_record.permanent_connection_checkout` setting.
827
-
828
- Controls whether `ActiveRecord::Base.connection` raises an error, emits a deprecation warning, or neither.
829
-
830
- `ActiveRecord::Base.connection` checkouts a database connection from the pool and keeps it leased until the end of
831
- the request or job. This behavior can be undesirable in environments that use many more threads or fibers than there
832
- is available connections.
833
-
834
- This configuration can be used to track down and eliminate code that calls `ActiveRecord::Base.connection` and
835
- migrate it to use `ActiveRecord::Base.with_connection` instead.
836
-
837
- The default behavior remains unchanged, and there is currently no plans to change the default.
838
-
839
- *Jean Boussier*
840
-
841
- * Add dirties option to uncached.
842
-
843
- This adds a `dirties` option to `ActiveRecord::Base.uncached` and
844
- `ActiveRecord::ConnectionAdapters::ConnectionPool#uncached`.
845
-
846
- When set to `true` (the default), writes will clear all query caches belonging to the current thread.
847
- When set to `false`, writes to the affected connection pool will not clear any query cache.
848
-
849
- This is needed by Solid Cache so that cache writes do not clear query caches.
850
-
851
- *Donal McBreen*
852
-
853
- * Deprecate `ActiveRecord::Base.connection` in favor of `.lease_connection`.
854
-
855
- The method has been renamed as `lease_connection` to better reflect that the returned
856
- connection will be held for the duration of the request or job.
857
-
858
- This deprecation is a soft deprecation, no warnings will be issued and there is no
859
- current plan to remove the method.
860
-
861
- *Jean Boussier*
862
-
863
- * Deprecate `ActiveRecord::ConnectionAdapters::ConnectionPool#connection`.
864
-
865
- The method has been renamed as `lease_connection` to better reflect that the returned
866
- connection will be held for the duration of the request or job.
867
-
868
- *Jean Boussier*
869
-
870
- * Expose a generic fixture accessor for fixture names that may conflict with Minitest.
848
+ You disable compression by passing `compress: false`.
871
849
 
872
850
  ```ruby
873
- assert_equal "Ruby on Rails", web_sites(:rubyonrails).name
874
- assert_equal "Ruby on Rails", fixture(:web_sites, :rubyonrails).name
875
- ```
876
-
877
- *Jean Boussier*
878
-
879
- * Using `Model.query_constraints` with a single non-primary-key column used to raise as expected, but with an
880
- incorrect error message.
881
-
882
- This has been fixed to raise with a more appropriate error message.
883
-
884
- *Joshua Young*
885
-
886
- * Fix `has_one` association autosave setting the foreign key attribute when it is unchanged.
887
-
888
- This behavior is also inconsistent with autosaving `belongs_to` and can have unintended side effects like raising
889
- an `ActiveRecord::ReadonlyAttributeError` when the foreign key attribute is marked as read-only.
890
-
891
- *Joshua Young*
892
-
893
- * Remove deprecated behavior that would rollback a transaction block when exited using `return`, `break` or `throw`.
894
-
895
- *Rafael Mendonça França*
896
-
897
- * Deprecate `Rails.application.config.active_record.commit_transaction_on_non_local_return`.
898
-
899
- *Rafael Mendonça França*
900
-
901
- * Remove deprecated support to pass `rewhere` to `ActiveRecord::Relation#merge`.
902
-
903
- *Rafael Mendonça França*
904
-
905
- * Remove deprecated support to pass `deferrable: true` to `add_foreign_key`.
906
-
907
- *Rafael Mendonça França*
908
-
909
- * Remove deprecated support to quote `ActiveSupport::Duration`.
910
-
911
- *Rafael Mendonça França*
912
-
913
- * Remove deprecated `#quote_bound_value`.
914
-
915
- *Rafael Mendonça França*
916
-
917
- * Remove deprecated `ActiveRecord::ConnectionAdapters::ConnectionPool#connection_klass`.
918
-
919
- *Rafael Mendonça França*
920
-
921
- * Remove deprecated support to apply `#connection_pool_list`, `#active_connections?`, `#clear_active_connections!`,
922
- `#clear_reloadable_connections!`, `#clear_all_connections!` and `#flush_idle_connections!` to the connections pools
923
- for the current role when the `role` argument isn't provided.
924
-
925
- *Rafael Mendonça França*
926
-
927
- * Remove deprecated `#all_connection_pools`.
928
-
929
- *Rafael Mendonça França*
930
-
931
- * Remove deprecated `ActiveRecord::ConnectionAdapters::SchemaCache#data_sources`.
932
-
933
- *Rafael Mendonça França*
934
-
935
- * Remove deprecated `ActiveRecord::ConnectionAdapters::SchemaCache.load_from`.
936
-
937
- *Rafael Mendonça França*
938
-
939
- * Remove deprecated `#all_foreign_keys_valid?` from database adapters.
940
-
941
- *Rafael Mendonça França*
942
-
943
- * Remove deprecated support to passing coder and class as second argument to `serialize`.
944
-
945
- *Rafael Mendonça França*
946
-
947
- * Remove deprecated support to `ActiveRecord::Base#read_attribute(:id)` to return the custom primary key value.
948
-
949
- *Rafael Mendonça França*
950
-
951
- * Remove deprecated `TestFixtures.fixture_path`.
952
-
953
- *Rafael Mendonça França*
954
-
955
- * Remove deprecated behavior to support referring to a singular association by its plural name.
956
-
957
- *Rafael Mendonça França*
958
-
959
- * Deprecate `Rails.application.config.active_record.allow_deprecated_singular_associations_name`.
960
-
961
- *Rafael Mendonça França*
962
-
963
- * Remove deprecated support to passing `SchemaMigration` and `InternalMetadata` classes as arguments to
964
- `ActiveRecord::MigrationContext`.
965
-
966
- *Rafael Mendonça França*
967
-
968
- * Remove deprecated `ActiveRecord::Migration.check_pending!` method.
969
-
970
- *Rafael Mendonça França*
971
-
972
- * Remove deprecated `ActiveRecord::LogSubscriber.runtime` method.
973
-
974
- *Rafael Mendonça França*
975
-
976
- * Remove deprecated `ActiveRecord::LogSubscriber.runtime=` method.
977
-
978
- *Rafael Mendonça França*
979
-
980
- * Remove deprecated `ActiveRecord::LogSubscriber.reset_runtime` method.
981
-
982
- *Rafael Mendonça França*
983
-
984
- * Remove deprecated support to define `explain` in the connection adapter with 2 arguments.
985
-
986
- *Rafael Mendonça França*
987
-
988
- * Remove deprecated `ActiveRecord::ActiveJobRequiredError`.
989
-
990
- *Rafael Mendonça França*
991
-
992
- * Remove deprecated `ActiveRecord::Base.clear_active_connections!`.
993
-
994
- *Rafael Mendonça França*
995
-
996
- * Remove deprecated `ActiveRecord::Base.clear_reloadable_connections!`.
997
-
998
- *Rafael Mendonça França*
999
-
1000
- * Remove deprecated `ActiveRecord::Base.clear_all_connections!`.
1001
-
1002
- *Rafael Mendonça França*
1003
-
1004
- * Remove deprecated `ActiveRecord::Base.flush_idle_connections!`.
1005
-
1006
- *Rafael Mendonça França*
1007
-
1008
- * Remove deprecated `name` argument from `ActiveRecord::Base.remove_connection`.
1009
-
1010
- *Rafael Mendonça França*
1011
-
1012
- * Remove deprecated support to call `alias_attribute` with non-existent attribute names.
1013
-
1014
- *Rafael Mendonça França*
1015
-
1016
- * Remove deprecated `Rails.application.config.active_record.suppress_multiple_database_warning`.
1017
-
1018
- *Rafael Mendonça França*
1019
-
1020
- * Add `ActiveRecord::Encryption::MessagePackMessageSerializer`.
1021
-
1022
- Serialize data to the MessagePack format, for efficient storage in binary columns.
1023
-
1024
- The binary encoding requires around 30% less space than the base64 encoding
1025
- used by the default serializer.
1026
-
1027
- *Donal McBreen*
1028
-
1029
- * Add support for encrypting binary columns.
1030
-
1031
- Ensure encryption and decryption pass `Type::Binary::Data` around for binary data.
1032
-
1033
- Previously encrypting binary columns with the `ActiveRecord::Encryption::MessageSerializer`
1034
- incidentally worked for MySQL and SQLite, but not PostgreSQL.
1035
-
1036
- *Donal McBreen*
1037
-
1038
- * Deprecated `ENV["SCHEMA_CACHE"]` in favor of `schema_cache_path` in the database configuration.
1039
-
1040
- *Rafael Mendonça França*
1041
-
1042
- * Add `ActiveRecord::Base.with_connection` as a shortcut for leasing a connection for a short duration.
1043
-
1044
- The leased connection is yielded, and for the duration of the block, any call to `ActiveRecord::Base.connection`
1045
- will yield that same connection.
1046
-
1047
- This is useful to perform a few database operations without causing a connection to be leased for the
1048
- entire duration of the request or job.
1049
-
1050
- *Jean Boussier*
1051
-
1052
- * Deprecate `config.active_record.warn_on_records_fetched_greater_than` now that `sql.active_record`
1053
- notification includes `:row_count` field.
1054
-
1055
- *Jason Nochlin*
1056
-
1057
- * Fix an issue with `where.associated` losing the current join type scope.
1058
-
1059
- Example:
1060
-
1061
- ```ruby
1062
- Post.left_joins(:author).where.associated(:author)
1063
- ```
1064
-
1065
- Previously, the `LEFT OUTER JOIN` would be lost and converted to an `INNER JOIN`.
1066
-
1067
- *Saleh Alhaddad*
1068
-
1069
- * Fix an issue where `ActiveRecord::Encryption` configurations are not ready before the loading
1070
- of Active Record models, when an application is eager loaded. As a result, encrypted attributes
1071
- could be misconfigured in some cases.
1072
-
1073
- *Maxime Réty*
1074
-
1075
- * Deprecate defining an `enum` with keyword arguments.
1076
-
1077
- ```ruby
1078
- class Function > ApplicationRecord
1079
- # BAD
1080
- enum color: [:red, :blue],
1081
- type: [:instance, :class]
1082
-
1083
- # GOOD
1084
- enum :color, [:red, :blue]
1085
- enum :type, [:instance, :class]
851
+ class User
852
+ encrypts :name, compress: false
1086
853
  end
1087
854
  ```
1088
855
 
1089
- *Hartley McGuire*
1090
-
1091
- * Add `config.active_record.validate_migration_timestamps` option for validating migration timestamps.
1092
-
1093
- When set, validates that the timestamp prefix for a migration is no more than a day ahead of
1094
- the timestamp associated with the current time. This is designed to prevent migrations prefixes
1095
- from being hand-edited to future timestamps, which impacts migration generation and other
1096
- migration commands.
1097
-
1098
- *Adrianna Chang*
1099
-
1100
- * Properly synchronize `Mysql2Adapter#active?` and `TrilogyAdapter#active?`.
1101
-
1102
- As well as `disconnect!` and `verify!`.
1103
-
1104
- This generally isn't a big problem as connections must not be shared between
1105
- threads, but is required when running transactional tests or system tests
1106
- and could lead to a SEGV.
1107
-
1108
- *Jean Boussier*
1109
-
1110
- * Support `:source_location` tag option for query log tags.
1111
-
1112
- ```ruby
1113
- config.active_record.query_log_tags << :source_location
1114
- ```
1115
-
1116
- Calculating the caller location is a costly operation and should be used primarily in development
1117
- (note, there is also a `config.active_record.verbose_query_logs` that serves the same purpose)
1118
- or occasionally on production for debugging purposes.
1119
-
1120
- *fatkodima*
1121
-
1122
- * Add an option to `ActiveRecord::Encryption::Encryptor` to disable compression.
1123
-
1124
- Allow compression to be disabled by setting `compress: false`
1125
-
1126
- ```ruby
1127
- class User
1128
- encrypts :name, encryptor: ActiveRecord::Encryption::Encryptor.new(compress: false)
1129
- end
1130
- ```
1131
-
1132
- *Donal McBreen*
1133
-
1134
- * Deprecate passing strings to `ActiveRecord::Tasks::DatabaseTasks.cache_dump_filename`.
1135
-
1136
- A `ActiveRecord::DatabaseConfigurations::DatabaseConfig` object should be passed instead.
1137
-
1138
- *Rafael Mendonça França*
1139
-
1140
- * Add `row_count` field to `sql.active_record` notification.
1141
-
1142
- This field returns the amount of rows returned by the query that emitted the notification.
1143
-
1144
- This metric is useful in cases where one wants to detect queries with big result sets.
1145
-
1146
- *Marvin Bitterlich*
1147
-
1148
- * Consistently raise an `ArgumentError` when passing an invalid argument to a nested attributes association writer.
1149
-
1150
- Previously, this would only raise on collection associations and produce a generic error on singular associations.
1151
-
1152
- Now, it will raise on both collection and singular associations.
1153
-
1154
- *Joshua Young*
1155
-
1156
- * Fix single quote escapes on default generated MySQL columns.
1157
-
1158
- MySQL 5.7.5+ supports generated columns, which can be used to create a column that is computed from an expression.
1159
-
1160
- Previously, the schema dump would output a string with double escapes for generated columns with single quotes in the default expression.
1161
-
1162
- This would result in issues when importing the schema on a fresh instance of a MySQL database.
856
+ *heka1024*
1163
857
 
1164
- Now, the string will not be escaped and will be valid Ruby upon importing of the schema.
1165
-
1166
- *Yash Kapadia*
1167
-
1168
- * Fix Migrations with versions older than 7.1 validating options given to
1169
- `add_reference` and `t.references`.
858
+ * Add condensed `#inspect` for `ConnectionPool`, `AbstractAdapter`, and
859
+ `DatabaseConfig`.
1170
860
 
1171
861
  *Hartley McGuire*
1172
862
 
1173
- * Add `<role>_types` class method to `ActiveRecord::DelegatedType` so that the delegated types can be introspected.
1174
-
1175
- *JP Rosevear*
1176
-
1177
- * Make `schema_dump`, `query_cache`, `replica` and `database_tasks` configurable via `DATABASE_URL`.
1178
-
1179
- This wouldn't always work previously because boolean values would be interpreted as strings.
1180
-
1181
- e.g. `DATABASE_URL=postgres://localhost/foo?schema_dump=false` now properly disable dumping the schema
1182
- cache.
1183
-
1184
- *Mike Coutermarsh*, *Jean Boussier*
1185
-
1186
- * Introduce `ActiveRecord::Transactions::ClassMethods#set_callback`.
1187
-
1188
- It is identical to `ActiveSupport::Callbacks::ClassMethods#set_callback`
1189
- but with support for `after_commit` and `after_rollback` callback options.
1190
-
1191
- *Joshua Young*
1192
-
1193
- * Make `ActiveRecord::Encryption::Encryptor` agnostic of the serialization format used for encrypted data.
1194
-
1195
- Previously, the encryptor instance only allowed an encrypted value serialized as a `String` to be passed to the message serializer.
1196
-
1197
- Now, the encryptor lets the configured `message_serializer` decide which types of serialized encrypted values are supported. A custom serialiser is therefore allowed to serialize `ActiveRecord::Encryption::Message` objects using a type other than `String`.
1198
-
1199
- The default `ActiveRecord::Encryption::MessageSerializer` already ensures that only `String` objects are passed for deserialization.
1200
-
1201
- *Maxime Réty*
1202
-
1203
- * Fix `encrypted_attribute?` to take into account context properties passed to `encrypts`.
1204
-
1205
- *Maxime Réty*
1206
-
1207
- * The object returned by `explain` now responds to `pluck`, `first`,
1208
- `last`, `average`, `count`, `maximum`, `minimum`, and `sum`. Those
1209
- new methods run `EXPLAIN` on the corresponding queries:
863
+ * Add `.shard_keys`, `.sharded?`, & `.connected_to_all_shards` methods.
1210
864
 
1211
865
  ```ruby
1212
- User.all.explain.count
1213
- # EXPLAIN SELECT COUNT(*) FROM `users`
1214
- # ...
1215
-
1216
- User.all.explain.maximum(:id)
1217
- # EXPLAIN SELECT MAX(`users`.`id`) FROM `users`
1218
- # ...
1219
- ```
1220
-
1221
- *Petrik de Heus*
1222
-
1223
- * Fixes an issue where `validates_associated` `:on` option wasn't respected
1224
- when validating associated records.
866
+ class ShardedBase < ActiveRecord::Base
867
+ self.abstract_class = true
1225
868
 
1226
- *Austen Madden*, *Alex Ghiculescu*, *Rafał Brize*
1227
-
1228
- * Allow overriding SQLite defaults from `database.yml`.
1229
-
1230
- Any PRAGMA configuration set under the `pragmas` key in the configuration
1231
- file takes precedence over Rails' defaults, and additional PRAGMAs can be
1232
- set as well.
1233
-
1234
- ```yaml
1235
- database: storage/development.sqlite3
1236
- timeout: 5000
1237
- pragmas:
1238
- journal_mode: off
1239
- temp_store: memory
1240
- ```
1241
-
1242
- *Stephen Margheim*
1243
-
1244
- * Remove warning message when running SQLite in production, but leave it unconfigured.
1245
-
1246
- There are valid use cases for running SQLite in production. However, it must be done
1247
- with care, so instead of a warning most users won't see anyway, it's preferable to
1248
- leave the configuration commented out to force them to think about having the database
1249
- on a persistent volume etc.
1250
-
1251
- *Jacopo Beschi*, *Jean Boussier*
1252
-
1253
- * Add support for generated columns to the SQLite3 adapter.
1254
-
1255
- Generated columns (both stored and dynamic) are supported since version 3.31.0 of SQLite.
1256
- This adds support for those to the SQLite3 adapter.
1257
-
1258
- ```ruby
1259
- create_table :users do |t|
1260
- t.string :name
1261
- t.virtual :name_upper, type: :string, as: 'UPPER(name)'
1262
- t.virtual :name_lower, type: :string, as: 'LOWER(name)', stored: true
869
+ connects_to shards: {
870
+ shard_one: { writing: :shard_one },
871
+ shard_two: { writing: :shard_two }
872
+ }
1263
873
  end
1264
- ```
1265
-
1266
- *Stephen Margheim*
1267
-
1268
- * TrilogyAdapter: ignore `host` if `socket` parameter is set.
1269
-
1270
- This allows to configure a connection on a UNIX socket via `DATABASE_URL`:
1271
-
1272
- ```
1273
- DATABASE_URL=trilogy://does-not-matter/my_db_production?socket=/var/run/mysql.sock
1274
- ```
1275
-
1276
- *Jean Boussier*
1277
-
1278
- * Make `assert_queries_count`, `assert_no_queries`, `assert_queries_match`, and
1279
- `assert_no_queries_match` assertions public.
1280
874
 
1281
- To assert the expected number of queries are made, Rails internally uses `assert_queries_count` and
1282
- `assert_no_queries`. To assert that specific SQL queries are made, `assert_queries_match` and
1283
- `assert_no_queries_match` are used. These assertions can now be used in applications as well.
1284
-
1285
- ```ruby
1286
- class ArticleTest < ActiveSupport::TestCase
1287
- test "queries are made" do
1288
- assert_queries_count(1) { Article.first }
1289
- end
1290
-
1291
- test "creates a foreign key" do
1292
- assert_queries_match(/ADD FOREIGN KEY/i, include_schema: true) do
1293
- @connection.add_foreign_key(:comments, :posts)
1294
- end
1295
- end
875
+ class ShardedModel < ShardedBase
1296
876
  end
1297
- ```
1298
-
1299
- *Petrik de Heus*, *fatkodima*
1300
-
1301
- * Fix `has_secure_token` calls the setter method on initialize.
1302
-
1303
- *Abeid Ahmed*
1304
-
1305
- * When using a `DATABASE_URL`, allow for a configuration to map the protocol in the URL to a specific database
1306
- adapter. This allows decoupling the adapter the application chooses to use from the database connection details
1307
- set in the deployment environment.
1308
877
 
1309
- ```ruby
1310
- # ENV['DATABASE_URL'] = "mysql://localhost/example_database"
1311
- config.active_record.protocol_adapters.mysql = "trilogy"
1312
- # will connect to MySQL using the trilogy adapter
878
+ ShardedModel.shard_keys => [:shard_one, :shard_two]
879
+ ShardedModel.sharded? => true
880
+ ShardedBase.connected_to_all_shards { ShardedModel.current_shard } => [:shard_one, :shard_two]
1313
881
  ```
1314
882
 
1315
- *Jean Boussier*, *Kevin McPhillips*
1316
-
1317
- * In cases where MySQL returns `warning_count` greater than zero, but returns no warnings when
1318
- the `SHOW WARNINGS` query is executed, `ActiveRecord.db_warnings_action` proc will still be
1319
- called with a generic warning message rather than silently ignoring the warning(s).
1320
-
1321
- *Kevin McPhillips*
1322
-
1323
- * `DatabaseConfigurations#configs_for` accepts a symbol in the `name` parameter.
1324
-
1325
- *Andrew Novoselac*
1326
-
1327
- * Fix `where(field: values)` queries when `field` is a serialized attribute
1328
- (for example, when `field` uses `ActiveRecord::Base.serialize` or is a JSON
1329
- column).
883
+ *Nony Dutton*
1330
884
 
1331
- *João Alves*
885
+ * Add a `filter` option to `in_order_of` to prioritize certain values in the sorting without filtering the results
886
+ by these values.
1332
887
 
1333
- * Make the output of `ActiveRecord::Core#inspect` configurable.
888
+ *Igor Depolli*
1334
889
 
1335
- By default, calling `inspect` on a record will yield a formatted string including just the `id`.
1336
-
1337
- ```ruby
1338
- Post.first.inspect #=> "#<Post id: 1>"
1339
- ```
1340
-
1341
- The attributes to be included in the output of `inspect` can be configured with
1342
- `ActiveRecord::Core#attributes_for_inspect`.
1343
-
1344
- ```ruby
1345
- Post.attributes_for_inspect = [:id, :title]
1346
- Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!">"
1347
- ```
890
+ * Fix an issue where the IDs reader method did not return expected results
891
+ for preloaded associations in models using composite primary keys.
1348
892
 
1349
- With `attributes_for_inspect` set to `:all`, `inspect` will list all the record's attributes.
893
+ *Jay Ang*
1350
894
 
1351
- ```ruby
1352
- Post.attributes_for_inspect = :all
1353
- Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!", published_at: "2023-10-23 14:28:11 +0000">"
1354
- ```
895
+ * Allow to configure `strict_loading_mode` globally or within a model.
1355
896
 
1356
- In `development` and `test` mode, `attributes_for_inspect` will be set to `:all` by default.
897
+ Defaults to `:all`, can be changed to `:n_plus_one_only`.
1357
898
 
1358
- You can also call `full_inspect` to get an inspection with all the attributes.
899
+ *Garen Torikian*
1359
900
 
1360
- The attributes in `attribute_for_inspect` will also be used for `pretty_print`.
901
+ * Add `ActiveRecord::Relation#readonly?`.
1361
902
 
1362
- *Andrew Novoselac*
903
+ Reflects if the relation has been marked as readonly.
1363
904
 
1364
- * Don't mark attributes as changed when reassigned to `Float::INFINITY` or
1365
- `-Float::INFINITY`.
905
+ *Theodor Tonum*
1366
906
 
1367
- *Maicol Bentancor*
907
+ * Improve `ActiveRecord::Store` to raise a descriptive exception if the column is not either
908
+ structured (e.g., PostgreSQL +hstore+/+json+, or MySQL +json+) or declared serializable via
909
+ `ActiveRecord.store`.
1368
910
 
1369
- * Support the `RETURNING` clause for MariaDB.
911
+ Previously, a `NoMethodError` would be raised when the accessor was read or written:
1370
912
 
1371
- *fatkodima*, *Nikolay Kondratyev*
913
+ NoMethodError: undefined method `accessor' for an instance of ActiveRecord::Type::Text
1372
914
 
1373
- * The SQLite3 adapter now implements the `supports_deferrable_constraints?` contract.
915
+ Now, a descriptive `ConfigurationError` is raised:
1374
916
 
1375
- Allows foreign keys to be deferred by adding the `:deferrable` key to the `foreign_key` options.
917
+ ActiveRecord::ConfigurationError: the column 'metadata' has not been configured as a store.
918
+ Please make sure the column is declared serializable via 'ActiveRecord.store' or, if your
919
+ database supports it, use a structured column type like hstore or json.
1376
920
 
1377
- ```ruby
1378
- add_reference :person, :alias, foreign_key: { deferrable: :deferred }
1379
- add_reference :alias, :person, foreign_key: { deferrable: :deferred }
1380
- ```
921
+ *Mike Dalessio*
1381
922
 
1382
- *Stephen Margheim*
923
+ * Fix inference of association model on nested models with the same demodularized name.
1383
924
 
1384
- * Add the `set_constraints` helper to PostgreSQL connections.
925
+ E.g. with the following setup:
1385
926
 
1386
927
  ```ruby
1387
- Post.create!(user_id: -1) # => ActiveRecord::InvalidForeignKey
1388
-
1389
- Post.transaction do
1390
- Post.connection.set_constraints(:deferred)
1391
- p = Post.create!(user_id: -1)
1392
- u = User.create!
1393
- p.user = u
1394
- p.save!
928
+ class Nested::Post < ApplicationRecord
929
+ has_one :post, through: :other
1395
930
  end
1396
931
  ```
1397
932
 
1398
- *Cody Cutrer*
1399
-
1400
- * Include `ActiveModel::API` in `ActiveRecord::Base`.
1401
-
1402
- *Sean Doyle*
1403
-
1404
- * Ensure `#signed_id` outputs `url_safe` strings.
1405
-
1406
- *Jason Meller*
933
+ Before, `#post` would infer the model as `Nested::Post`, but now it correctly infers `Post`.
1407
934
 
1408
- * Add `nulls_last` and working `desc.nulls_first` for MySQL.
935
+ *Joshua Young*
1409
936
 
1410
- *Tristan Fellows*
937
+ * Add public method for checking if a table is ignored by the schema cache.
1411
938
 
1412
- * Allow for more complex hash arguments for `order` which mimics `where` in `ActiveRecord::Relation`.
939
+ Previously, an application would need to reimplement `ignored_table?` from the schema cache class to check if a table was set to be ignored. This adds a public method to support this and updates the schema cache to use that directly.
1413
940
 
1414
941
  ```ruby
1415
- Topic.includes(:posts).order(posts: { created_at: :desc })
942
+ ActiveRecord.schema_cache_ignored_tables = ["developers"]
943
+ ActiveRecord.schema_cache_ignored_table?("developers")
944
+ => true
1416
945
  ```
1417
946
 
1418
- *Myles Boone*
947
+ *Eileen M. Uchitelle*
1419
948
 
1420
- Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/activerecord/CHANGELOG.md) for previous changes.
949
+ Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/activerecord/CHANGELOG.md) for previous changes.