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