activerecord 7.1.1 → 7.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +496 -0
- data/README.rdoc +1 -0
- data/lib/active_record/associations/association.rb +2 -1
- data/lib/active_record/associations/belongs_to_association.rb +4 -4
- data/lib/active_record/associations/collection_association.rb +4 -4
- data/lib/active_record/associations/has_many_association.rb +2 -2
- data/lib/active_record/associations/has_one_association.rb +2 -2
- data/lib/active_record/associations/join_dependency/join_association.rb +3 -2
- data/lib/active_record/associations/join_dependency.rb +10 -12
- data/lib/active_record/associations/preloader/association.rb +4 -1
- data/lib/active_record/associations.rb +21 -15
- data/lib/active_record/attribute_methods/before_type_cast.rb +1 -1
- data/lib/active_record/attribute_methods/dirty.rb +15 -11
- data/lib/active_record/attribute_methods/read.rb +3 -3
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +4 -0
- data/lib/active_record/attribute_methods/write.rb +3 -3
- data/lib/active_record/attribute_methods.rb +47 -7
- data/lib/active_record/autosave_association.rb +5 -2
- data/lib/active_record/callbacks.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +19 -9
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +5 -3
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +2 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +8 -4
- data/lib/active_record/connection_adapters/abstract_adapter.rb +27 -19
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +37 -13
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +2 -1
- data/lib/active_record/connection_adapters/mysql2/database_statements.rb +3 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +16 -10
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +4 -1
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +6 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +3 -2
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +15 -6
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +32 -33
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +10 -3
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +2 -2
- data/lib/active_record/connection_adapters/trilogy/database_statements.rb +1 -0
- data/lib/active_record/connection_adapters/trilogy_adapter.rb +25 -21
- data/lib/active_record/connection_handling.rb +1 -1
- data/lib/active_record/core.rb +49 -10
- data/lib/active_record/counter_cache.rb +7 -3
- data/lib/active_record/database_configurations/connection_url_resolver.rb +1 -1
- data/lib/active_record/database_configurations/hash_config.rb +6 -2
- data/lib/active_record/delegated_type.rb +7 -7
- data/lib/active_record/destroy_association_async_job.rb +1 -1
- data/lib/active_record/encryption/encryptable_record.rb +7 -1
- data/lib/active_record/encryption/encrypted_attribute_type.rb +6 -2
- data/lib/active_record/encryption/extended_deterministic_queries.rb +0 -15
- data/lib/active_record/encryption/scheme.rb +8 -4
- data/lib/active_record/encryption.rb +2 -0
- data/lib/active_record/enum.rb +6 -9
- data/lib/active_record/errors.rb +5 -4
- data/lib/active_record/fixtures.rb +16 -0
- data/lib/active_record/future_result.rb +10 -0
- data/lib/active_record/gem_version.rb +1 -1
- data/lib/active_record/insert_all.rb +3 -3
- data/lib/active_record/internal_metadata.rb +1 -1
- data/lib/active_record/locking/optimistic.rb +1 -1
- data/lib/active_record/marshalling.rb +4 -1
- data/lib/active_record/message_pack.rb +1 -1
- data/lib/active_record/middleware/database_selector.rb +1 -1
- data/lib/active_record/migration/compatibility.rb +14 -0
- data/lib/active_record/migration/pending_migration_connection.rb +21 -0
- data/lib/active_record/migration.rb +9 -5
- data/lib/active_record/model_schema.rb +12 -7
- data/lib/active_record/nested_attributes.rb +16 -5
- data/lib/active_record/normalization.rb +8 -0
- data/lib/active_record/persistence.rb +6 -5
- data/lib/active_record/promise.rb +1 -1
- data/lib/active_record/query_cache.rb +1 -1
- data/lib/active_record/query_logs_formatter.rb +1 -1
- data/lib/active_record/railtie.rb +14 -14
- data/lib/active_record/railties/controller_runtime.rb +2 -1
- data/lib/active_record/railties/databases.rake +7 -7
- data/lib/active_record/reflection.rb +21 -3
- data/lib/active_record/relation/calculations.rb +28 -1
- data/lib/active_record/relation/delegation.rb +1 -1
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +6 -1
- data/lib/active_record/relation/query_methods.rb +21 -7
- data/lib/active_record/relation.rb +30 -5
- data/lib/active_record/result.rb +1 -1
- data/lib/active_record/runtime_registry.rb +15 -1
- data/lib/active_record/schema_migration.rb +1 -1
- data/lib/active_record/secure_token.rb +1 -1
- data/lib/active_record/tasks/database_tasks.rb +35 -13
- data/lib/active_record/test_fixtures.rb +1 -0
- data/lib/active_record/timestamp.rb +3 -1
- data/lib/active_record.rb +2 -2
- data/lib/arel/nodes/homogeneous_in.rb +1 -1
- data/lib/arel/tree_manager.rb +5 -1
- data/lib/arel/visitors/to_sql.rb +2 -1
- metadata +14 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b45ca3fee0a501dbddff6f5513b1c6d76224df56a5826e4cdcc67bded7fe299e
|
|
4
|
+
data.tar.gz: a5c02ade3297c1a2aae5ddd20f51ad4bb83d53bc807b968f3253c69bb8598f9b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2083fba136690148693664668f35e35717ccf6116cdcf28a996e5e5b4e021f633d5c786d676c447f63423bb4b418415270214966cb0c2539569a3e0a979bd7a
|
|
7
|
+
data.tar.gz: 4b81f2d092784dff65738ea7f1873dbb4c72b70e2fc5cdf3b70f64d8e7e7ed0b44e108ea16966d63e49eb3efa9a0c5a396ed1b5426c6272b97fb9813186f5e29
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,495 @@
|
|
|
1
|
+
## Rails 7.1.5 (October 30, 2024) ##
|
|
2
|
+
|
|
3
|
+
* Fix marshalling of unsaved associated records in 7.1 format.
|
|
4
|
+
|
|
5
|
+
The 7.1 format would only marshal associated records if the association was loaded.
|
|
6
|
+
But associations that would only contain unsaved records would be skipped.
|
|
7
|
+
|
|
8
|
+
*Jean Boussier*
|
|
9
|
+
|
|
10
|
+
* Fix an issue where `.left_outer_joins` used with multiple associations that have
|
|
11
|
+
the same child association but different parents does not join all parents.
|
|
12
|
+
|
|
13
|
+
Previously, using `.left_outer_joins` with the same child association would only join one of the parents.
|
|
14
|
+
|
|
15
|
+
Now it will correctly join both parents.
|
|
16
|
+
|
|
17
|
+
Fixes #41498.
|
|
18
|
+
|
|
19
|
+
*Garrett Blehm*
|
|
20
|
+
|
|
21
|
+
* Ensure `ActiveRecord::Encryption.config` is always ready before access.
|
|
22
|
+
|
|
23
|
+
Previously, `ActiveRecord::Encryption` configuration was deferred until `ActiveRecord::Base`
|
|
24
|
+
was loaded. Therefore, accessing `ActiveRecord::Encryption.config` properties before
|
|
25
|
+
`ActiveRecord::Base` was loaded would give incorrect results.
|
|
26
|
+
|
|
27
|
+
`ActiveRecord::Encryption` now has its own loading hook so that its configuration is set as
|
|
28
|
+
soon as needed.
|
|
29
|
+
|
|
30
|
+
When `ActiveRecord::Base` is loaded, even lazily, it in turn triggers the loading of
|
|
31
|
+
`ActiveRecord::Encryption`, thus preserving the original behavior of having its config ready
|
|
32
|
+
before any use of `ActiveRecord::Base`.
|
|
33
|
+
|
|
34
|
+
*Maxime Réty*
|
|
35
|
+
|
|
36
|
+
* Add `TimeZoneConverter#==` method, so objects will be properly compared by
|
|
37
|
+
their type, scale, limit & precision.
|
|
38
|
+
|
|
39
|
+
Address #52699.
|
|
40
|
+
|
|
41
|
+
*Ruy Rocha*
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Rails 7.1.4.2 (October 23, 2024) ##
|
|
45
|
+
|
|
46
|
+
* No changes.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## Rails 7.1.4.1 (October 15, 2024) ##
|
|
50
|
+
|
|
51
|
+
* No changes.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Rails 7.1.4 (August 22, 2024) ##
|
|
55
|
+
|
|
56
|
+
* Allow to eager load nested nil associations.
|
|
57
|
+
|
|
58
|
+
*fatkodima*
|
|
59
|
+
|
|
60
|
+
* Fix `create_table` with `:auto_increment` option for MySQL adapter.
|
|
61
|
+
|
|
62
|
+
*fatkodima*
|
|
63
|
+
|
|
64
|
+
* Don't load has_one associations during autosave.
|
|
65
|
+
|
|
66
|
+
*Eugene Kenny*
|
|
67
|
+
|
|
68
|
+
* Fix migration ordering for `bin/rails db:prepare` across databases.
|
|
69
|
+
|
|
70
|
+
*fatkodima*
|
|
71
|
+
|
|
72
|
+
* Fix `alias_attribute` to ignore methods defined in parent classes.
|
|
73
|
+
|
|
74
|
+
*Jean Boussier*
|
|
75
|
+
|
|
76
|
+
* Fix a performance regression in attribute methods.
|
|
77
|
+
|
|
78
|
+
*Jean Boussier*
|
|
79
|
+
|
|
80
|
+
* Fix Active Record configs variable shadowing.
|
|
81
|
+
|
|
82
|
+
*Joel Lubrano*
|
|
83
|
+
|
|
84
|
+
* Fix running migrations on other databases when `database_tasks: false` on primary.
|
|
85
|
+
|
|
86
|
+
*fatkodima*
|
|
87
|
+
|
|
88
|
+
* Fix non-partial inserts for models with composite identity primary keys.
|
|
89
|
+
|
|
90
|
+
*fatkodima*
|
|
91
|
+
|
|
92
|
+
* Fix `ActiveRecord::Relation#touch_all` with custom attribute aliased as attribute for update.
|
|
93
|
+
|
|
94
|
+
*fatkodima*
|
|
95
|
+
|
|
96
|
+
* Fix a crash when an Executor wrapped fork exit.
|
|
97
|
+
|
|
98
|
+
*Joé Dupuis*
|
|
99
|
+
|
|
100
|
+
* Fix `destroy_async` job for owners with composite primary keys.
|
|
101
|
+
|
|
102
|
+
*fatkodima*
|
|
103
|
+
|
|
104
|
+
* Ensure pre-7.1 migrations use legacy index names when using `rename_table`.
|
|
105
|
+
|
|
106
|
+
*fatkodima*
|
|
107
|
+
|
|
108
|
+
* Allow `primary_key:` association option to be composite.
|
|
109
|
+
|
|
110
|
+
*Nikita Vasilevsky*
|
|
111
|
+
|
|
112
|
+
* Do not try to alias on key update when raw SQL is supplied.
|
|
113
|
+
|
|
114
|
+
*Gabriel Amaral*
|
|
115
|
+
|
|
116
|
+
* Memoize `key_provider` from `key` or deterministic `key_provider` if any.
|
|
117
|
+
|
|
118
|
+
*Rosa Gutierrez*
|
|
119
|
+
|
|
120
|
+
* Fix `upsert` warning for MySQL.
|
|
121
|
+
|
|
122
|
+
*fatkodima*
|
|
123
|
+
|
|
124
|
+
* Fix predicate builder for polymorphic models referencing models with composite primary keys.
|
|
125
|
+
|
|
126
|
+
*fatkodima*
|
|
127
|
+
|
|
128
|
+
* Fix `update_all/delete_all` on CPK model relation with join subquery.
|
|
129
|
+
|
|
130
|
+
*Nikita Vasilevsky*
|
|
131
|
+
|
|
132
|
+
* Remove memoization to accept `key_provider` overridden by `with_encryption_context`.
|
|
133
|
+
|
|
134
|
+
*John Hawthorn*
|
|
135
|
+
|
|
136
|
+
* Raise error for Trilogy when prepared_statements is true.
|
|
137
|
+
|
|
138
|
+
Trilogy doesn't currently support prepared statements. The error that
|
|
139
|
+
applications would see is a `StatementInvalid` error. This doesn't quite point
|
|
140
|
+
you to the fact this isn't supported. So raise a more appropriate error
|
|
141
|
+
pointing to what to change.
|
|
142
|
+
|
|
143
|
+
*Eileen M. Uchitelle*
|
|
144
|
+
|
|
145
|
+
* Fix loading schema cache when all databases have disabled database tasks.
|
|
146
|
+
|
|
147
|
+
*fatkodima*
|
|
148
|
+
|
|
149
|
+
* Always request `primary_key` in `RETURNING` if no other columns requested.
|
|
150
|
+
|
|
151
|
+
*Nikita Vasilevsky*
|
|
152
|
+
|
|
153
|
+
* Handle records being loaded with Marshal without triggering schema load
|
|
154
|
+
|
|
155
|
+
When using the old marshalling format for Active Record and loading
|
|
156
|
+
a serialized instance, it didn't trigger loading the schema and defining
|
|
157
|
+
attribute methods.
|
|
158
|
+
|
|
159
|
+
*Jean Boussier*
|
|
160
|
+
|
|
161
|
+
* Prevent some constant redefinition warnings when defining `inherited` on models.
|
|
162
|
+
|
|
163
|
+
*Adrian Hirt*
|
|
164
|
+
|
|
165
|
+
* Fix a memory perfomance regression in attribute methods.
|
|
166
|
+
|
|
167
|
+
Attribute methods used much more memory and were slower to define than
|
|
168
|
+
they should have been.
|
|
169
|
+
|
|
170
|
+
*Jean Boussier*
|
|
171
|
+
|
|
172
|
+
* Fix an issue that could cause database connection leaks.
|
|
173
|
+
|
|
174
|
+
If Active Record successfully connected to the database, but then failed
|
|
175
|
+
to read the server informations, the connection would be leaked until the
|
|
176
|
+
Ruby garbage collector triggers.
|
|
177
|
+
|
|
178
|
+
*Jean Boussier*
|
|
179
|
+
|
|
180
|
+
* Fix an issue where the IDs reader method did not return expected results
|
|
181
|
+
for preloaded associations in models using composite primary keys.
|
|
182
|
+
|
|
183
|
+
*Jay Ang*
|
|
184
|
+
|
|
185
|
+
* PostgreSQL `Cidr#change?` detects the address prefix change.
|
|
186
|
+
|
|
187
|
+
*Taketo Takashima*
|
|
188
|
+
|
|
189
|
+
* Fix Active Record serialization to not include instantiated but not loaded associations
|
|
190
|
+
|
|
191
|
+
*Jean Boussier*, *Ben Kyriakou*
|
|
192
|
+
|
|
193
|
+
* Allow `Sqlite3Adapter` to use `sqlite3` gem version `2.x`
|
|
194
|
+
|
|
195
|
+
*Mike Dalessio*
|
|
196
|
+
|
|
197
|
+
* Strict loading using `:n_plus_one_only` does not eagerly load child associations.
|
|
198
|
+
|
|
199
|
+
With this change, child associations are no longer eagerly loaded, to
|
|
200
|
+
match intended behavior and to prevent non-deterministic order issues caused
|
|
201
|
+
by calling methods like `first` or `last`. As `first` and `last` don't cause
|
|
202
|
+
an N+1 by themselves, calling child associations will no longer raise.
|
|
203
|
+
Fixes #49473.
|
|
204
|
+
|
|
205
|
+
Before:
|
|
206
|
+
|
|
207
|
+
```ruby
|
|
208
|
+
person = Person.find(1)
|
|
209
|
+
person.strict_loading!(mode: :n_plus_one_only)
|
|
210
|
+
person.posts.first
|
|
211
|
+
# SELECT * FROM posts WHERE person_id = 1; -- non-deterministic order
|
|
212
|
+
person.posts.first.firm # raises ActiveRecord::StrictLoadingViolationError
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
After:
|
|
216
|
+
|
|
217
|
+
```ruby
|
|
218
|
+
person = Person.find(1)
|
|
219
|
+
person.strict_loading!(mode: :n_plus_one_only)
|
|
220
|
+
person.posts.first # this is 1+1, not N+1
|
|
221
|
+
# SELECT * FROM posts WHERE person_id = 1 ORDER BY id LIMIT 1;
|
|
222
|
+
person.posts.first.firm # no longer raises
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
*Reid Lynch*
|
|
226
|
+
|
|
227
|
+
* Using `Model.query_constraints` with a single non-primary-key column used to raise as expected, but with an
|
|
228
|
+
incorrect error message. This has been fixed to raise with a more appropriate error message.
|
|
229
|
+
|
|
230
|
+
*Joshua Young*
|
|
231
|
+
|
|
232
|
+
* Fix `has_one` association autosave setting the foreign key attribute when it is unchanged.
|
|
233
|
+
|
|
234
|
+
This behaviour is also inconsistent with autosaving `belongs_to` and can have unintended side effects like raising
|
|
235
|
+
an `ActiveRecord::ReadonlyAttributeError` when the foreign key attribute is marked as read-only.
|
|
236
|
+
|
|
237
|
+
*Joshua Young*
|
|
238
|
+
|
|
239
|
+
* Fix an issue where `ActiveRecord::Encryption` configurations are not ready before the loading
|
|
240
|
+
of Active Record models, when an application is eager loaded. As a result, encrypted attributes
|
|
241
|
+
could be misconfigured in some cases.
|
|
242
|
+
|
|
243
|
+
*Maxime Réty*
|
|
244
|
+
|
|
245
|
+
* Properly synchronize `Mysql2Adapter#active?` and `TrilogyAdapter#active?`
|
|
246
|
+
|
|
247
|
+
As well as `disconnect!` and `verify!`.
|
|
248
|
+
|
|
249
|
+
This generally isn't a big problem as connections must not be shared between
|
|
250
|
+
threads, but is required when running transactional tests or system tests
|
|
251
|
+
and could lead to a SEGV.
|
|
252
|
+
|
|
253
|
+
*Jean Boussier*
|
|
254
|
+
|
|
255
|
+
* Fix counter caches when the foreign key is composite.
|
|
256
|
+
|
|
257
|
+
If the model holding the counter cache had a composite primary key,
|
|
258
|
+
inserting a dependent record would fail with an `ArgumentError`
|
|
259
|
+
`Expected corresponding value for...`
|
|
260
|
+
|
|
261
|
+
*fatkodima*
|
|
262
|
+
|
|
263
|
+
* Fix loading of schema cache for multiple databases.
|
|
264
|
+
|
|
265
|
+
Before this change, if you have multiple databases configured in your
|
|
266
|
+
application, and had schema cache present, Rails would load the same
|
|
267
|
+
cache to all databases.
|
|
268
|
+
|
|
269
|
+
*Rafael Mendonça França*
|
|
270
|
+
|
|
271
|
+
* Fix eager loading of composite primary key associations.
|
|
272
|
+
|
|
273
|
+
`relation.eager_load(:other_model)` could load the wrong records if `other_model`
|
|
274
|
+
had a composite primary key.
|
|
275
|
+
|
|
276
|
+
*Nikita Vasilevsky*
|
|
277
|
+
|
|
278
|
+
* Fix async queries returning a doubly wrapped result when hitting the query cache.
|
|
279
|
+
|
|
280
|
+
*fatkodima*
|
|
281
|
+
|
|
282
|
+
* Fix single quote escapes on default generated MySQL columns
|
|
283
|
+
|
|
284
|
+
MySQL 5.7.5+ supports generated columns, which can be used to create a column that is computed from an expression.
|
|
285
|
+
|
|
286
|
+
Previously, the schema dump would output a string with double escapes for generated columns with single quotes in the default expression.
|
|
287
|
+
|
|
288
|
+
This would result in issues when importing the schema on a fresh instance of a MySQL database.
|
|
289
|
+
|
|
290
|
+
Now, the string will not be escaped and will be valid Ruby upon importing of the schema.
|
|
291
|
+
|
|
292
|
+
*Yash Kapadia*
|
|
293
|
+
|
|
294
|
+
* Fix Migrations with versions older than 7.1 validating options given to
|
|
295
|
+
`t.references`.
|
|
296
|
+
|
|
297
|
+
*Hartley McGuire*
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
## Rails 7.1.3.4 (June 04, 2024) ##
|
|
301
|
+
|
|
302
|
+
* No changes.
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
## Rails 7.1.3.3 (May 16, 2024) ##
|
|
306
|
+
|
|
307
|
+
* No changes.
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
## Rails 7.1.3.2 (February 21, 2024) ##
|
|
311
|
+
|
|
312
|
+
* No changes.
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
## Rails 7.1.3.1 (February 21, 2024) ##
|
|
316
|
+
|
|
317
|
+
* No changes.
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
## Rails 7.1.3 (January 16, 2024) ##
|
|
321
|
+
|
|
322
|
+
* Fix Migrations with versions older than 7.1 validating options given to
|
|
323
|
+
`add_reference`.
|
|
324
|
+
|
|
325
|
+
*Hartley McGuire*
|
|
326
|
+
|
|
327
|
+
* Ensure `reload` sets correct owner for each association.
|
|
328
|
+
|
|
329
|
+
*Dmytro Savochkin*
|
|
330
|
+
|
|
331
|
+
* Fix view runtime for controllers with async queries.
|
|
332
|
+
|
|
333
|
+
*fatkodima*
|
|
334
|
+
|
|
335
|
+
* Fix `load_async` to work with query cache.
|
|
336
|
+
|
|
337
|
+
*fatkodima*
|
|
338
|
+
|
|
339
|
+
* Fix polymorphic `belongs_to` to correctly use parent's `query_constraints`.
|
|
340
|
+
|
|
341
|
+
*fatkodima*
|
|
342
|
+
|
|
343
|
+
* Fix `Preloader` to not generate a query for already loaded association with `query_constraints`.
|
|
344
|
+
|
|
345
|
+
*fatkodima*
|
|
346
|
+
|
|
347
|
+
* Fix multi-database polymorphic preloading with equivalent table names.
|
|
348
|
+
|
|
349
|
+
When preloading polymorphic associations, if two models pointed to two
|
|
350
|
+
tables with the same name but located in different databases, the
|
|
351
|
+
preloader would only load one.
|
|
352
|
+
|
|
353
|
+
*Ari Summer*
|
|
354
|
+
|
|
355
|
+
* Fix `encrypted_attribute?` to take into account context properties passed to `encrypts`.
|
|
356
|
+
|
|
357
|
+
*Maxime Réty*
|
|
358
|
+
|
|
359
|
+
* Fix `find_by` to work correctly in presence of composite primary keys.
|
|
360
|
+
|
|
361
|
+
*fatkodima*
|
|
362
|
+
|
|
363
|
+
* Fix async queries sometimes returning a raw result if they hit the query cache.
|
|
364
|
+
|
|
365
|
+
`ShipPart.async_count` could return a raw integer rather than a Promise
|
|
366
|
+
if it found the result in the query cache.
|
|
367
|
+
|
|
368
|
+
*fatkodima*
|
|
369
|
+
|
|
370
|
+
* Fix `Relation#transaction` to not apply a default scope.
|
|
371
|
+
|
|
372
|
+
The method was incorrectly setting a default scope around its block:
|
|
373
|
+
|
|
374
|
+
```ruby
|
|
375
|
+
Post.where(published: true).transaction do
|
|
376
|
+
Post.count # SELECT COUNT(*) FROM posts WHERE published = FALSE;
|
|
377
|
+
end
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
*Jean Boussier*
|
|
381
|
+
|
|
382
|
+
* Fix calling `async_pluck` on a `none` relation.
|
|
383
|
+
|
|
384
|
+
`Model.none.async_pluck(:id)` was returning a naked value
|
|
385
|
+
instead of a promise.
|
|
386
|
+
|
|
387
|
+
*Jean Boussier*
|
|
388
|
+
|
|
389
|
+
* Fix calling `load_async` on a `none` relation.
|
|
390
|
+
|
|
391
|
+
`Model.none.load_async` was returning a broken result.
|
|
392
|
+
|
|
393
|
+
*Lucas Mazza*
|
|
394
|
+
|
|
395
|
+
* TrilogyAdapter: ignore `host` if `socket` parameter is set.
|
|
396
|
+
|
|
397
|
+
This allows to configure a connection on a UNIX socket via DATABASE_URL:
|
|
398
|
+
|
|
399
|
+
```
|
|
400
|
+
DATABASE_URL=trilogy://does-not-matter/my_db_production?socket=/var/run/mysql.sock
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
*Jean Boussier*
|
|
404
|
+
|
|
405
|
+
* Fix `has_secure_token` calls the setter method on initialize.
|
|
406
|
+
|
|
407
|
+
*Abeid Ahmed*
|
|
408
|
+
|
|
409
|
+
* Allow using `object_id` as a database column name.
|
|
410
|
+
It was available before rails 7.1 and may be used as a part of polymorphic relationship to `object` where `object` can be any other database record.
|
|
411
|
+
|
|
412
|
+
*Mikhail Doronin*
|
|
413
|
+
|
|
414
|
+
* Fix `rails db:create:all` to not touch databases before they are created.
|
|
415
|
+
|
|
416
|
+
*fatkodima*
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
## Rails 7.1.2 (November 10, 2023) ##
|
|
420
|
+
|
|
421
|
+
* Fix renaming primary key index when renaming a table with a UUID primary key
|
|
422
|
+
in PostgreSQL.
|
|
423
|
+
|
|
424
|
+
*fatkodima*
|
|
425
|
+
|
|
426
|
+
* Fix `where(field: values)` queries when `field` is a serialized attribute
|
|
427
|
+
(for example, when `field` uses `ActiveRecord::Base.serialize` or is a JSON
|
|
428
|
+
column).
|
|
429
|
+
|
|
430
|
+
*João Alves*
|
|
431
|
+
|
|
432
|
+
* Prevent marking broken connections as verified.
|
|
433
|
+
|
|
434
|
+
*Daniel Colson*
|
|
435
|
+
|
|
436
|
+
* Don't mark Float::INFINITY as changed when reassigning it
|
|
437
|
+
|
|
438
|
+
When saving a record with a float infinite value, it shouldn't mark as changed
|
|
439
|
+
|
|
440
|
+
*Maicol Bentancor*
|
|
441
|
+
|
|
442
|
+
* `ActiveRecord::Base.table_name` now returns `nil` instead of raising
|
|
443
|
+
"undefined method `abstract_class?` for Object:Class".
|
|
444
|
+
|
|
445
|
+
*a5-stable*
|
|
446
|
+
|
|
447
|
+
* Fix upserting for custom `:on_duplicate` and `:unique_by` consisting of all
|
|
448
|
+
inserts keys.
|
|
449
|
+
|
|
450
|
+
*fatkodima*
|
|
451
|
+
|
|
452
|
+
* Fixed an [issue](https://github.com/rails/rails/issues/49809) where saving a
|
|
453
|
+
record could innappropriately `dup` its attributes.
|
|
454
|
+
|
|
455
|
+
*Jonathan Hefner*
|
|
456
|
+
|
|
457
|
+
* Dump schema only for a specific db for rollback/up/down tasks for multiple dbs.
|
|
458
|
+
|
|
459
|
+
*fatkodima*
|
|
460
|
+
|
|
461
|
+
* Fix `NoMethodError` when casting a PostgreSQL `money` value that uses a
|
|
462
|
+
comma as its radix point and has no leading currency symbol. For example,
|
|
463
|
+
when casting `"3,50"`.
|
|
464
|
+
|
|
465
|
+
*Andreas Reischuck* and *Jonathan Hefner*
|
|
466
|
+
|
|
467
|
+
* Re-enable support for using `enum` with non-column-backed attributes.
|
|
468
|
+
Non-column-backed attributes must be previously declared with an explicit
|
|
469
|
+
type. For example:
|
|
470
|
+
|
|
471
|
+
```ruby
|
|
472
|
+
class Post < ActiveRecord::Base
|
|
473
|
+
attribute :topic, :string
|
|
474
|
+
enum topic: %i[science tech engineering math]
|
|
475
|
+
end
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
*Jonathan Hefner*
|
|
479
|
+
|
|
480
|
+
* Raise on `foreign_key:` being passed as an array in associations
|
|
481
|
+
|
|
482
|
+
*Nikita Vasilevsky*
|
|
483
|
+
|
|
484
|
+
* Return back maximum allowed PostgreSQL table name to 63 characters.
|
|
485
|
+
|
|
486
|
+
*fatkodima*
|
|
487
|
+
|
|
488
|
+
* Fix detecting `IDENTITY` columns for PostgreSQL < 10.
|
|
489
|
+
|
|
490
|
+
*fatkodima*
|
|
491
|
+
|
|
492
|
+
|
|
1
493
|
## Rails 7.1.1 (October 11, 2023) ##
|
|
2
494
|
|
|
3
495
|
* Fix auto populating IDENTITY columns for PostgreSQL.
|
|
@@ -165,6 +657,10 @@
|
|
|
165
657
|
|
|
166
658
|
*Adam Hess*
|
|
167
659
|
|
|
660
|
+
* Deprecate aliasing non-attributes with `alias_attribute`.
|
|
661
|
+
|
|
662
|
+
*Ian Candy*
|
|
663
|
+
|
|
168
664
|
* Fix unscope is not working in specific case
|
|
169
665
|
|
|
170
666
|
Before:
|
data/README.rdoc
CHANGED
|
@@ -166,6 +166,7 @@ Active Record is an implementation of the object-relational mapping (ORM)
|
|
|
166
166
|
pattern[https://www.martinfowler.com/eaaCatalog/activeRecord.html] by the same
|
|
167
167
|
name described by Martin Fowler:
|
|
168
168
|
|
|
169
|
+
>>>
|
|
169
170
|
"An object that wraps a row in a database table or view,
|
|
170
171
|
encapsulates the database access, and adds domain logic on that data."
|
|
171
172
|
|
|
@@ -33,7 +33,8 @@ module ActiveRecord
|
|
|
33
33
|
# <tt>owner</tt>, the collection of its posts as <tt>target</tt>, and
|
|
34
34
|
# the <tt>reflection</tt> object represents a <tt>:has_many</tt> macro.
|
|
35
35
|
class Association # :nodoc:
|
|
36
|
-
|
|
36
|
+
attr_accessor :owner
|
|
37
|
+
attr_reader :target, :reflection, :disable_joins
|
|
37
38
|
|
|
38
39
|
delegate :options, to: :reflection
|
|
39
40
|
|
|
@@ -12,11 +12,11 @@ module ActiveRecord
|
|
|
12
12
|
raise ActiveRecord::Rollback unless target.destroy
|
|
13
13
|
when :destroy_async
|
|
14
14
|
if reflection.foreign_key.is_a?(Array)
|
|
15
|
-
primary_key_column = reflection.active_record_primary_key
|
|
16
|
-
id = reflection.foreign_key.map { |col| owner.public_send(col
|
|
15
|
+
primary_key_column = reflection.active_record_primary_key
|
|
16
|
+
id = reflection.foreign_key.map { |col| owner.public_send(col) }
|
|
17
17
|
else
|
|
18
|
-
primary_key_column = reflection.active_record_primary_key
|
|
19
|
-
id = owner.public_send(reflection.foreign_key
|
|
18
|
+
primary_key_column = reflection.active_record_primary_key
|
|
19
|
+
id = owner.public_send(reflection.foreign_key)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
enqueue_destroy_association(
|
|
@@ -48,11 +48,11 @@ module ActiveRecord
|
|
|
48
48
|
# Implements the ids reader method, e.g. foo.item_ids for Foo.has_many :items
|
|
49
49
|
def ids_reader
|
|
50
50
|
if loaded?
|
|
51
|
-
target.pluck(reflection.association_primary_key)
|
|
51
|
+
target.pluck(*reflection.association_primary_key)
|
|
52
52
|
elsif !target.empty?
|
|
53
|
-
load_target.pluck(reflection.association_primary_key)
|
|
53
|
+
load_target.pluck(*reflection.association_primary_key)
|
|
54
54
|
else
|
|
55
|
-
@association_ids ||= scope.pluck(reflection.association_primary_key)
|
|
55
|
+
@association_ids ||= scope.pluck(*reflection.association_primary_key)
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -303,7 +303,7 @@ module ActiveRecord
|
|
|
303
303
|
|
|
304
304
|
def find_from_target?
|
|
305
305
|
loaded? ||
|
|
306
|
-
owner.strict_loading? ||
|
|
306
|
+
(owner.strict_loading? && owner.strict_loading_all?) ||
|
|
307
307
|
reflection.strict_loading? ||
|
|
308
308
|
owner.new_record? ||
|
|
309
309
|
target.any? { |record| record.new_record? || record.changed? }
|
|
@@ -35,10 +35,10 @@ module ActiveRecord
|
|
|
35
35
|
unless target.empty?
|
|
36
36
|
association_class = target.first.class
|
|
37
37
|
if association_class.query_constraints_list
|
|
38
|
-
primary_key_column = association_class.query_constraints_list
|
|
38
|
+
primary_key_column = association_class.query_constraints_list
|
|
39
39
|
ids = target.collect { |assoc| primary_key_column.map { |col| assoc.public_send(col) } }
|
|
40
40
|
else
|
|
41
|
-
primary_key_column = association_class.primary_key
|
|
41
|
+
primary_key_column = association_class.primary_key
|
|
42
42
|
ids = target.collect { |assoc| assoc.public_send(primary_key_column) }
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -34,10 +34,10 @@ module ActiveRecord
|
|
|
34
34
|
throw(:abort) unless target.destroyed?
|
|
35
35
|
when :destroy_async
|
|
36
36
|
if target.class.query_constraints_list
|
|
37
|
-
primary_key_column = target.class.query_constraints_list
|
|
37
|
+
primary_key_column = target.class.query_constraints_list
|
|
38
38
|
id = primary_key_column.map { |col| target.public_send(col) }
|
|
39
39
|
else
|
|
40
|
-
primary_key_column = target.class.primary_key
|
|
40
|
+
primary_key_column = target.class.primary_key
|
|
41
41
|
id = target.public_send(primary_key_column)
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -25,8 +25,9 @@ module ActiveRecord
|
|
|
25
25
|
joins = []
|
|
26
26
|
chain = []
|
|
27
27
|
|
|
28
|
-
reflection.chain
|
|
29
|
-
|
|
28
|
+
reflection_chain = reflection.chain
|
|
29
|
+
reflection_chain.each_with_index do |reflection, index|
|
|
30
|
+
table, terminated = yield reflection, reflection_chain[index..]
|
|
30
31
|
@table ||= table
|
|
31
32
|
|
|
32
33
|
if terminated
|
|
@@ -61,7 +61,7 @@ module ActiveRecord
|
|
|
61
61
|
when Hash
|
|
62
62
|
associations.each do |k, v|
|
|
63
63
|
cache = hash[k] ||= {}
|
|
64
|
-
walk_tree v, cache
|
|
64
|
+
walk_tree v, cache if v
|
|
65
65
|
end
|
|
66
66
|
else
|
|
67
67
|
raise ConfigurationError, associations.inspect
|
|
@@ -190,12 +190,12 @@ module ActiveRecord
|
|
|
190
190
|
def make_constraints(parent, child, join_type)
|
|
191
191
|
foreign_table = parent.table
|
|
192
192
|
foreign_klass = parent.base_klass
|
|
193
|
-
child.join_constraints(foreign_table, foreign_klass, join_type, alias_tracker) do |reflection|
|
|
194
|
-
table, terminated = @joined_tables[
|
|
193
|
+
child.join_constraints(foreign_table, foreign_klass, join_type, alias_tracker) do |reflection, remaining_reflection_chain|
|
|
194
|
+
table, terminated = @joined_tables[remaining_reflection_chain]
|
|
195
195
|
root = reflection == child.reflection
|
|
196
196
|
|
|
197
197
|
if table && (!root || !terminated)
|
|
198
|
-
@joined_tables[
|
|
198
|
+
@joined_tables[remaining_reflection_chain] = [table, root] if root
|
|
199
199
|
next table, true
|
|
200
200
|
end
|
|
201
201
|
|
|
@@ -206,7 +206,7 @@ module ActiveRecord
|
|
|
206
206
|
root ? name : "#{name}_join"
|
|
207
207
|
end
|
|
208
208
|
|
|
209
|
-
@joined_tables[
|
|
209
|
+
@joined_tables[remaining_reflection_chain] ||= [table, root] if join_type == Arel::Nodes::OuterJoin
|
|
210
210
|
table
|
|
211
211
|
end.concat child.children.flat_map { |c| make_constraints(child, c, join_type) }
|
|
212
212
|
end
|
|
@@ -254,10 +254,10 @@ module ActiveRecord
|
|
|
254
254
|
|
|
255
255
|
if node.primary_key
|
|
256
256
|
keys = Array(node.primary_key).map { |column| aliases.column_alias(node, column) }
|
|
257
|
-
|
|
257
|
+
id = keys.map { |key| row[key] }
|
|
258
258
|
else
|
|
259
259
|
keys = Array(node.reflection.join_primary_key).map { |column| aliases.column_alias(node, column.to_s) }
|
|
260
|
-
|
|
260
|
+
id = keys.map { nil } # Avoid id-based model caching.
|
|
261
261
|
end
|
|
262
262
|
|
|
263
263
|
if keys.any? { |key| row[key].nil? }
|
|
@@ -266,11 +266,9 @@ module ActiveRecord
|
|
|
266
266
|
next
|
|
267
267
|
end
|
|
268
268
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
seen[ar_parent][node][id] = model if id
|
|
273
|
-
end
|
|
269
|
+
unless model = seen[ar_parent][node][id]
|
|
270
|
+
model = construct_model(ar_parent, node, row, model_cache, id, strict_loading_value)
|
|
271
|
+
seen[ar_parent][node][id] = model if id
|
|
274
272
|
end
|
|
275
273
|
|
|
276
274
|
construct(model, node, row, seen, model_cache, strict_loading_value)
|