activerecord 7.2.4 → 8.0.5.2

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