activerecord 7.2.0 → 8.0.0.beta1
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 +189 -745
- data/README.rdoc +1 -1
- data/lib/active_record/associations/association.rb +25 -5
- data/lib/active_record/associations/builder/association.rb +7 -6
- data/lib/active_record/associations/collection_association.rb +10 -8
- 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/join_association.rb +3 -2
- data/lib/active_record/associations/join_dependency.rb +5 -5
- data/lib/active_record/associations/preloader/association.rb +2 -2
- 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_assignment.rb +9 -1
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +4 -0
- data/lib/active_record/attributes.rb +6 -5
- data/lib/active_record/autosave_association.rb +69 -27
- data/lib/active_record/connection_adapters/abstract/connection_handler.rb +16 -10
- 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 +23 -44
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +90 -43
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +53 -18
- data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +26 -5
- data/lib/active_record/connection_adapters/abstract/transaction.rb +15 -5
- data/lib/active_record/connection_adapters/abstract_adapter.rb +24 -25
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +20 -38
- 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 +44 -46
- data/lib/active_record/connection_adapters/mysql2/database_statements.rb +42 -98
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +1 -8
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +64 -42
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +10 -0
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +50 -6
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +38 -90
- data/lib/active_record/connection_adapters/schema_cache.rb +1 -3
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +76 -100
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +0 -6
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +13 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +8 -1
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +55 -12
- 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_handling.rb +22 -0
- data/lib/active_record/core.rb +16 -9
- data/lib/active_record/database_configurations/connection_url_resolver.rb +1 -1
- data/lib/active_record/encryption/config.rb +3 -1
- data/lib/active_record/encryption/encryptable_record.rb +5 -5
- data/lib/active_record/encryption/encrypted_attribute_type.rb +12 -3
- data/lib/active_record/encryption/encryptor.rb +16 -9
- data/lib/active_record/encryption/extended_deterministic_queries.rb +4 -2
- data/lib/active_record/encryption/key_provider.rb +1 -1
- data/lib/active_record/encryption/scheme.rb +8 -1
- data/lib/active_record/encryption.rb +2 -0
- data/lib/active_record/enum.rb +8 -0
- data/lib/active_record/errors.rb +13 -5
- data/lib/active_record/fixtures.rb +0 -1
- data/lib/active_record/future_result.rb +14 -10
- data/lib/active_record/gem_version.rb +3 -3
- data/lib/active_record/insert_all.rb +1 -1
- data/lib/active_record/migration/command_recorder.rb +22 -5
- data/lib/active_record/migration/compatibility.rb +5 -2
- data/lib/active_record/migration.rb +35 -33
- data/lib/active_record/model_schema.rb +6 -3
- data/lib/active_record/nested_attributes.rb +11 -2
- data/lib/active_record/persistence.rb +128 -130
- data/lib/active_record/query_logs.rb +97 -39
- data/lib/active_record/query_logs_formatter.rb +17 -28
- data/lib/active_record/querying.rb +6 -6
- data/lib/active_record/railtie.rb +8 -14
- data/lib/active_record/reflection.rb +19 -10
- data/lib/active_record/relation/batches/batch_enumerator.rb +4 -3
- data/lib/active_record/relation/batches.rb +135 -75
- data/lib/active_record/relation/calculations.rb +24 -19
- 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/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 +6 -1
- data/lib/active_record/relation/query_methods.rb +58 -37
- data/lib/active_record/relation/record_fetch_warning.rb +2 -2
- data/lib/active_record/relation/spawn_methods.rb +1 -1
- data/lib/active_record/relation.rb +72 -61
- data/lib/active_record/result.rb +68 -7
- 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 +6 -2
- data/lib/active_record/statement_cache.rb +12 -12
- data/lib/active_record/store.rb +7 -3
- data/lib/active_record/tasks/database_tasks.rb +36 -16
- data/lib/active_record/tasks/mysql_database_tasks.rb +0 -2
- data/lib/active_record/tasks/sqlite_database_tasks.rb +2 -2
- data/lib/active_record/test_fixtures.rb +12 -0
- data/lib/active_record/token_for.rb +1 -1
- data/lib/active_record/validations/uniqueness.rb +9 -8
- data/lib/active_record.rb +15 -0
- data/lib/arel/collectors/bind.rb +1 -1
- metadata +14 -14
data/CHANGELOG.md
CHANGED
@@ -1,902 +1,346 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 8.0.0.beta1 (September 26, 2024) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Allow `drop_table` to accept an array of table names.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
* Fixes `validates_associated` raising an exception when configured with a
|
8
|
-
singular association and having `index_nested_attribute_errors` enabled.
|
9
|
-
|
10
|
-
*Martin Spickermann*
|
11
|
-
|
12
|
-
* The constant `ActiveRecord::ImmutableRelation` has been deprecated because
|
13
|
-
we want to reserve that name for a stronger sense of "immutable relation".
|
14
|
-
Please use `ActiveRecord::UnmodifiableRelation` instead.
|
15
|
-
|
16
|
-
*Xavier Noria*
|
17
|
-
|
18
|
-
* Add condensed `#inspect` for `ConnectionPool`, `AbstractAdapter`, and
|
19
|
-
`DatabaseConfig`.
|
20
|
-
|
21
|
-
*Hartley McGuire*
|
22
|
-
|
23
|
-
* Fixed a memory performance issue in Active Record attribute methods definition.
|
24
|
-
|
25
|
-
*Jean Boussier*
|
26
|
-
|
27
|
-
* Define the new Active Support notification event `start_transaction.active_record`.
|
28
|
-
|
29
|
-
This event is fired when database transactions or savepoints start, and
|
30
|
-
complements `transaction.active_record`, which is emitted when they finish.
|
31
|
-
|
32
|
-
The payload has the transaction (`:transaction`) and the connection (`:connection`).
|
33
|
-
|
34
|
-
*Xavier Noria*
|
35
|
-
|
36
|
-
* Fix an issue where the IDs reader method did not return expected results
|
37
|
-
for preloaded associations in models using composite primary keys.
|
38
|
-
|
39
|
-
*Jay Ang*
|
40
|
-
|
41
|
-
* The payload of `sql.active_record` Active Support notifications now has the current transaction in the `:transaction` key.
|
42
|
-
|
43
|
-
*Xavier Noria*
|
44
|
-
|
45
|
-
* The payload of `transaction.active_record` Active Support notifications now has the transaction the event is related to in the `:transaction` key.
|
46
|
-
|
47
|
-
*Xavier Noria*
|
48
|
-
|
49
|
-
* 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.
|
50
|
-
|
51
|
-
*Xavier Noria*
|
52
|
-
|
53
|
-
* Fix inference of association model on nested models with the same demodularized name.
|
54
|
-
|
55
|
-
E.g. with the following setup:
|
56
|
-
|
57
|
-
```ruby
|
58
|
-
class Nested::Post < ApplicationRecord
|
59
|
-
has_one :post, through: :other
|
60
|
-
end
|
61
|
-
```
|
62
|
-
|
63
|
-
Before, `#post` would infer the model as `Nested::Post`, but now it correctly infers `Post`.
|
64
|
-
|
65
|
-
*Joshua Young*
|
66
|
-
|
67
|
-
* PostgreSQL `Cidr#change?` detects the address prefix change.
|
68
|
-
|
69
|
-
*Taketo Takashima*
|
70
|
-
|
71
|
-
* Change `BatchEnumerator#destroy_all` to return the total number of affected rows.
|
72
|
-
|
73
|
-
Previously, it always returned `nil`.
|
74
|
-
|
75
|
-
*fatkodima*
|
76
|
-
|
77
|
-
* Support `touch_all` in batches.
|
5
|
+
This will let you to drop multiple tables in a single call.
|
78
6
|
|
79
7
|
```ruby
|
80
|
-
|
8
|
+
ActiveRecord::Base.lease_connection.drop_table(:users, :posts)
|
81
9
|
```
|
82
10
|
|
83
|
-
*
|
84
|
-
|
85
|
-
* Add support for `:if_not_exists` and `:force` options to `create_schema`.
|
86
|
-
|
87
|
-
*fatkodima*
|
88
|
-
|
89
|
-
* Fix `index_errors` having incorrect index in association validation errors.
|
90
|
-
|
91
|
-
*lulalala*
|
92
|
-
|
93
|
-
* Add `index_errors: :nested_attributes_order` mode.
|
11
|
+
*Gabriel Sobrinho*
|
94
12
|
|
95
|
-
|
13
|
+
* Add support for PostgreSQL `IF NOT EXISTS` via the `:if_not_exists` option
|
14
|
+
on the `add_enum_value` method.
|
96
15
|
|
97
|
-
*
|
16
|
+
*Ariel Rzezak*
|
98
17
|
|
99
|
-
*
|
18
|
+
* When running `db:migrate` on a fresh database, load the database schema before running migrations.
|
100
19
|
|
101
|
-
*
|
102
|
-
|
103
|
-
* Association option `query_constraints` is deprecated in favor of `foreign_key`.
|
20
|
+
*Andrew Novoselac*
|
104
21
|
|
105
|
-
|
22
|
+
* Fix an issue where `.left_outer_joins` used with multiple associations that have
|
23
|
+
the same child association but different parents does not join all parents.
|
106
24
|
|
107
|
-
|
25
|
+
Previously, using `.left_outer_joins` with the same child association would only join one of the parents.
|
108
26
|
|
109
|
-
|
27
|
+
Now it will correctly join both parents.
|
110
28
|
|
111
|
-
|
29
|
+
Fixes #41498.
|
112
30
|
|
113
|
-
*
|
31
|
+
*Garrett Blehm*
|
114
32
|
|
115
|
-
|
116
|
-
Post.with_recursive(
|
117
|
-
post_and_replies: [
|
118
|
-
Post.where(id: 42),
|
119
|
-
Post.joins('JOIN post_and_replies ON posts.in_reply_to_id = post_and_replies.id'),
|
120
|
-
]
|
121
|
-
)
|
122
|
-
```
|
33
|
+
* Deprecate `unsigned_float` and `unsigned_decimal` short-hand column methods.
|
123
34
|
|
124
|
-
|
35
|
+
As of MySQL 8.0.17, the UNSIGNED attribute is deprecated for columns of type FLOAT, DOUBLE,
|
36
|
+
and DECIMAL. Consider using a simple CHECK constraint instead for such columns.
|
125
37
|
|
126
|
-
|
127
|
-
WITH RECURSIVE "post_and_replies" AS (
|
128
|
-
(SELECT "posts".* FROM "posts" WHERE "posts"."id" = 42)
|
129
|
-
UNION ALL
|
130
|
-
(SELECT "posts".* FROM "posts" JOIN post_and_replies ON posts.in_reply_to_id = post_and_replies.id)
|
131
|
-
)
|
132
|
-
SELECT "posts".* FROM "posts"
|
133
|
-
```
|
38
|
+
https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
|
134
39
|
|
135
|
-
*
|
40
|
+
*Ryuta Kamizono*
|
136
41
|
|
137
|
-
*
|
42
|
+
* Drop MySQL 5.5 support.
|
138
43
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
t.check_constraint "price > discounted_price", name: "price_check", validate: false
|
143
|
-
t.validate_check_constraint "price_check"
|
144
|
-
end
|
145
|
-
```
|
44
|
+
MySQL 5.5 is the only version that does not support datetime with precision,
|
45
|
+
which we have supported in the core. Now we support MySQL 5.6.4 or later, which
|
46
|
+
is the first version to support datetime with precision.
|
146
47
|
|
147
|
-
*
|
48
|
+
*Ryuta Kamizono*
|
148
49
|
|
149
|
-
*
|
50
|
+
* Make Active Record asynchronous queries compatible with transactional fixtures.
|
150
51
|
|
151
|
-
|
152
|
-
|
153
|
-
ActiveRecord::Base.connection
|
154
|
-
.select_value("select '2024-01-01'::date").class #=> Date
|
155
|
-
```
|
52
|
+
Previously transactional fixtures would disable asynchronous queries, because transactional
|
53
|
+
fixtures impose all queries use the same connection.
|
156
54
|
|
157
|
-
|
55
|
+
Now asynchronous queries will use the connection pinned by transactional fixtures, and behave
|
56
|
+
much closer to production.
|
158
57
|
|
159
|
-
*
|
58
|
+
*Jean Boussier*
|
160
59
|
|
161
|
-
|
162
|
-
match intended behavior and to prevent non-deterministic order issues caused
|
163
|
-
by calling methods like `first` or `last`. As `first` and `last` don't cause
|
164
|
-
an N+1 by themselves, calling child associations will no longer raise.
|
165
|
-
Fixes #49473.
|
60
|
+
* Deserialize binary data before decrypting
|
166
61
|
|
167
|
-
|
62
|
+
This ensures that we call `PG::Connection.unescape_bytea` on PostgreSQL before decryption.
|
168
63
|
|
169
|
-
|
170
|
-
person = Person.find(1)
|
171
|
-
person.strict_loading!(mode: :n_plus_one_only)
|
172
|
-
person.posts.first
|
173
|
-
# SELECT * FROM posts WHERE person_id = 1; -- non-deterministic order
|
174
|
-
person.posts.first.firm # raises ActiveRecord::StrictLoadingViolationError
|
175
|
-
```
|
64
|
+
*Donal McBreen*
|
176
65
|
|
177
|
-
|
66
|
+
* Ensure `ActiveRecord::Encryption.config` is always ready before access.
|
178
67
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
person.posts.first # this is 1+1, not N+1
|
183
|
-
# SELECT * FROM posts WHERE person_id = 1 ORDER BY id LIMIT 1;
|
184
|
-
person.posts.first.firm # no longer raises
|
185
|
-
```
|
68
|
+
Previously, `ActiveRecord::Encryption` configuration was deferred until `ActiveRecord::Base`
|
69
|
+
was loaded. Therefore, accessing `ActiveRecord::Encryption.config` properties before
|
70
|
+
`ActiveRecord::Base` was loaded would give incorrect results.
|
186
71
|
|
187
|
-
|
72
|
+
`ActiveRecord::Encryption` now has its own loading hook so that its configuration is set as
|
73
|
+
soon as needed.
|
188
74
|
|
189
|
-
|
75
|
+
When `ActiveRecord::Base` is loaded, even lazily, it in turn triggers the loading of
|
76
|
+
`ActiveRecord::Encryption`, thus preserving the original behavior of having its config ready
|
77
|
+
before any use of `ActiveRecord::Base`.
|
190
78
|
|
191
|
-
*
|
79
|
+
*Maxime Réty*
|
192
80
|
|
193
|
-
*
|
81
|
+
* Add `TimeZoneConverter#==` method, so objects will be properly compared by
|
82
|
+
their type, scale, limit & precision.
|
194
83
|
|
195
|
-
|
196
|
-
# Before
|
197
|
-
Post.joins(:comments).pluck("posts.id", "comments.id", "comments.body")
|
84
|
+
Address #52699.
|
198
85
|
|
199
|
-
|
200
|
-
Post.joins(:comments).pluck(posts: [:id], comments: [:id, :body])
|
201
|
-
```
|
86
|
+
*Ruy Rocha*
|
202
87
|
|
203
|
-
|
88
|
+
* Add support for SQLite3 full-text-search and other virtual tables.
|
204
89
|
|
205
|
-
|
90
|
+
Previously, adding sqlite3 virtual tables messed up `schema.rb`.
|
206
91
|
|
207
|
-
|
92
|
+
Now, virtual tables can safely be added using `create_virtual_table`.
|
208
93
|
|
209
|
-
*
|
94
|
+
*Zacharias Knudsen*
|
210
95
|
|
211
|
-
|
96
|
+
* Support use of alternative database interfaces via the `database_cli` ActiveRecord configuration option.
|
212
97
|
|
213
98
|
```ruby
|
214
|
-
|
215
|
-
|
216
|
-
transaction.after_commit do
|
217
|
-
PublishNotificationMailer.with(article: article).deliver_later
|
218
|
-
end
|
99
|
+
Rails.application.configure do
|
100
|
+
config.active_record.database_cli = { postgresql: "pgcli" }
|
219
101
|
end
|
220
102
|
```
|
221
103
|
|
222
|
-
*
|
223
|
-
|
224
|
-
* Add `ActiveRecord::Base.current_transaction`.
|
225
|
-
|
226
|
-
Returns the current transaction, to allow registering callbacks on it.
|
104
|
+
*T S Vallender*
|
227
105
|
|
228
|
-
|
229
|
-
Article.current_transaction.after_commit do
|
230
|
-
PublishNotificationMailer.with(article: article).deliver_later
|
231
|
-
end
|
232
|
-
```
|
106
|
+
* Add support for dumping table inheritance and native partitioning table definitions for PostgeSQL adapter
|
233
107
|
|
234
|
-
*
|
108
|
+
*Justin Talbott*
|
235
109
|
|
236
|
-
* Add `ActiveRecord
|
110
|
+
* Add support for `ActiveRecord::Point` type casts using `Hash` values
|
237
111
|
|
238
|
-
|
239
|
-
|
112
|
+
This allows `ActiveRecord::Point` to be cast or serialized from a hash
|
113
|
+
with `:x` and `:y` keys of numeric values, mirroring the functionality of
|
114
|
+
existing casts for string and array values. Both string and symbol keys are
|
115
|
+
supported.
|
240
116
|
|
241
117
|
```ruby
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
end
|
118
|
+
class PostgresqlPoint < ActiveRecord::Base
|
119
|
+
attribute :x, :point
|
120
|
+
attribute :y, :point
|
121
|
+
attribute :z, :point
|
247
122
|
end
|
248
|
-
```
|
249
|
-
|
250
|
-
In the above example, the block is either executed immediately if called outside
|
251
|
-
of a transaction, or called after the open transaction is committed.
|
252
123
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
Starting to use counter caches on existing large tables can be troublesome, because the column
|
260
|
-
values must be backfilled separately of the column addition (to not lock the table for too long)
|
261
|
-
and before the use of `:counter_cache` (otherwise methods like `size`/`any?`/etc, which use
|
262
|
-
counter caches internally, can produce incorrect results). People usually use database triggers
|
263
|
-
or callbacks on child associations while backfilling before introducing a counter cache
|
264
|
-
configuration to the association.
|
265
|
-
|
266
|
-
Now, to safely backfill the column, while keeping the column updated with child records added/removed, use:
|
267
|
-
|
268
|
-
```ruby
|
269
|
-
class Comment < ApplicationRecord
|
270
|
-
belongs_to :post, counter_cache: { active: false }
|
271
|
-
end
|
124
|
+
val = PostgresqlPoint.new({
|
125
|
+
x: '(12.34, -43.21)',
|
126
|
+
y: [12.34, '-43.21'],
|
127
|
+
z: {x: '12.34', y: -43.21}
|
128
|
+
})
|
129
|
+
ActiveRecord::Point.new(12.32, -43.21) == val.x == val.y == val.z
|
272
130
|
```
|
273
131
|
|
274
|
-
|
275
|
-
but get the results directly from the database. After the counter cache column is backfilled, simply
|
276
|
-
remove the `{ active: false }` part from the counter cache definition, and it will now be used by the
|
277
|
-
mentioned methods.
|
278
|
-
|
279
|
-
*fatkodima*
|
280
|
-
|
281
|
-
* Retry known idempotent SELECT queries on connection-related exceptions.
|
282
|
-
|
283
|
-
SELECT queries we construct by walking the Arel tree and / or with known model attributes
|
284
|
-
are idempotent and can safely be retried in the case of a connection error. Previously,
|
285
|
-
adapters such as `TrilogyAdapter` would raise `ActiveRecord::ConnectionFailed: Trilogy::EOFError`
|
286
|
-
when encountering a connection error mid-request.
|
132
|
+
*Stephen Drew*
|
287
133
|
|
288
|
-
|
134
|
+
* Replace `SQLite3::Database#busy_timeout` with `#busy_handler_timeout=`.
|
289
135
|
|
290
|
-
|
136
|
+
Provides a non-GVL-blocking, fair retry interval busy handler implementation.
|
291
137
|
|
292
|
-
|
293
|
-
Now it's possible to pass an Array value as `foreign_key` to achieve the same behavior of an association.
|
294
|
-
|
295
|
-
*Nikita Vasilevsky*
|
296
|
-
|
297
|
-
* Allow association's `primary_key` to be composite.
|
298
|
-
|
299
|
-
Association's `primary_key` can be composite when derived from associated model `primary_key` or `query_constraints`.
|
300
|
-
Now it's possible to explicitly set it as composite on the association.
|
301
|
-
|
302
|
-
*Nikita Vasilevsky*
|
303
|
-
|
304
|
-
* Add `config.active_record.permanent_connection_checkout` setting.
|
305
|
-
|
306
|
-
Controls whether `ActiveRecord::Base.connection` raises an error, emits a deprecation warning, or neither.
|
307
|
-
|
308
|
-
`ActiveRecord::Base.connection` checkouts a database connection from the pool and keeps it leased until the end of
|
309
|
-
the request or job. This behavior can be undesirable in environments that use many more threads or fibers than there
|
310
|
-
is available connections.
|
311
|
-
|
312
|
-
This configuration can be used to track down and eliminate code that calls `ActiveRecord::Base.connection` and
|
313
|
-
migrate it to use `ActiveRecord::Base.with_connection` instead.
|
314
|
-
|
315
|
-
The default behavior remains unchanged, and there is currently no plans to change the default.
|
316
|
-
|
317
|
-
*Jean Boussier*
|
318
|
-
|
319
|
-
* Add dirties option to uncached.
|
320
|
-
|
321
|
-
This adds a `dirties` option to `ActiveRecord::Base.uncached` and
|
322
|
-
`ActiveRecord::ConnectionAdapters::ConnectionPool#uncached`.
|
323
|
-
|
324
|
-
When set to `true` (the default), writes will clear all query caches belonging to the current thread.
|
325
|
-
When set to `false`, writes to the affected connection pool will not clear any query cache.
|
326
|
-
|
327
|
-
This is needed by Solid Cache so that cache writes do not clear query caches.
|
328
|
-
|
329
|
-
*Donal McBreen*
|
330
|
-
|
331
|
-
* Deprecate `ActiveRecord::Base.connection` in favor of `.lease_connection`.
|
332
|
-
|
333
|
-
The method has been renamed as `lease_connection` to better reflect that the returned
|
334
|
-
connection will be held for the duration of the request or job.
|
335
|
-
|
336
|
-
This deprecation is a soft deprecation, no warnings will be issued and there is no
|
337
|
-
current plan to remove the method.
|
138
|
+
*Stephen Margheim*
|
338
139
|
|
339
|
-
|
140
|
+
* SQLite3Adapter: Translate `SQLite3::BusyException` into `ActiveRecord::StatementTimeout`.
|
340
141
|
|
341
|
-
*
|
142
|
+
*Matthew Nguyen*
|
342
143
|
|
343
|
-
|
344
|
-
connection will be held for the duration of the request or job.
|
144
|
+
* Include schema name in `enable_extension` statements in `db/schema.rb`.
|
345
145
|
|
346
|
-
|
146
|
+
The schema dumper will now include the schema name in generated
|
147
|
+
`enable_extension` statements if they differ from the current schema.
|
347
148
|
|
348
|
-
|
149
|
+
For example, if you have a migration:
|
349
150
|
|
350
151
|
```ruby
|
351
|
-
|
352
|
-
|
152
|
+
enable_extension "heroku_ext.pgcrypto"
|
153
|
+
enable_extension "pg_stat_statements"
|
353
154
|
```
|
354
155
|
|
355
|
-
|
356
|
-
|
357
|
-
* Using `Model.query_constraints` with a single non-primary-key column used to raise as expected, but with an
|
358
|
-
incorrect error message.
|
359
|
-
|
360
|
-
This has been fixed to raise with a more appropriate error message.
|
361
|
-
|
362
|
-
*Joshua Young*
|
363
|
-
|
364
|
-
* Fix `has_one` association autosave setting the foreign key attribute when it is unchanged.
|
365
|
-
|
366
|
-
This behavior is also inconsistent with autosaving `belongs_to` and can have unintended side effects like raising
|
367
|
-
an `ActiveRecord::ReadonlyAttributeError` when the foreign key attribute is marked as read-only.
|
368
|
-
|
369
|
-
*Joshua Young*
|
370
|
-
|
371
|
-
* Remove deprecated behavior that would rollback a transaction block when exited using `return`, `break` or `throw`.
|
372
|
-
|
373
|
-
*Rafael Mendonça França*
|
374
|
-
|
375
|
-
* Deprecate `Rails.application.config.active_record.commit_transaction_on_non_local_return`.
|
376
|
-
|
377
|
-
*Rafael Mendonça França*
|
378
|
-
|
379
|
-
* Remove deprecated support to pass `rewhere` to `ActiveRecord::Relation#merge`.
|
380
|
-
|
381
|
-
*Rafael Mendonça França*
|
382
|
-
|
383
|
-
* Remove deprecated support to pass `deferrable: true` to `add_foreign_key`.
|
384
|
-
|
385
|
-
*Rafael Mendonça França*
|
386
|
-
|
387
|
-
* Remove deprecated support to quote `ActiveSupport::Duration`.
|
388
|
-
|
389
|
-
*Rafael Mendonça França*
|
390
|
-
|
391
|
-
* Remove deprecated `#quote_bound_value`.
|
392
|
-
|
393
|
-
*Rafael Mendonça França*
|
394
|
-
|
395
|
-
* Remove deprecated `ActiveRecord::ConnectionAdapters::ConnectionPool#connection_klass`.
|
396
|
-
|
397
|
-
*Rafael Mendonça França*
|
398
|
-
|
399
|
-
* Remove deprecated support to apply `#connection_pool_list`, `#active_connections?`, `#clear_active_connections!`,
|
400
|
-
`#clear_reloadable_connections!`, `#clear_all_connections!` and `#flush_idle_connections!` to the connections pools
|
401
|
-
for the current role when the `role` argument isn't provided.
|
402
|
-
|
403
|
-
*Rafael Mendonça França*
|
404
|
-
|
405
|
-
* Remove deprecated `#all_connection_pools`.
|
406
|
-
|
407
|
-
*Rafael Mendonça França*
|
408
|
-
|
409
|
-
* Remove deprecated `ActiveRecord::ConnectionAdapters::SchemaCache#data_sources`.
|
410
|
-
|
411
|
-
*Rafael Mendonça França*
|
412
|
-
|
413
|
-
* Remove deprecated `ActiveRecord::ConnectionAdapters::SchemaCache.load_from`.
|
414
|
-
|
415
|
-
*Rafael Mendonça França*
|
416
|
-
|
417
|
-
* Remove deprecated `#all_foreign_keys_valid?` from database adapters.
|
418
|
-
|
419
|
-
*Rafael Mendonça França*
|
420
|
-
|
421
|
-
* Remove deprecated support to passing coder and class as second argument to `serialize`.
|
422
|
-
|
423
|
-
*Rafael Mendonça França*
|
424
|
-
|
425
|
-
* Remove deprecated support to `ActiveRecord::Base#read_attribute(:id)` to return the custom primary key value.
|
426
|
-
|
427
|
-
*Rafael Mendonça França*
|
428
|
-
|
429
|
-
* Remove deprecated `TestFixtures.fixture_path`.
|
430
|
-
|
431
|
-
*Rafael Mendonça França*
|
432
|
-
|
433
|
-
* Remove deprecated behavior to support referring to a singular association by its plural name.
|
434
|
-
|
435
|
-
*Rafael Mendonça França*
|
436
|
-
|
437
|
-
* Deprecate `Rails.application.config.active_record.allow_deprecated_singular_associations_name`.
|
438
|
-
|
439
|
-
*Rafael Mendonça França*
|
440
|
-
|
441
|
-
* Remove deprecated support to passing `SchemaMigration` and `InternalMetadata` classes as arguments to
|
442
|
-
`ActiveRecord::MigrationContext`.
|
443
|
-
|
444
|
-
*Rafael Mendonça França*
|
445
|
-
|
446
|
-
* Remove deprecated `ActiveRecord::Migration.check_pending!` method.
|
447
|
-
|
448
|
-
*Rafael Mendonça França*
|
449
|
-
|
450
|
-
* Remove deprecated `ActiveRecord::LogSubscriber.runtime` method.
|
451
|
-
|
452
|
-
*Rafael Mendonça França*
|
453
|
-
|
454
|
-
* Remove deprecated `ActiveRecord::LogSubscriber.runtime=` method.
|
455
|
-
|
456
|
-
*Rafael Mendonça França*
|
457
|
-
|
458
|
-
* Remove deprecated `ActiveRecord::LogSubscriber.reset_runtime` method.
|
459
|
-
|
460
|
-
*Rafael Mendonça França*
|
461
|
-
|
462
|
-
* Remove deprecated support to define `explain` in the connection adapter with 2 arguments.
|
463
|
-
|
464
|
-
*Rafael Mendonça França*
|
465
|
-
|
466
|
-
* Remove deprecated `ActiveRecord::ActiveJobRequiredError`.
|
467
|
-
|
468
|
-
*Rafael Mendonça França*
|
469
|
-
|
470
|
-
* Remove deprecated `ActiveRecord::Base.clear_active_connections!`.
|
471
|
-
|
472
|
-
*Rafael Mendonça França*
|
473
|
-
|
474
|
-
* Remove deprecated `ActiveRecord::Base.clear_reloadable_connections!`.
|
475
|
-
|
476
|
-
*Rafael Mendonça França*
|
477
|
-
|
478
|
-
* Remove deprecated `ActiveRecord::Base.clear_all_connections!`.
|
479
|
-
|
480
|
-
*Rafael Mendonça França*
|
481
|
-
|
482
|
-
* Remove deprecated `ActiveRecord::Base.flush_idle_connections!`.
|
483
|
-
|
484
|
-
*Rafael Mendonça França*
|
485
|
-
|
486
|
-
* Remove deprecated `name` argument from `ActiveRecord::Base.remove_connection`.
|
487
|
-
|
488
|
-
*Rafael Mendonça França*
|
489
|
-
|
490
|
-
* Remove deprecated support to call `alias_attribute` with non-existent attribute names.
|
491
|
-
|
492
|
-
*Rafael Mendonça França*
|
493
|
-
|
494
|
-
* Remove deprecated `Rails.application.config.active_record.suppress_multiple_database_warning`.
|
495
|
-
|
496
|
-
*Rafael Mendonça França*
|
497
|
-
|
498
|
-
* Add `ActiveRecord::Encryption::MessagePackMessageSerializer`.
|
499
|
-
|
500
|
-
Serialize data to the MessagePack format, for efficient storage in binary columns.
|
501
|
-
|
502
|
-
The binary encoding requires around 30% less space than the base64 encoding
|
503
|
-
used by the default serializer.
|
504
|
-
|
505
|
-
*Donal McBreen*
|
506
|
-
|
507
|
-
* Add support for encrypting binary columns.
|
508
|
-
|
509
|
-
Ensure encryption and decryption pass `Type::Binary::Data` around for binary data.
|
510
|
-
|
511
|
-
Previously encrypting binary columns with the `ActiveRecord::Encryption::MessageSerializer`
|
512
|
-
incidentally worked for MySQL and SQLite, but not PostgreSQL.
|
513
|
-
|
514
|
-
*Donal McBreen*
|
515
|
-
|
516
|
-
* Deprecated `ENV["SCHEMA_CACHE"]` in favor of `schema_cache_path` in the database configuration.
|
517
|
-
|
518
|
-
*Rafael Mendonça França*
|
519
|
-
|
520
|
-
* Add `ActiveRecord::Base.with_connection` as a shortcut for leasing a connection for a short duration.
|
521
|
-
|
522
|
-
The leased connection is yielded, and for the duration of the block, any call to `ActiveRecord::Base.connection`
|
523
|
-
will yield that same connection.
|
524
|
-
|
525
|
-
This is useful to perform a few database operations without causing a connection to be leased for the
|
526
|
-
entire duration of the request or job.
|
527
|
-
|
528
|
-
*Jean Boussier*
|
529
|
-
|
530
|
-
* Deprecate `config.active_record.warn_on_records_fetched_greater_than` now that `sql.active_record`
|
531
|
-
notification includes `:row_count` field.
|
532
|
-
|
533
|
-
*Jason Nochlin*
|
534
|
-
|
535
|
-
* The fix ensures that the association is joined using the appropriate join type
|
536
|
-
(either inner join or left outer join) based on the existing joins in the scope.
|
537
|
-
|
538
|
-
This prevents unintentional overrides of existing join types and ensures consistency in the generated SQL queries.
|
539
|
-
|
540
|
-
Example:
|
541
|
-
|
542
|
-
|
156
|
+
then the generated schema dump will also contain:
|
543
157
|
|
544
158
|
```ruby
|
545
|
-
|
546
|
-
|
159
|
+
enable_extension "heroku_ext.pgcrypto"
|
160
|
+
enable_extension "pg_stat_statements"
|
547
161
|
```
|
548
162
|
|
549
|
-
*
|
163
|
+
*Tony Novak*
|
550
164
|
|
551
|
-
* Fix
|
552
|
-
|
553
|
-
could be misconfigured in some cases.
|
165
|
+
* Fix `ActiveRecord::Encryption::EncryptedAttributeType#type` to return
|
166
|
+
actual cast type.
|
554
167
|
|
555
|
-
*
|
168
|
+
*Vasiliy Ermolovich*
|
556
169
|
|
557
|
-
*
|
558
|
-
|
559
|
-
```ruby
|
560
|
-
class Function > ApplicationRecord
|
561
|
-
# BAD
|
562
|
-
enum color: [:red, :blue],
|
563
|
-
type: [:instance, :class]
|
564
|
-
|
565
|
-
# GOOD
|
566
|
-
enum :color, [:red, :blue]
|
567
|
-
enum :type, [:instance, :class]
|
568
|
-
end
|
569
|
-
```
|
170
|
+
* SQLite3Adapter: Bulk insert fixtures.
|
570
171
|
|
571
|
-
|
172
|
+
Previously one insert command was executed for each fixture, now they are
|
173
|
+
aggregated in a single bulk insert command.
|
572
174
|
|
573
|
-
*
|
175
|
+
*Lázaro Nixon*
|
574
176
|
|
575
|
-
|
576
|
-
the timestamp associated with the current time. This is designed to prevent migrations prefixes
|
577
|
-
from being hand-edited to future timestamps, which impacts migration generation and other
|
578
|
-
migration commands.
|
177
|
+
* PostgreSQLAdapter: Allow `disable_extension` to be called with schema-qualified name.
|
579
178
|
|
580
|
-
|
179
|
+
For parity with `enable_extension`, the `disable_extension` method can be called with a schema-qualified
|
180
|
+
name (e.g. `disable_extension "myschema.pgcrypto"`). Note that PostgreSQL's `DROP EXTENSION` does not
|
181
|
+
actually take a schema name (unlike `CREATE EXTENSION`), so the resulting SQL statement will only name
|
182
|
+
the extension, e.g. `DROP EXTENSION IF EXISTS "pgcrypto"`.
|
581
183
|
|
582
|
-
*
|
184
|
+
*Tony Novak*
|
583
185
|
|
584
|
-
|
186
|
+
* Make `create_schema` / `drop_schema` reversible in migrations.
|
585
187
|
|
586
|
-
|
587
|
-
threads, but is required when running transactional tests or system tests
|
588
|
-
and could lead to a SEGV.
|
188
|
+
Previously, `create_schema` and `drop_schema` were irreversible migration operations.
|
589
189
|
|
590
|
-
*
|
190
|
+
*Tony Novak*
|
591
191
|
|
592
|
-
* Support
|
192
|
+
* Support batching using custom columns.
|
593
193
|
|
594
194
|
```ruby
|
595
|
-
|
195
|
+
Product.in_batches(cursor: [:shop_id, :id]) do |relation|
|
196
|
+
# do something with relation
|
197
|
+
end
|
596
198
|
```
|
597
199
|
|
598
|
-
Calculating the caller location is a costly operation and should be used primarily in development
|
599
|
-
(note, there is also a `config.active_record.verbose_query_logs` that serves the same purpose)
|
600
|
-
or occasionally on production for debugging purposes.
|
601
|
-
|
602
200
|
*fatkodima*
|
603
201
|
|
604
|
-
*
|
605
|
-
|
606
|
-
Allow compression to be disabled by setting `compress: false`
|
607
|
-
|
608
|
-
```ruby
|
609
|
-
class User
|
610
|
-
encrypts :name, encryptor: ActiveRecord::Encryption::Encryptor.new(compress: false)
|
611
|
-
end
|
612
|
-
```
|
613
|
-
|
614
|
-
*Donal McBreen*
|
615
|
-
|
616
|
-
* Deprecate passing strings to `ActiveRecord::Tasks::DatabaseTasks.cache_dump_filename`.
|
617
|
-
|
618
|
-
A `ActiveRecord::DatabaseConfigurations::DatabaseConfig` object should be passed instead.
|
619
|
-
|
620
|
-
*Rafael Mendonça França*
|
621
|
-
|
622
|
-
* Add `row_count` field to `sql.active_record` notification.
|
623
|
-
|
624
|
-
This field returns the amount of rows returned by the query that emitted the notification.
|
625
|
-
|
626
|
-
This metric is useful in cases where one wants to detect queries with big result sets.
|
627
|
-
|
628
|
-
*Marvin Bitterlich*
|
629
|
-
|
630
|
-
* Consistently raise an `ArgumentError` when passing an invalid argument to a nested attributes association writer.
|
631
|
-
|
632
|
-
Previously, this would only raise on collection associations and produce a generic error on singular associations.
|
633
|
-
|
634
|
-
Now, it will raise on both collection and singular associations.
|
635
|
-
|
636
|
-
*Joshua Young*
|
637
|
-
|
638
|
-
* Fix single quote escapes on default generated MySQL columns.
|
202
|
+
* Use SQLite `IMMEDIATE` transactions when possible.
|
639
203
|
|
640
|
-
|
204
|
+
Transactions run against the SQLite3 adapter default to IMMEDIATE mode to improve concurrency support and avoid busy exceptions.
|
641
205
|
|
642
|
-
|
643
|
-
|
644
|
-
This would result in issues when importing the schema on a fresh instance of a MySQL database.
|
645
|
-
|
646
|
-
Now, the string will not be escaped and will be valid Ruby upon importing of the schema.
|
647
|
-
|
648
|
-
*Yash Kapadia*
|
649
|
-
|
650
|
-
* Fix Migrations with versions older than 7.1 validating options given to
|
651
|
-
`add_reference` and `t.references`.
|
652
|
-
|
653
|
-
*Hartley McGuire*
|
206
|
+
*Stephen Margheim*
|
654
207
|
|
655
|
-
*
|
208
|
+
* Raise specific exception when a connection is not defined.
|
656
209
|
|
657
|
-
|
210
|
+
The new `ConnectionNotDefined` exception provides connection name, shard and role accessors indicating the details of the connection that was requested.
|
658
211
|
|
659
|
-
*
|
212
|
+
*Hana Harencarova*, *Matthew Draper*
|
660
213
|
|
661
|
-
|
214
|
+
* Delete the deprecated constant `ActiveRecord::ImmutableRelation`.
|
662
215
|
|
663
|
-
|
664
|
-
cache.
|
216
|
+
*Xavier Noria*
|
665
217
|
|
666
|
-
|
218
|
+
* Fix duplicate callback execution when child autosaves parent with `has_one` and `belongs_to`.
|
667
219
|
|
668
|
-
|
220
|
+
Before, persisting a new child record with a new associated parent record would run `before_validation`,
|
221
|
+
`after_validation`, `before_save` and `after_save` callbacks twice.
|
669
222
|
|
670
|
-
|
671
|
-
but with support for `after_commit` and `after_rollback` callback options.
|
223
|
+
Now, these callbacks are only executed once as expected.
|
672
224
|
|
673
225
|
*Joshua Young*
|
674
226
|
|
675
|
-
*
|
676
|
-
|
677
|
-
Previously, the encryptor instance only allowed an encrypted value serialized as a `String` to be passed to the message serializer.
|
678
|
-
|
679
|
-
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`.
|
680
|
-
|
681
|
-
The default `ActiveRecord::Encryption::MessageSerializer` already ensures that only `String` objects are passed for deserialization.
|
682
|
-
|
683
|
-
*Maxime Réty*
|
684
|
-
|
685
|
-
* Fix `encrypted_attribute?` to take into account context properties passed to `encrypts`.
|
686
|
-
|
687
|
-
*Maxime Réty*
|
688
|
-
|
689
|
-
* The object returned by `explain` now responds to `pluck`, `first`,
|
690
|
-
`last`, `average`, `count`, `maximum`, `minimum`, and `sum`. Those
|
691
|
-
new methods run `EXPLAIN` on the corresponding queries:
|
227
|
+
* `ActiveRecord::Encryption::Encryptor` now supports a `:compressor` option to customize the compression algorithm used.
|
692
228
|
|
693
229
|
```ruby
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
User.all.explain.maximum(:id)
|
699
|
-
# EXPLAIN SELECT MAX(`users`.`id`) FROM `users`
|
700
|
-
# ...
|
701
|
-
```
|
702
|
-
|
703
|
-
*Petrik de Heus*
|
704
|
-
|
705
|
-
* Fixes an issue where `validates_associated` `:on` option wasn't respected
|
706
|
-
when validating associated records.
|
707
|
-
|
708
|
-
*Austen Madden*, *Alex Ghiculescu*, *Rafał Brize*
|
709
|
-
|
710
|
-
* Allow overriding SQLite defaults from `database.yml`.
|
230
|
+
module ZstdCompressor
|
231
|
+
def self.deflate(data)
|
232
|
+
Zstd.compress(data)
|
233
|
+
end
|
711
234
|
|
712
|
-
|
713
|
-
|
714
|
-
|
235
|
+
def self.inflate(data)
|
236
|
+
Zstd.decompress(data)
|
237
|
+
end
|
238
|
+
end
|
715
239
|
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
pragmas:
|
720
|
-
journal_mode: off
|
721
|
-
temp_store: memory
|
240
|
+
class User
|
241
|
+
encrypts :name, compressor: ZstdCompressor
|
242
|
+
end
|
722
243
|
```
|
723
244
|
|
724
|
-
|
725
|
-
|
726
|
-
* Remove warning message when running SQLite in production, but leave it unconfigured.
|
727
|
-
|
728
|
-
There are valid use cases for running SQLite in production. However, it must be done
|
729
|
-
with care, so instead of a warning most users won't see anyway, it's preferable to
|
730
|
-
leave the configuration commented out to force them to think about having the database
|
731
|
-
on a persistent volume etc.
|
732
|
-
|
733
|
-
*Jacopo Beschi*, *Jean Boussier*
|
734
|
-
|
735
|
-
* Add support for generated columns to the SQLite3 adapter.
|
736
|
-
|
737
|
-
Generated columns (both stored and dynamic) are supported since version 3.31.0 of SQLite.
|
738
|
-
This adds support for those to the SQLite3 adapter.
|
245
|
+
You disable compression by passing `compress: false`.
|
739
246
|
|
740
247
|
```ruby
|
741
|
-
|
742
|
-
|
743
|
-
t.virtual :name_upper, type: :string, as: 'UPPER(name)'
|
744
|
-
t.virtual :name_lower, type: :string, as: 'LOWER(name)', stored: true
|
248
|
+
class User
|
249
|
+
encrypts :name, compress: false
|
745
250
|
end
|
746
251
|
```
|
747
252
|
|
748
|
-
*
|
749
|
-
|
750
|
-
* TrilogyAdapter: ignore `host` if `socket` parameter is set.
|
751
|
-
|
752
|
-
This allows to configure a connection on a UNIX socket via `DATABASE_URL`:
|
753
|
-
|
754
|
-
```
|
755
|
-
DATABASE_URL=trilogy://does-not-matter/my_db_production?socket=/var/run/mysql.sock
|
756
|
-
```
|
253
|
+
*heka1024*
|
757
254
|
|
758
|
-
|
255
|
+
* Add condensed `#inspect` for `ConnectionPool`, `AbstractAdapter`, and
|
256
|
+
`DatabaseConfig`.
|
759
257
|
|
760
|
-
*
|
761
|
-
`assert_no_queries_match` assertions public.
|
258
|
+
*Hartley McGuire*
|
762
259
|
|
763
|
-
|
764
|
-
`assert_no_queries`. To assert that specific SQL queries are made, `assert_queries_match` and
|
765
|
-
`assert_no_queries_match` are used. These assertions can now be used in applications as well.
|
260
|
+
* Add `.shard_keys`, `.sharded?`, & `.connected_to_all_shards` methods.
|
766
261
|
|
767
262
|
```ruby
|
768
|
-
class
|
769
|
-
|
770
|
-
assert_queries_count(1) { Article.first }
|
771
|
-
end
|
263
|
+
class ShardedBase < ActiveRecord::Base
|
264
|
+
self.abstract_class = true
|
772
265
|
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
end
|
266
|
+
connects_to shards: {
|
267
|
+
shard_one: { writing: :shard_one },
|
268
|
+
shard_two: { writing: :shard_two }
|
269
|
+
}
|
778
270
|
end
|
779
|
-
```
|
780
|
-
|
781
|
-
*Petrik de Heus*, *fatkodima*
|
782
|
-
|
783
|
-
* Fix `has_secure_token` calls the setter method on initialize.
|
784
271
|
|
785
|
-
|
786
|
-
|
787
|
-
* When using a `DATABASE_URL`, allow for a configuration to map the protocol in the URL to a specific database
|
788
|
-
adapter. This allows decoupling the adapter the application chooses to use from the database connection details
|
789
|
-
set in the deployment environment.
|
272
|
+
class ShardedModel < ShardedBase
|
273
|
+
end
|
790
274
|
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
# will connect to MySQL using the trilogy adapter
|
275
|
+
ShardedModel.shard_keys => [:shard_one, :shard_two]
|
276
|
+
ShardedModel.sharded? => true
|
277
|
+
ShardedBase.connected_to_all_shards { ShardedModel.current_shard } => [:shard_one, :shard_two]
|
795
278
|
```
|
796
279
|
|
797
|
-
*
|
280
|
+
*Nony Dutton*
|
798
281
|
|
799
|
-
*
|
800
|
-
|
801
|
-
called with a generic warning message rather than silently ignoring the warning(s).
|
282
|
+
* Add a `filter` option to `in_order_of` to prioritize certain values in the sorting without filtering the results
|
283
|
+
by these values.
|
802
284
|
|
803
|
-
*
|
285
|
+
*Igor Depolli*
|
804
286
|
|
805
|
-
*
|
806
|
-
|
807
|
-
*Andrew Novoselac*
|
808
|
-
|
809
|
-
* Fix `where(field: values)` queries when `field` is a serialized attribute
|
810
|
-
(for example, when `field` uses `ActiveRecord::Base.serialize` or is a JSON
|
811
|
-
column).
|
812
|
-
|
813
|
-
*João Alves*
|
814
|
-
|
815
|
-
* Make the output of `ActiveRecord::Core#inspect` configurable.
|
816
|
-
|
817
|
-
By default, calling `inspect` on a record will yield a formatted string including just the `id`.
|
818
|
-
|
819
|
-
```ruby
|
820
|
-
Post.first.inspect #=> "#<Post id: 1>"
|
821
|
-
```
|
822
|
-
|
823
|
-
The attributes to be included in the output of `inspect` can be configured with
|
824
|
-
`ActiveRecord::Core#attributes_for_inspect`.
|
825
|
-
|
826
|
-
```ruby
|
827
|
-
Post.attributes_for_inspect = [:id, :title]
|
828
|
-
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!">"
|
829
|
-
```
|
287
|
+
* Fix an issue where the IDs reader method did not return expected results
|
288
|
+
for preloaded associations in models using composite primary keys.
|
830
289
|
|
831
|
-
|
290
|
+
*Jay Ang*
|
832
291
|
|
833
|
-
|
834
|
-
Post.attributes_for_inspect = :all
|
835
|
-
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!", published_at: "2023-10-23 14:28:11 +0000">"
|
836
|
-
```
|
292
|
+
* Allow to configure `strict_loading_mode` globally or within a model.
|
837
293
|
|
838
|
-
|
294
|
+
Defaults to `:all`, can be changed to `:n_plus_one_only`.
|
839
295
|
|
840
|
-
|
296
|
+
*Garen Torikian*
|
841
297
|
|
842
|
-
|
298
|
+
* Add `ActiveRecord::Relation#readonly?`.
|
843
299
|
|
844
|
-
|
300
|
+
Reflects if the relation has been marked as readonly.
|
845
301
|
|
846
|
-
*
|
847
|
-
`-Float::INFINITY`.
|
302
|
+
*Theodor Tonum*
|
848
303
|
|
849
|
-
|
304
|
+
* Improve `ActiveRecord::Store` to raise a descriptive exception if the column is not either
|
305
|
+
structured (e.g., PostgreSQL +hstore+/+json+, or MySQL +json+) or declared serializable via
|
306
|
+
`ActiveRecord.store`.
|
850
307
|
|
851
|
-
|
308
|
+
Previously, a `NoMethodError` would be raised when the accessor was read or written:
|
852
309
|
|
853
|
-
|
310
|
+
NoMethodError: undefined method `accessor' for an instance of ActiveRecord::Type::Text
|
854
311
|
|
855
|
-
|
312
|
+
Now, a descriptive `ConfigurationError` is raised:
|
856
313
|
|
857
|
-
|
314
|
+
ActiveRecord::ConfigurationError: the column 'metadata' has not been configured as a store.
|
315
|
+
Please make sure the column is declared serializable via 'ActiveRecord.store' or, if your
|
316
|
+
database supports it, use a structured column type like hstore or json.
|
858
317
|
|
859
|
-
|
860
|
-
add_reference :person, :alias, foreign_key: { deferrable: :deferred }
|
861
|
-
add_reference :alias, :person, foreign_key: { deferrable: :deferred }
|
862
|
-
```
|
318
|
+
*Mike Dalessio*
|
863
319
|
|
864
|
-
|
320
|
+
* Fix inference of association model on nested models with the same demodularized name.
|
865
321
|
|
866
|
-
|
322
|
+
E.g. with the following setup:
|
867
323
|
|
868
324
|
```ruby
|
869
|
-
Post
|
870
|
-
|
871
|
-
Post.transaction do
|
872
|
-
Post.connection.set_constraints(:deferred)
|
873
|
-
p = Post.create!(user_id: -1)
|
874
|
-
u = User.create!
|
875
|
-
p.user = u
|
876
|
-
p.save!
|
325
|
+
class Nested::Post < ApplicationRecord
|
326
|
+
has_one :post, through: :other
|
877
327
|
end
|
878
328
|
```
|
879
329
|
|
880
|
-
|
881
|
-
|
882
|
-
* Include `ActiveModel::API` in `ActiveRecord::Base`.
|
883
|
-
|
884
|
-
*Sean Doyle*
|
885
|
-
|
886
|
-
* Ensure `#signed_id` outputs `url_safe` strings.
|
887
|
-
|
888
|
-
*Jason Meller*
|
330
|
+
Before, `#post` would infer the model as `Nested::Post`, but now it correctly infers `Post`.
|
889
331
|
|
890
|
-
*
|
332
|
+
*Joshua Young*
|
891
333
|
|
892
|
-
|
334
|
+
* Add public method for checking if a table is ignored by the schema cache.
|
893
335
|
|
894
|
-
|
336
|
+
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.
|
895
337
|
|
896
338
|
```ruby
|
897
|
-
|
339
|
+
ActiveRecord.schema_cache_ignored_tables = ["developers"]
|
340
|
+
ActiveRecord.schema_cache_ignored_table?("developers")
|
341
|
+
=> true
|
898
342
|
```
|
899
343
|
|
900
|
-
*
|
344
|
+
*Eileen M. Uchitelle*
|
901
345
|
|
902
|
-
Please check [7-
|
346
|
+
Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/activerecord/CHANGELOG.md) for previous changes.
|