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