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