activerecord 7.2.3 → 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.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +192 -1261
- data/README.rdoc +2 -2
- data/lib/active_record/associations/alias_tracker.rb +4 -6
- data/lib/active_record/associations/association.rb +25 -5
- data/lib/active_record/associations/belongs_to_association.rb +2 -18
- data/lib/active_record/associations/builder/association.rb +7 -6
- data/lib/active_record/associations/collection_association.rb +4 -4
- data/lib/active_record/associations/disable_joins_association_scope.rb +1 -1
- data/lib/active_record/associations/has_many_through_association.rb +4 -9
- data/lib/active_record/associations/join_dependency/join_association.rb +27 -25
- 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 +50 -32
- data/lib/active_record/asynchronous_queries_tracker.rb +28 -24
- data/lib/active_record/attribute_methods/serialization.rb +1 -1
- data/lib/active_record/attribute_methods.rb +19 -24
- data/lib/active_record/attributes.rb +26 -37
- data/lib/active_record/autosave_association.rb +81 -49
- data/lib/active_record/base.rb +2 -2
- data/lib/active_record/callbacks.rb +1 -1
- 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 +31 -75
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +90 -43
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +14 -19
- data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +2 -6
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +27 -9
- data/lib/active_record/connection_adapters/abstract/transaction.rb +15 -5
- data/lib/active_record/connection_adapters/abstract_adapter.rb +27 -57
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +28 -58
- data/lib/active_record/connection_adapters/mysql/quoting.rb +1 -15
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +2 -8
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +43 -45
- data/lib/active_record/connection_adapters/mysql2/database_statements.rb +42 -98
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +2 -16
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +64 -42
- 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_definitions.rb +12 -14
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +51 -9
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +44 -101
- 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/quoting.rb +0 -13
- 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 -2
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +60 -22
- data/lib/active_record/connection_adapters/trilogy/database_statements.rb +37 -67
- data/lib/active_record/connection_adapters/trilogy_adapter.rb +1 -18
- data/lib/active_record/connection_handling.rb +29 -11
- data/lib/active_record/core.rb +15 -60
- data/lib/active_record/counter_cache.rb +1 -1
- data/lib/active_record/database_configurations/connection_url_resolver.rb +1 -3
- data/lib/active_record/delegated_type.rb +18 -18
- 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 +11 -2
- data/lib/active_record/encryption/encryptor.rb +35 -29
- 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 +12 -13
- data/lib/active_record/errors.rb +16 -8
- data/lib/active_record/fixture_set/table_row.rb +2 -19
- data/lib/active_record/fixtures.rb +0 -1
- data/lib/active_record/future_result.rb +14 -10
- data/lib/active_record/gem_version.rb +4 -4
- data/lib/active_record/insert_all.rb +1 -1
- data/lib/active_record/marshalling.rb +1 -4
- 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 +36 -35
- data/lib/active_record/model_schema.rb +1 -1
- data/lib/active_record/nested_attributes.rb +4 -6
- data/lib/active_record/persistence.rb +128 -130
- data/lib/active_record/query_cache.rb +5 -4
- data/lib/active_record/query_logs.rb +98 -44
- data/lib/active_record/query_logs_formatter.rb +17 -28
- data/lib/active_record/querying.rb +10 -10
- data/lib/active_record/railtie.rb +5 -6
- data/lib/active_record/railties/databases.rake +1 -2
- data/lib/active_record/reflection.rb +9 -7
- 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 +55 -55
- data/lib/active_record/relation/delegation.rb +25 -14
- data/lib/active_record/relation/finder_methods.rb +31 -32
- data/lib/active_record/relation/merger.rb +8 -8
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +0 -2
- 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 +5 -0
- data/lib/active_record/relation/query_attribute.rb +1 -1
- data/lib/active_record/relation/query_methods.rb +90 -91
- 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/where_clause.rb +2 -8
- data/lib/active_record/relation.rb +77 -76
- data/lib/active_record/result.rb +68 -7
- data/lib/active_record/sanitization.rb +7 -6
- data/lib/active_record/schema_dumper.rb +16 -29
- data/lib/active_record/schema_migration.rb +2 -1
- data/lib/active_record/scoping/named.rb +5 -2
- data/lib/active_record/secure_token.rb +3 -3
- data/lib/active_record/signed_id.rb +6 -7
- 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 +24 -15
- data/lib/active_record/tasks/mysql_database_tasks.rb +0 -2
- data/lib/active_record/tasks/postgresql_database_tasks.rb +0 -7
- data/lib/active_record/tasks/sqlite_database_tasks.rb +2 -2
- data/lib/active_record/test_fixtures.rb +12 -0
- data/lib/active_record/testing/query_assertions.rb +2 -2
- data/lib/active_record/token_for.rb +1 -1
- data/lib/active_record/transactions.rb +1 -3
- data/lib/active_record/validations/uniqueness.rb +8 -8
- data/lib/active_record.rb +16 -1
- data/lib/arel/collectors/bind.rb +1 -1
- data/lib/arel/crud.rb +0 -2
- data/lib/arel/delete_manager.rb +0 -5
- data/lib/arel/nodes/delete_statement.rb +2 -4
- data/lib/arel/nodes/update_statement.rb +2 -4
- data/lib/arel/select_manager.rb +2 -6
- data/lib/arel/update_manager.rb +0 -5
- data/lib/arel/visitors/dot.rb +0 -2
- data/lib/arel/visitors/sqlite.rb +0 -25
- data/lib/arel/visitors/to_sql.rb +1 -3
- metadata +14 -11
data/CHANGELOG.md
CHANGED
|
@@ -1,1415 +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
|
-
`ON DELETE CASCADE` foreign keys, ActiveRecord would silently delete all
|
|
7
|
-
data from the child tables. This occurred because SQLite requires table
|
|
8
|
-
recreation for schema changes, and during this process the original table
|
|
9
|
-
is temporarily dropped, triggering CASCADE deletes on child tables.
|
|
10
|
-
|
|
11
|
-
The root cause was incorrect ordering of operations. The original code
|
|
12
|
-
wrapped `disable_referential_integrity` inside a transaction, but
|
|
13
|
-
`PRAGMA foreign_keys` cannot be modified inside a transaction in SQLite -
|
|
14
|
-
attempting to do so simply has no effect. This meant foreign keys remained
|
|
15
|
-
enabled during table recreation, causing CASCADE deletes to fire.
|
|
16
|
-
|
|
17
|
-
The fix reverses the order to follow the official SQLite 12-step ALTER TABLE
|
|
18
|
-
procedure: `disable_referential_integrity` now wraps the transaction instead
|
|
19
|
-
of being wrapped by it. This ensures foreign keys are properly disabled
|
|
20
|
-
before the transaction starts and re-enabled after it commits, preventing
|
|
21
|
-
CASCADE deletes while maintaining data integrity through atomic transactions.
|
|
22
|
-
|
|
23
|
-
*Ruy Rocha*
|
|
24
|
-
|
|
25
|
-
* Fix `belongs_to` associations not to clear the entire composite primary key.
|
|
26
|
-
|
|
27
|
-
When clearing a `belongs_to` association that references a model with composite primary key,
|
|
28
|
-
only the optional part of the key should be cleared.
|
|
29
|
-
|
|
30
|
-
*zzak*
|
|
31
|
-
|
|
32
|
-
* Fix invalid records being autosaved when distantly associated records are marked for deletion.
|
|
33
|
-
|
|
34
|
-
*Ian Terrell*, *axlekb AB*
|
|
35
|
-
|
|
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
|
-
|
|
50
|
-
*Jean Boussier*
|
|
51
|
-
|
|
52
|
-
* Fix query cache for pinned connections in multi threaded transactional tests.
|
|
53
|
-
|
|
54
|
-
When a pinned connection is used across separate threads, they now use a separate cache store
|
|
55
|
-
for each thread.
|
|
56
|
-
|
|
57
|
-
This improve accuracy of system tests, and any test using multiple threads.
|
|
58
|
-
|
|
59
|
-
*Heinrich Lee Yu*, *Jean Boussier*
|
|
60
|
-
|
|
61
|
-
* Don't add `id_value` attribute alias when attribute/column with that name already exists.
|
|
62
|
-
|
|
63
|
-
*Rob Lewis*
|
|
64
|
-
|
|
65
|
-
* Fix false positive change detection involving STI and polymorhic has one relationships.
|
|
66
|
-
|
|
67
|
-
Polymorphic `has_one` relationships would always be considered changed when defined in a STI child
|
|
68
|
-
class, causing nedless extra autosaves.
|
|
69
|
-
|
|
70
|
-
*David Fritsch*
|
|
71
|
-
|
|
72
|
-
* Fix stale associaton detection for polymophic `belong_to`.
|
|
73
|
-
|
|
74
|
-
*Florent Beaurain*, *Thomas Crambert*
|
|
75
|
-
|
|
76
|
-
* Fix removal of PostgreSQL version comments in `structure.sql` for latest PostgreSQL versions which include `\restrict`.
|
|
77
|
-
|
|
78
|
-
*Brendan Weibrecht*
|
|
79
|
-
|
|
80
|
-
* Fix `#merge` with `#or` or `#and` and a mixture of attributes and SQL strings resulting in an incorrect query.
|
|
81
|
-
|
|
82
|
-
```ruby
|
|
83
|
-
base = Comment.joins(:post).where(user_id: 1).where("recent = 1")
|
|
84
|
-
puts base.merge(base.where(draft: true).or(Post.where(archived: true))).to_sql
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Before:
|
|
88
|
-
|
|
89
|
-
```SQL
|
|
90
|
-
SELECT "comments".* FROM "comments"
|
|
91
|
-
INNER JOIN "posts" ON "posts"."id" = "comments"."post_id"
|
|
92
|
-
WHERE (recent = 1)
|
|
93
|
-
AND (
|
|
94
|
-
"comments"."user_id" = 1
|
|
95
|
-
AND (recent = 1)
|
|
96
|
-
AND "comments"."draft" = 1
|
|
97
|
-
OR "posts"."archived" = 1
|
|
98
|
-
)
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
After:
|
|
102
|
-
|
|
103
|
-
```SQL
|
|
104
|
-
SELECT "comments".* FROM "comments"
|
|
105
|
-
INNER JOIN "posts" ON "posts"."id" = "comments"."post_id"
|
|
106
|
-
WHERE "comments"."user_id" = 1
|
|
107
|
-
AND (recent = 1)
|
|
108
|
-
AND (
|
|
109
|
-
"comments"."user_id" = 1
|
|
110
|
-
AND (recent = 1)
|
|
111
|
-
AND "comments"."draft" = 1
|
|
112
|
-
OR "posts"."archived" = 1
|
|
113
|
-
)
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
*Joshua Young*
|
|
117
|
-
|
|
118
|
-
* Fix inline `has_and_belongs_to_many` fixtures for tables with composite primary keys.
|
|
119
|
-
|
|
120
|
-
*fatkodima*
|
|
121
|
-
|
|
122
|
-
* Fix `annotate` comments to propagate to `update_all`/`delete_all`.
|
|
123
|
-
|
|
124
|
-
*fatkodima*
|
|
125
|
-
|
|
126
|
-
* Fix checking whether an unpersisted record is `include?`d in a strictly
|
|
127
|
-
loaded `has_and_belongs_to_many` association.
|
|
128
|
-
|
|
129
|
-
*Hartley McGuire*
|
|
130
|
-
|
|
131
|
-
* Fix inline has_and_belongs_to_many fixtures for tables with composite primary keys.
|
|
132
|
-
|
|
133
|
-
*fatkodima*
|
|
134
|
-
|
|
135
|
-
* `create_or_find_by` will now correctly rollback a transaction.
|
|
136
|
-
|
|
137
|
-
When using `create_or_find_by`, raising a ActiveRecord::Rollback error
|
|
138
|
-
in a `after_save` callback had no effect, the transaction was committed
|
|
139
|
-
and a record created.
|
|
140
|
-
|
|
141
|
-
*Edouard Chin*
|
|
142
|
-
|
|
143
|
-
* Gracefully handle `Timeout.timeout` firing during connection configuration.
|
|
144
|
-
|
|
145
|
-
Use of `Timeout.timeout` could result in improperly initialized database connection.
|
|
146
|
-
|
|
147
|
-
This could lead to a partially configured connection being used, resulting in various exceptions,
|
|
148
|
-
the most common being with the PostgreSQLAdapter raising `undefined method 'key?' for nil`
|
|
149
|
-
or `TypeError: wrong argument type nil (expected PG::TypeMap)`.
|
|
150
|
-
|
|
151
|
-
*Jean Boussier*
|
|
152
|
-
|
|
153
|
-
* The SQLite3 adapter quotes non-finite Numeric values like "Infinity" and "NaN".
|
|
154
|
-
|
|
155
|
-
*Mike Dalessio*
|
|
156
|
-
|
|
157
|
-
* Handle libpq returning a database version of 0 on no/bad connection in `PostgreSQLAdapter`.
|
|
158
|
-
|
|
159
|
-
Before, this version would be cached and an error would be raised during connection configuration when
|
|
160
|
-
comparing it with the minimum required version for the adapter. This meant that the connection could
|
|
161
|
-
never be successfully configured on subsequent reconnection attempts.
|
|
162
|
-
|
|
163
|
-
Now, this is treated as a connection failure consistent with libpq, raising a `ActiveRecord::ConnectionFailed`
|
|
164
|
-
and ensuring the version isn't cached, which allows the version to be retrieved on the next connection attempt.
|
|
165
|
-
|
|
166
|
-
*Joshua Young*, *Rian McGuire*
|
|
167
|
-
|
|
168
|
-
* Fix error handling during connection configuration.
|
|
169
|
-
|
|
170
|
-
Active Record wasn't properly handling errors during the connection configuration phase.
|
|
171
|
-
This could lead to a partially configured connection being used, resulting in various exceptions,
|
|
172
|
-
the most common being with the PostgreSQLAdapter raising `undefined method `key?' for nil`
|
|
173
|
-
or `TypeError: wrong argument type nil (expected PG::TypeMap)`.
|
|
174
|
-
|
|
175
|
-
*Jean Boussier*
|
|
176
|
-
|
|
177
|
-
* Fix a case where a non-retryable query could be marked retryable.
|
|
178
|
-
|
|
179
|
-
*Hartley McGuire*
|
|
180
|
-
|
|
181
|
-
* Handle circular references when autosaving associations.
|
|
182
|
-
|
|
183
|
-
*zzak*
|
|
184
|
-
|
|
185
|
-
* Prevent persisting invalid record.
|
|
186
|
-
|
|
187
|
-
*Edouard Chin*
|
|
188
|
-
|
|
189
|
-
* Fix support for PostgreSQL enum types with commas in their name.
|
|
190
|
-
|
|
191
|
-
*Arthur Hess*
|
|
192
|
-
|
|
193
|
-
* Fix inserts on MySQL with no RETURNING support for a table with multiple auto populated columns.
|
|
194
|
-
|
|
195
|
-
*Nikita Vasilevsky*
|
|
196
|
-
|
|
197
|
-
* Fix joining on a scoped association with string joins and bind parameters.
|
|
198
|
-
|
|
199
|
-
```ruby
|
|
200
|
-
class Instructor < ActiveRecord::Base
|
|
201
|
-
has_many :instructor_roles, -> { active }
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
class InstructorRole < ActiveRecord::Base
|
|
205
|
-
scope :active, -> {
|
|
206
|
-
joins("JOIN students ON instructor_roles.student_id = students.id")
|
|
207
|
-
.where(students { status: 1 })
|
|
208
|
-
}
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
Instructor.joins(:instructor_roles).first
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
The above example would result in `ActiveRecord::StatementInvalid` because the
|
|
215
|
-
`active` scope bind parameters would be lost.
|
|
216
|
-
|
|
217
|
-
*Jean Boussier*
|
|
218
|
-
|
|
219
|
-
* Fix a potential race condition with system tests and transactional fixtures.
|
|
220
|
-
|
|
221
|
-
*Sjoerd Lagarde*
|
|
222
|
-
|
|
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
|
-
* Fix autosave associations to no longer validated unmodified associated records.
|
|
232
|
-
|
|
233
|
-
Active Record was incorrectly performing validation on associated record that
|
|
234
|
-
weren't created nor modified as part of the transaction:
|
|
235
|
-
|
|
236
|
-
```ruby
|
|
237
|
-
Post.create!(author: User.find(1)) # Fail if user is invalid
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
*Jean Boussier*
|
|
241
|
-
|
|
242
|
-
* Remember when a database connection has recently been verified (for
|
|
243
|
-
two seconds, by default), to avoid repeated reverifications during a
|
|
244
|
-
single request.
|
|
245
|
-
|
|
246
|
-
This should recreate a similar rate of verification as in Rails 7.1,
|
|
247
|
-
where connections are leased for the duration of a request, and thus
|
|
248
|
-
only verified once.
|
|
249
|
-
|
|
250
|
-
*Matthew Draper*
|
|
251
|
-
|
|
252
|
-
* Fix prepared statements on mysql2 adapter.
|
|
253
|
-
|
|
254
|
-
*Jean Boussier*
|
|
255
|
-
|
|
256
|
-
* Fix a race condition in `ActiveRecord::Base#method_missing` when lazily defining attributes.
|
|
257
|
-
|
|
258
|
-
If multiple thread were concurrently triggering attribute definition on the same model,
|
|
259
|
-
it could result in a `NoMethodError` being raised.
|
|
260
|
-
|
|
261
|
-
*Jean Boussier*
|
|
262
|
-
|
|
263
|
-
* Fix MySQL default functions getting dropped when changing a column's nullability.
|
|
264
|
-
|
|
265
|
-
*Bastian Bartmann*
|
|
266
|
-
|
|
267
|
-
* Fix `add_unique_constraint`/`add_check_constraint`/`/`add_foreign_key` to be revertible when
|
|
268
|
-
given invalid options.
|
|
269
|
-
|
|
270
|
-
*fatkodima*
|
|
271
|
-
|
|
272
|
-
* Fix asynchronous destroying of polymorphic `belongs_to` associations.
|
|
273
|
-
|
|
274
|
-
*fatkodima*
|
|
275
|
-
|
|
276
|
-
* NOT VALID constraints should not dump in `create_table`.
|
|
277
|
-
|
|
278
|
-
*Ryuta Kamizono*
|
|
279
|
-
|
|
280
|
-
* Fix finding by nil composite primary key association.
|
|
281
|
-
|
|
282
|
-
*fatkodima*
|
|
283
|
-
|
|
284
|
-
* Fix parsing of SQLite foreign key names when they contain non-ASCII characters
|
|
285
|
-
|
|
286
|
-
*Zacharias Knudsen*
|
|
287
|
-
|
|
288
|
-
* Fix parsing of MySQL 8.0.16+ CHECK constraints when they contain new lines.
|
|
289
|
-
|
|
290
|
-
*Steve Hill*
|
|
291
|
-
|
|
292
|
-
* Ensure normalized attribute queries use `IS NULL` consistently for `nil` and normalized `nil` values.
|
|
293
|
-
|
|
294
|
-
*Joshua Young*
|
|
295
|
-
|
|
296
|
-
* Restore back the ability to pass only database name for `DATABASE_URL`.
|
|
297
|
-
|
|
298
|
-
*fatkodima*
|
|
299
|
-
|
|
300
|
-
* Fix `order` with using association name as an alias.
|
|
301
|
-
|
|
302
|
-
*Ryuta Kamizono*
|
|
303
|
-
|
|
304
|
-
* Improve invalid argument error for with.
|
|
305
|
-
|
|
306
|
-
*Ryuta Kamizono*
|
|
307
|
-
|
|
308
|
-
* Deduplicate `with` CTE expressions.
|
|
309
|
-
|
|
310
|
-
*fatkodima*
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
## Rails 7.2.2.2 (August 13, 2025) ##
|
|
314
|
-
|
|
315
|
-
* Call inspect on ids in RecordNotFound error
|
|
316
|
-
|
|
317
|
-
[CVE-2025-55193]
|
|
318
|
-
|
|
319
|
-
*Gannon McGibbon*, *John Hawthorn*
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
## Rails 7.2.2.1 (December 10, 2024) ##
|
|
323
|
-
|
|
324
|
-
* No changes.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
## Rails 7.2.2 (October 30, 2024) ##
|
|
328
|
-
|
|
329
|
-
* Fix support for `query_cache: false` in `database.yml`.
|
|
330
|
-
|
|
331
|
-
`query_cache: false` would no longer entirely disable the Active Record query cache.
|
|
332
|
-
|
|
333
|
-
*zzak*
|
|
334
|
-
|
|
335
|
-
* Set `.attributes_for_inspect` to `:all` by default.
|
|
336
|
-
|
|
337
|
-
For new applications it is set to `[:id]` in config/environment/production.rb.
|
|
338
|
-
|
|
339
|
-
In the console all the attributes are always shown.
|
|
340
|
-
|
|
341
|
-
*Andrew Novoselac*
|
|
342
|
-
|
|
343
|
-
* `PG::UnableToSend: no connection to the server` is now retryable as a connection-related exception
|
|
344
|
-
|
|
345
|
-
*Kazuma Watanabe*
|
|
346
|
-
|
|
347
|
-
* Fix marshalling of unsaved associated records in 7.1 format.
|
|
348
|
-
|
|
349
|
-
The 7.1 format would only marshal associated records if the association was loaded.
|
|
350
|
-
But associations that would only contain unsaved records would be skipped.
|
|
351
|
-
|
|
352
|
-
*Jean Boussier*
|
|
353
|
-
|
|
354
|
-
* Fix incorrect SQL query when passing an empty hash to `ActiveRecord::Base.insert`.
|
|
355
|
-
|
|
356
|
-
*David Stosik*
|
|
357
|
-
|
|
358
|
-
* Allow to save records with polymorphic join tables that have `inverse_of`
|
|
359
|
-
specified.
|
|
360
|
-
|
|
361
|
-
*Markus Doits*
|
|
362
|
-
|
|
363
|
-
* Fix association scopes applying on the incorrect join when using a polymorphic `has_many through:`.
|
|
364
|
-
|
|
365
|
-
*Joshua Young*
|
|
366
|
-
|
|
367
|
-
* Fix `dependent: :destroy` for bi-directional has one through association.
|
|
368
|
-
|
|
369
|
-
Fixes #50948.
|
|
370
|
-
|
|
371
|
-
```ruby
|
|
372
|
-
class Left < ActiveRecord::Base
|
|
373
|
-
has_one :middle, dependent: :destroy
|
|
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
|
|
386
|
-
```
|
|
387
|
-
In the above example `left.destroy` wouldn't destroy its associated `Right`
|
|
388
|
-
record.
|
|
389
|
-
|
|
390
|
-
*Andy Stewart*
|
|
391
|
-
|
|
392
|
-
* Properly handle lazily pinned connection pools.
|
|
393
|
-
|
|
394
|
-
Fixes #53147.
|
|
395
|
-
|
|
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
|
-
|
|
401
|
-
*Jean Boussier*
|
|
402
|
-
|
|
403
|
-
* Fix `ActiveRecord::Base.with` to accept more than two sub queries.
|
|
404
|
-
|
|
405
|
-
Fixes #53110.
|
|
406
|
-
|
|
407
|
-
```ruby
|
|
408
|
-
User.with(foo: [User.select(:id), User.select(:id), User.select(:id)]).to_sql
|
|
409
|
-
undefined method `union' for an instance of Arel::Nodes::UnionAll (NoMethodError)
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
The above now works as expected.
|
|
413
|
-
|
|
414
|
-
*fatkodima*
|
|
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.
|
|
423
|
-
|
|
424
|
-
*Jean Boussier*
|
|
425
|
-
|
|
426
|
-
* Make Float distinguish between `float4` and `float8` in PostgreSQL.
|
|
427
|
-
|
|
428
|
-
Fixes #52742
|
|
429
|
-
|
|
430
|
-
*Ryota Kitazawa*, *Takayuki Nagatomi*
|
|
431
|
-
|
|
432
|
-
* Fix an issue where `.left_outer_joins` used with multiple associations that have
|
|
433
|
-
the same child association but different parents does not join all parents.
|
|
434
|
-
|
|
435
|
-
Previously, using `.left_outer_joins` with the same child association would only join one of the parents.
|
|
436
|
-
|
|
437
|
-
Now it will correctly join both parents.
|
|
438
|
-
|
|
439
|
-
Fixes #41498.
|
|
440
|
-
|
|
441
|
-
*Garrett Blehm*
|
|
442
|
-
|
|
443
|
-
* Ensure `ActiveRecord::Encryption.config` is always ready before access.
|
|
444
|
-
|
|
445
|
-
Previously, `ActiveRecord::Encryption` configuration was deferred until `ActiveRecord::Base`
|
|
446
|
-
was loaded. Therefore, accessing `ActiveRecord::Encryption.config` properties before
|
|
447
|
-
`ActiveRecord::Base` was loaded would give incorrect results.
|
|
448
|
-
|
|
449
|
-
`ActiveRecord::Encryption` now has its own loading hook so that its configuration is set as
|
|
450
|
-
soon as needed.
|
|
451
|
-
|
|
452
|
-
When `ActiveRecord::Base` is loaded, even lazily, it in turn triggers the loading of
|
|
453
|
-
`ActiveRecord::Encryption`, thus preserving the original behavior of having its config ready
|
|
454
|
-
before any use of `ActiveRecord::Base`.
|
|
455
|
-
|
|
456
|
-
*Maxime Réty*
|
|
457
|
-
|
|
458
|
-
* Add `TimeZoneConverter#==` method, so objects will be properly compared by
|
|
459
|
-
their type, scale, limit & precision.
|
|
460
|
-
|
|
461
|
-
Address #52699.
|
|
462
|
-
|
|
463
|
-
*Ruy Rocha*
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
## Rails 7.2.1.2 (October 23, 2024) ##
|
|
467
|
-
|
|
468
|
-
* No changes.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
## Rails 7.2.1.1 (October 15, 2024) ##
|
|
472
|
-
|
|
473
|
-
* No changes.
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
## Rails 7.2.1 (August 22, 2024) ##
|
|
477
|
-
|
|
478
|
-
* Fix detection for `enum` columns with parallelized tests and PostgreSQL.
|
|
479
|
-
|
|
480
|
-
*Rafael Mendonça França*
|
|
481
|
-
|
|
482
|
-
* Allow to eager load nested nil associations.
|
|
483
|
-
|
|
484
|
-
*fatkodima*
|
|
485
|
-
|
|
486
|
-
* Fix swallowing ignore order warning when batching using `BatchEnumerator`.
|
|
487
|
-
|
|
488
|
-
*fatkodima*
|
|
489
|
-
|
|
490
|
-
* Fix memory bloat on the connection pool when using the Fiber `IsolatedExecutionState`.
|
|
491
|
-
|
|
492
|
-
*Jean Boussier*
|
|
493
|
-
|
|
494
|
-
* Restore inferred association class with the same modularized name.
|
|
495
|
-
|
|
496
|
-
*Justin Ko*
|
|
497
|
-
|
|
498
|
-
* Fix `ActiveRecord::Base.inspect` to properly explain how to load schema information.
|
|
499
|
-
|
|
500
|
-
*Jean Boussier*
|
|
501
|
-
|
|
502
|
-
* Check invalid `enum` options for the new syntax.
|
|
503
|
-
|
|
504
|
-
The options using `_` prefix in the old syntax are invalid in the new syntax.
|
|
505
|
-
|
|
506
|
-
*Rafael Mendonça França*
|
|
507
|
-
|
|
508
|
-
* Fix `ActiveRecord::Encryption::EncryptedAttributeType#type` to return
|
|
509
|
-
actual cast type.
|
|
510
|
-
|
|
511
|
-
*Vasiliy Ermolovich*
|
|
512
|
-
|
|
513
|
-
* Fix `create_table` with `:auto_increment` option for MySQL adapter.
|
|
514
|
-
|
|
515
|
-
*fatkodima*
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
## Rails 7.2.0 (August 09, 2024) ##
|
|
519
|
-
|
|
520
|
-
* Handle commas in Sqlite3 default function definitions.
|
|
521
|
-
|
|
522
|
-
*Stephen Margheim*
|
|
523
|
-
|
|
524
|
-
* Fixes `validates_associated` raising an exception when configured with a
|
|
525
|
-
singular association and having `index_nested_attribute_errors` enabled.
|
|
526
|
-
|
|
527
|
-
*Martin Spickermann*
|
|
528
|
-
|
|
529
|
-
* The constant `ActiveRecord::ImmutableRelation` has been deprecated because
|
|
530
|
-
we want to reserve that name for a stronger sense of "immutable relation".
|
|
531
|
-
Please use `ActiveRecord::UnmodifiableRelation` instead.
|
|
532
|
-
|
|
533
|
-
*Xavier Noria*
|
|
534
|
-
|
|
535
|
-
* Add condensed `#inspect` for `ConnectionPool`, `AbstractAdapter`, and
|
|
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:
|
|
573
|
-
|
|
574
|
-
```ruby
|
|
575
|
-
class Nested::Post < ApplicationRecord
|
|
576
|
-
has_one :post, through: :other
|
|
577
|
-
end
|
|
578
|
-
```
|
|
579
|
-
|
|
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
|
-
*fatkodima*
|
|
593
|
-
|
|
594
|
-
* Support `touch_all` in batches.
|
|
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`.
|
|
621
|
-
|
|
622
|
-
*Nikita Vasilevsky*
|
|
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.
|
|
683
|
-
|
|
684
|
-
Before:
|
|
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
|
-
```
|
|
703
|
-
|
|
704
|
-
*Reid Lynch*
|
|
705
|
-
|
|
706
|
-
* Allow `Sqlite3Adapter` to use `sqlite3` gem version `2.x`.
|
|
707
|
-
|
|
708
|
-
*Mike Dalessio*
|
|
709
|
-
|
|
710
|
-
* Allow `ActiveRecord::Base#pluck` to accept hash values.
|
|
711
|
-
|
|
712
|
-
```ruby
|
|
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
|
-
```
|
|
719
|
-
|
|
720
|
-
*fatkodima*
|
|
721
|
-
|
|
722
|
-
* Raise an `ActiveRecord::ActiveRecordError` error when the MySQL database returns an invalid version string.
|
|
723
|
-
|
|
724
|
-
*Kevin McPhillips*
|
|
725
|
-
|
|
726
|
-
* `ActiveRecord::Base.transaction` now yields an `ActiveRecord::Transaction` object.
|
|
727
|
-
|
|
728
|
-
This allows to register callbacks on it.
|
|
729
|
-
|
|
730
|
-
```ruby
|
|
731
|
-
Article.transaction do |transaction|
|
|
732
|
-
article.update(published: true)
|
|
733
|
-
transaction.after_commit do
|
|
734
|
-
PublishNotificationMailer.with(article: article).deliver_later
|
|
735
|
-
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
|
-
|
|
751
|
-
*Jean Boussier*
|
|
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
|
|
763
|
-
end
|
|
764
|
-
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
|
-
|
|
770
|
-
If the transaction is rolled back, the block isn't called.
|
|
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:
|
|
5
|
+
This will let you to drop multiple tables in a single call.
|
|
784
6
|
|
|
785
7
|
```ruby
|
|
786
|
-
|
|
787
|
-
belongs_to :post, counter_cache: { active: false }
|
|
788
|
-
end
|
|
8
|
+
ActiveRecord::Base.lease_connection.drop_table(:users, :posts)
|
|
789
9
|
```
|
|
790
10
|
|
|
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.
|
|
11
|
+
*Gabriel Sobrinho*
|
|
815
12
|
|
|
816
|
-
|
|
817
|
-
|
|
13
|
+
* Add support for PostgreSQL `IF NOT EXISTS` via the `:if_not_exists` option
|
|
14
|
+
on the `add_enum_value` method.
|
|
818
15
|
|
|
819
|
-
*
|
|
16
|
+
*Ariel Rzezak*
|
|
820
17
|
|
|
821
|
-
*
|
|
18
|
+
* When running `db:migrate` on a fresh database, load the database schema before running migrations.
|
|
822
19
|
|
|
823
|
-
|
|
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.
|
|
20
|
+
*Andrew Novoselac*
|
|
833
21
|
|
|
834
|
-
|
|
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.
|
|
835
24
|
|
|
836
|
-
|
|
25
|
+
Previously, using `.left_outer_joins` with the same child association would only join one of the parents.
|
|
837
26
|
|
|
838
|
-
|
|
839
|
-
`ActiveRecord::ConnectionAdapters::ConnectionPool#uncached`.
|
|
27
|
+
Now it will correctly join both parents.
|
|
840
28
|
|
|
841
|
-
|
|
842
|
-
When set to `false`, writes to the affected connection pool will not clear any query cache.
|
|
29
|
+
Fixes #41498.
|
|
843
30
|
|
|
844
|
-
|
|
31
|
+
*Garrett Blehm*
|
|
845
32
|
|
|
846
|
-
|
|
33
|
+
* Deprecate `unsigned_float` and `unsigned_decimal` short-hand column methods.
|
|
847
34
|
|
|
848
|
-
|
|
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.
|
|
849
37
|
|
|
850
|
-
|
|
851
|
-
connection will be held for the duration of the request or job.
|
|
38
|
+
https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
|
|
852
39
|
|
|
853
|
-
|
|
854
|
-
current plan to remove the method.
|
|
40
|
+
*Ryuta Kamizono*
|
|
855
41
|
|
|
856
|
-
|
|
42
|
+
* Drop MySQL 5.5 support.
|
|
857
43
|
|
|
858
|
-
|
|
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.
|
|
859
47
|
|
|
860
|
-
|
|
861
|
-
connection will be held for the duration of the request or job.
|
|
48
|
+
*Ryuta Kamizono*
|
|
862
49
|
|
|
863
|
-
|
|
50
|
+
* Make Active Record asynchronous queries compatible with transactional fixtures.
|
|
864
51
|
|
|
865
|
-
|
|
52
|
+
Previously transactional fixtures would disable asynchronous queries, because transactional
|
|
53
|
+
fixtures impose all queries use the same connection.
|
|
866
54
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
assert_equal "Ruby on Rails", fixture(:web_sites, :rubyonrails).name
|
|
870
|
-
```
|
|
55
|
+
Now asynchronous queries will use the connection pinned by transactional fixtures, and behave
|
|
56
|
+
much closer to production.
|
|
871
57
|
|
|
872
58
|
*Jean Boussier*
|
|
873
59
|
|
|
874
|
-
*
|
|
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!`.
|
|
60
|
+
* Deserialize binary data before decrypting
|
|
1000
61
|
|
|
1001
|
-
|
|
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.
|
|
62
|
+
This ensures that we call `PG::Connection.unescape_bytea` on PostgreSQL before decryption.
|
|
1021
63
|
|
|
1022
64
|
*Donal McBreen*
|
|
1023
65
|
|
|
1024
|
-
*
|
|
1025
|
-
|
|
1026
|
-
Ensure encryption and decryption pass `Type::Binary::Data` around for binary data.
|
|
66
|
+
* Ensure `ActiveRecord::Encryption.config` is always ready before access.
|
|
1027
67
|
|
|
1028
|
-
Previously
|
|
1029
|
-
|
|
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.
|
|
1030
71
|
|
|
1031
|
-
|
|
72
|
+
`ActiveRecord::Encryption` now has its own loading hook so that its configuration is set as
|
|
73
|
+
soon as needed.
|
|
1032
74
|
|
|
1033
|
-
|
|
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`.
|
|
1034
78
|
|
|
1035
|
-
*
|
|
79
|
+
*Maxime Réty*
|
|
1036
80
|
|
|
1037
|
-
* Add `
|
|
81
|
+
* Add `TimeZoneConverter#==` method, so objects will be properly compared by
|
|
82
|
+
their type, scale, limit & precision.
|
|
1038
83
|
|
|
1039
|
-
|
|
1040
|
-
will yield that same connection.
|
|
84
|
+
Address #52699.
|
|
1041
85
|
|
|
1042
|
-
|
|
1043
|
-
entire duration of the request or job.
|
|
86
|
+
*Ruy Rocha*
|
|
1044
87
|
|
|
1045
|
-
|
|
88
|
+
* Add support for SQLite3 full-text-search and other virtual tables.
|
|
1046
89
|
|
|
1047
|
-
|
|
1048
|
-
notification includes `:row_count` field.
|
|
90
|
+
Previously, adding sqlite3 virtual tables messed up `schema.rb`.
|
|
1049
91
|
|
|
1050
|
-
|
|
92
|
+
Now, virtual tables can safely be added using `create_virtual_table`.
|
|
1051
93
|
|
|
1052
|
-
*
|
|
94
|
+
*Zacharias Knudsen*
|
|
1053
95
|
|
|
1054
|
-
|
|
96
|
+
* Support use of alternative database interfaces via the `database_cli` ActiveRecord configuration option.
|
|
1055
97
|
|
|
1056
98
|
```ruby
|
|
1057
|
-
|
|
99
|
+
Rails.application.configure do
|
|
100
|
+
config.active_record.database_cli = { postgresql: "pgcli" }
|
|
101
|
+
end
|
|
1058
102
|
```
|
|
1059
103
|
|
|
1060
|
-
|
|
104
|
+
*T S Vallender*
|
|
1061
105
|
|
|
1062
|
-
|
|
106
|
+
* Add support for dumping table inheritance and native partitioning table definitions for PostgeSQL adapter
|
|
1063
107
|
|
|
1064
|
-
*
|
|
1065
|
-
of Active Record models, when an application is eager loaded. As a result, encrypted attributes
|
|
1066
|
-
could be misconfigured in some cases.
|
|
108
|
+
*Justin Talbott*
|
|
1067
109
|
|
|
1068
|
-
|
|
110
|
+
* Add support for `ActiveRecord::Point` type casts using `Hash` values
|
|
1069
111
|
|
|
1070
|
-
|
|
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.
|
|
1071
116
|
|
|
1072
117
|
```ruby
|
|
1073
|
-
class
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
# GOOD
|
|
1079
|
-
enum :color, [:red, :blue]
|
|
1080
|
-
enum :type, [:instance, :class]
|
|
118
|
+
class PostgresqlPoint < ActiveRecord::Base
|
|
119
|
+
attribute :x, :point
|
|
120
|
+
attribute :y, :point
|
|
121
|
+
attribute :z, :point
|
|
1081
122
|
end
|
|
123
|
+
|
|
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
|
|
1082
130
|
```
|
|
1083
131
|
|
|
1084
|
-
*
|
|
132
|
+
*Stephen Drew*
|
|
1085
133
|
|
|
1086
|
-
*
|
|
134
|
+
* Replace `SQLite3::Database#busy_timeout` with `#busy_handler_timeout=`.
|
|
1087
135
|
|
|
1088
|
-
|
|
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.
|
|
136
|
+
Provides a non-GVL-blocking, fair retry interval busy handler implementation.
|
|
1092
137
|
|
|
1093
|
-
*
|
|
138
|
+
*Stephen Margheim*
|
|
1094
139
|
|
|
1095
|
-
*
|
|
140
|
+
* SQLite3Adapter: Translate `SQLite3::BusyException` into `ActiveRecord::StatementTimeout`.
|
|
1096
141
|
|
|
1097
|
-
|
|
142
|
+
*Matthew Nguyen*
|
|
1098
143
|
|
|
1099
|
-
|
|
1100
|
-
threads, but is required when running transactional tests or system tests
|
|
1101
|
-
and could lead to a SEGV.
|
|
144
|
+
* Include schema name in `enable_extension` statements in `db/schema.rb`.
|
|
1102
145
|
|
|
1103
|
-
|
|
146
|
+
The schema dumper will now include the schema name in generated
|
|
147
|
+
`enable_extension` statements if they differ from the current schema.
|
|
1104
148
|
|
|
1105
|
-
|
|
149
|
+
For example, if you have a migration:
|
|
1106
150
|
|
|
1107
151
|
```ruby
|
|
1108
|
-
|
|
152
|
+
enable_extension "heroku_ext.pgcrypto"
|
|
153
|
+
enable_extension "pg_stat_statements"
|
|
1109
154
|
```
|
|
1110
155
|
|
|
1111
|
-
|
|
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`
|
|
156
|
+
then the generated schema dump will also contain:
|
|
1120
157
|
|
|
1121
158
|
```ruby
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
end
|
|
159
|
+
enable_extension "heroku_ext.pgcrypto"
|
|
160
|
+
enable_extension "pg_stat_statements"
|
|
1125
161
|
```
|
|
1126
162
|
|
|
1127
|
-
*
|
|
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.
|
|
1158
|
-
|
|
1159
|
-
Now, the string will not be escaped and will be valid Ruby upon importing of the schema.
|
|
1160
|
-
|
|
1161
|
-
*Yash Kapadia*
|
|
1162
|
-
|
|
1163
|
-
* Fix Migrations with versions older than 7.1 validating options given to
|
|
1164
|
-
`add_reference` and `t.references`.
|
|
1165
|
-
|
|
1166
|
-
*Hartley McGuire*
|
|
1167
|
-
|
|
1168
|
-
* Add `<role>_types` class method to `ActiveRecord::DelegatedType` so that the delegated types can be introspected.
|
|
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.
|
|
163
|
+
*Tony Novak*
|
|
1175
164
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
*Mike Coutermarsh*, *Jean Boussier*
|
|
165
|
+
* Fix `ActiveRecord::Encryption::EncryptedAttributeType#type` to return
|
|
166
|
+
actual cast type.
|
|
1180
167
|
|
|
1181
|
-
*
|
|
168
|
+
*Vasiliy Ermolovich*
|
|
1182
169
|
|
|
1183
|
-
|
|
1184
|
-
but with support for `after_commit` and `after_rollback` callback options.
|
|
170
|
+
* SQLite3Adapter: Bulk insert fixtures.
|
|
1185
171
|
|
|
1186
|
-
|
|
172
|
+
Previously one insert command was executed for each fixture, now they are
|
|
173
|
+
aggregated in a single bulk insert command.
|
|
1187
174
|
|
|
1188
|
-
*
|
|
175
|
+
*Lázaro Nixon*
|
|
1189
176
|
|
|
1190
|
-
|
|
177
|
+
* PostgreSQLAdapter: Allow `disable_extension` to be called with schema-qualified name.
|
|
1191
178
|
|
|
1192
|
-
|
|
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"`.
|
|
1193
183
|
|
|
1194
|
-
|
|
184
|
+
*Tony Novak*
|
|
1195
185
|
|
|
1196
|
-
|
|
186
|
+
* Make `create_schema` / `drop_schema` reversible in migrations.
|
|
1197
187
|
|
|
1198
|
-
|
|
188
|
+
Previously, `create_schema` and `drop_schema` were irreversible migration operations.
|
|
1199
189
|
|
|
1200
|
-
*
|
|
190
|
+
*Tony Novak*
|
|
1201
191
|
|
|
1202
|
-
*
|
|
1203
|
-
`last`, `average`, `count`, `maximum`, `minimum`, and `sum`. Those
|
|
1204
|
-
new methods run `EXPLAIN` on the corresponding queries:
|
|
192
|
+
* Support batching using custom columns.
|
|
1205
193
|
|
|
1206
194
|
```ruby
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
User.all.explain.maximum(:id)
|
|
1212
|
-
# EXPLAIN SELECT MAX(`users`.`id`) FROM `users`
|
|
1213
|
-
# ...
|
|
195
|
+
Product.in_batches(cursor: [:shop_id, :id]) do |relation|
|
|
196
|
+
# do something with relation
|
|
197
|
+
end
|
|
1214
198
|
```
|
|
1215
199
|
|
|
1216
|
-
*
|
|
1217
|
-
|
|
1218
|
-
* Fixes an issue where `validates_associated` `:on` option wasn't respected
|
|
1219
|
-
when validating associated records.
|
|
1220
|
-
|
|
1221
|
-
*Austen Madden*, *Alex Ghiculescu*, *Rafał Brize*
|
|
1222
|
-
|
|
1223
|
-
* Allow overriding SQLite defaults from `database.yml`.
|
|
200
|
+
*fatkodima*
|
|
1224
201
|
|
|
1225
|
-
|
|
1226
|
-
file takes precedence over Rails' defaults, and additional PRAGMAs can be
|
|
1227
|
-
set as well.
|
|
202
|
+
* Use SQLite `IMMEDIATE` transactions when possible.
|
|
1228
203
|
|
|
1229
|
-
|
|
1230
|
-
database: storage/development.sqlite3
|
|
1231
|
-
timeout: 5000
|
|
1232
|
-
pragmas:
|
|
1233
|
-
journal_mode: off
|
|
1234
|
-
temp_store: memory
|
|
1235
|
-
```
|
|
204
|
+
Transactions run against the SQLite3 adapter default to IMMEDIATE mode to improve concurrency support and avoid busy exceptions.
|
|
1236
205
|
|
|
1237
206
|
*Stephen Margheim*
|
|
1238
207
|
|
|
1239
|
-
*
|
|
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*
|
|
208
|
+
* Raise specific exception when a connection is not defined.
|
|
1247
209
|
|
|
1248
|
-
|
|
210
|
+
The new `ConnectionNotDefined` exception provides connection name, shard and role accessors indicating the details of the connection that was requested.
|
|
1249
211
|
|
|
1250
|
-
|
|
1251
|
-
This adds support for those to the SQLite3 adapter.
|
|
212
|
+
*Hana Harencarova*, *Matthew Draper*
|
|
1252
213
|
|
|
1253
|
-
|
|
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
|
|
1258
|
-
end
|
|
1259
|
-
```
|
|
1260
|
-
|
|
1261
|
-
*Stephen Margheim*
|
|
214
|
+
* Delete the deprecated constant `ActiveRecord::ImmutableRelation`.
|
|
1262
215
|
|
|
1263
|
-
*
|
|
216
|
+
*Xavier Noria*
|
|
1264
217
|
|
|
1265
|
-
|
|
218
|
+
* Fix duplicate callback execution when child autosaves parent with `has_one` and `belongs_to`.
|
|
1266
219
|
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
```
|
|
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.
|
|
1270
222
|
|
|
1271
|
-
|
|
223
|
+
Now, these callbacks are only executed once as expected.
|
|
1272
224
|
|
|
1273
|
-
*
|
|
1274
|
-
`assert_no_queries_match` assertions public.
|
|
225
|
+
*Joshua Young*
|
|
1275
226
|
|
|
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.
|
|
227
|
+
* `ActiveRecord::Encryption::Encryptor` now supports a `:compressor` option to customize the compression algorithm used.
|
|
1279
228
|
|
|
1280
229
|
```ruby
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
230
|
+
module ZstdCompressor
|
|
231
|
+
def self.deflate(data)
|
|
232
|
+
Zstd.compress(data)
|
|
1284
233
|
end
|
|
1285
234
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
@connection.add_foreign_key(:comments, :posts)
|
|
1289
|
-
end
|
|
235
|
+
def self.inflate(data)
|
|
236
|
+
Zstd.decompress(data)
|
|
1290
237
|
end
|
|
1291
238
|
end
|
|
1292
|
-
```
|
|
1293
|
-
|
|
1294
|
-
*Petrik de Heus*, *fatkodima*
|
|
1295
239
|
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
240
|
+
class User
|
|
241
|
+
encrypts :name, compressor: ZstdCompressor
|
|
242
|
+
end
|
|
243
|
+
```
|
|
1299
244
|
|
|
1300
|
-
|
|
1301
|
-
adapter. This allows decoupling the adapter the application chooses to use from the database connection details
|
|
1302
|
-
set in the deployment environment.
|
|
245
|
+
You disable compression by passing `compress: false`.
|
|
1303
246
|
|
|
1304
247
|
```ruby
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
248
|
+
class User
|
|
249
|
+
encrypts :name, compress: false
|
|
250
|
+
end
|
|
1308
251
|
```
|
|
1309
252
|
|
|
1310
|
-
*
|
|
253
|
+
*heka1024*
|
|
1311
254
|
|
|
1312
|
-
*
|
|
1313
|
-
|
|
1314
|
-
called with a generic warning message rather than silently ignoring the warning(s).
|
|
255
|
+
* Add condensed `#inspect` for `ConnectionPool`, `AbstractAdapter`, and
|
|
256
|
+
`DatabaseConfig`.
|
|
1315
257
|
|
|
1316
|
-
*
|
|
258
|
+
*Hartley McGuire*
|
|
1317
259
|
|
|
1318
|
-
*
|
|
260
|
+
* Add `.shard_keys`, `.sharded?`, & `.connected_to_all_shards` methods.
|
|
1319
261
|
|
|
1320
|
-
|
|
262
|
+
```ruby
|
|
263
|
+
class ShardedBase < ActiveRecord::Base
|
|
264
|
+
self.abstract_class = true
|
|
1321
265
|
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
266
|
+
connects_to shards: {
|
|
267
|
+
shard_one: { writing: :shard_one },
|
|
268
|
+
shard_two: { writing: :shard_two }
|
|
269
|
+
}
|
|
270
|
+
end
|
|
1325
271
|
|
|
1326
|
-
|
|
272
|
+
class ShardedModel < ShardedBase
|
|
273
|
+
end
|
|
1327
274
|
|
|
1328
|
-
|
|
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]
|
|
278
|
+
```
|
|
1329
279
|
|
|
1330
|
-
|
|
280
|
+
*Nony Dutton*
|
|
1331
281
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
```
|
|
282
|
+
* Add a `filter` option to `in_order_of` to prioritize certain values in the sorting without filtering the results
|
|
283
|
+
by these values.
|
|
1335
284
|
|
|
1336
|
-
|
|
1337
|
-
`ActiveRecord::Core#attributes_for_inspect`.
|
|
285
|
+
*Igor Depolli*
|
|
1338
286
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!">"
|
|
1342
|
-
```
|
|
287
|
+
* Fix an issue where the IDs reader method did not return expected results
|
|
288
|
+
for preloaded associations in models using composite primary keys.
|
|
1343
289
|
|
|
1344
|
-
|
|
290
|
+
*Jay Ang*
|
|
1345
291
|
|
|
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
|
-
```
|
|
292
|
+
* Allow to configure `strict_loading_mode` globally or within a model.
|
|
1350
293
|
|
|
1351
|
-
|
|
294
|
+
Defaults to `:all`, can be changed to `:n_plus_one_only`.
|
|
1352
295
|
|
|
1353
|
-
|
|
296
|
+
*Garen Torikian*
|
|
1354
297
|
|
|
1355
|
-
|
|
298
|
+
* Add `ActiveRecord::Relation#readonly?`.
|
|
1356
299
|
|
|
1357
|
-
|
|
300
|
+
Reflects if the relation has been marked as readonly.
|
|
1358
301
|
|
|
1359
|
-
*
|
|
1360
|
-
`-Float::INFINITY`.
|
|
302
|
+
*Theodor Tonum*
|
|
1361
303
|
|
|
1362
|
-
|
|
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`.
|
|
1363
307
|
|
|
1364
|
-
|
|
308
|
+
Previously, a `NoMethodError` would be raised when the accessor was read or written:
|
|
1365
309
|
|
|
1366
|
-
|
|
310
|
+
NoMethodError: undefined method `accessor' for an instance of ActiveRecord::Type::Text
|
|
1367
311
|
|
|
1368
|
-
|
|
312
|
+
Now, a descriptive `ConfigurationError` is raised:
|
|
1369
313
|
|
|
1370
|
-
|
|
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.
|
|
1371
317
|
|
|
1372
|
-
|
|
1373
|
-
add_reference :person, :alias, foreign_key: { deferrable: :deferred }
|
|
1374
|
-
add_reference :alias, :person, foreign_key: { deferrable: :deferred }
|
|
1375
|
-
```
|
|
318
|
+
*Mike Dalessio*
|
|
1376
319
|
|
|
1377
|
-
|
|
320
|
+
* Fix inference of association model on nested models with the same demodularized name.
|
|
1378
321
|
|
|
1379
|
-
|
|
322
|
+
E.g. with the following setup:
|
|
1380
323
|
|
|
1381
324
|
```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!
|
|
325
|
+
class Nested::Post < ApplicationRecord
|
|
326
|
+
has_one :post, through: :other
|
|
1390
327
|
end
|
|
1391
328
|
```
|
|
1392
329
|
|
|
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*
|
|
330
|
+
Before, `#post` would infer the model as `Nested::Post`, but now it correctly infers `Post`.
|
|
1402
331
|
|
|
1403
|
-
*
|
|
332
|
+
*Joshua Young*
|
|
1404
333
|
|
|
1405
|
-
|
|
334
|
+
* Add public method for checking if a table is ignored by the schema cache.
|
|
1406
335
|
|
|
1407
|
-
|
|
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.
|
|
1408
337
|
|
|
1409
338
|
```ruby
|
|
1410
|
-
|
|
339
|
+
ActiveRecord.schema_cache_ignored_tables = ["developers"]
|
|
340
|
+
ActiveRecord.schema_cache_ignored_table?("developers")
|
|
341
|
+
=> true
|
|
1411
342
|
```
|
|
1412
343
|
|
|
1413
|
-
*
|
|
344
|
+
*Eileen M. Uchitelle*
|
|
1414
345
|
|
|
1415
|
-
Please check [7-
|
|
346
|
+
Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/activerecord/CHANGELOG.md) for previous changes.
|