activerecord 6.1.0 → 6.1.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +433 -26
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/active_record/aggregations.rb +4 -4
- data/lib/active_record/association_relation.rb +10 -0
- data/lib/active_record/associations/association.rb +13 -7
- data/lib/active_record/associations/association_scope.rb +7 -5
- data/lib/active_record/associations/belongs_to_association.rb +8 -5
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +7 -2
- data/lib/active_record/associations/builder/association.rb +23 -2
- data/lib/active_record/associations/builder/belongs_to.rb +2 -2
- data/lib/active_record/associations/collection_association.rb +16 -8
- data/lib/active_record/associations/has_many_association.rb +1 -1
- data/lib/active_record/associations/join_dependency/join_association.rb +8 -7
- data/lib/active_record/associations/join_dependency.rb +1 -1
- data/lib/active_record/associations/preloader/association.rb +1 -3
- data/lib/active_record/associations.rb +6 -2
- data/lib/active_record/attributes.rb +1 -1
- data/lib/active_record/coders/yaml_column.rb +11 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +5 -5
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/quoting.rb +3 -3
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +4 -0
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +7 -1
- data/lib/active_record/connection_adapters/abstract/transaction.rb +14 -3
- data/lib/active_record/connection_adapters/abstract_adapter.rb +10 -11
- data/lib/active_record/connection_adapters/legacy_pool_manager.rb +6 -2
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +2 -0
- data/lib/active_record/connection_adapters/mysql/quoting.rb +17 -2
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +4 -1
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +4 -1
- data/lib/active_record/connection_adapters/pool_config.rb +13 -3
- data/lib/active_record/connection_adapters/pool_manager.rb +5 -1
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +2 -8
- data/lib/active_record/connection_adapters/schema_cache.rb +43 -11
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +0 -2
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +2 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -1
- data/lib/active_record/connection_adapters.rb +2 -0
- data/lib/active_record/connection_handling.rb +22 -14
- data/lib/active_record/core.rb +60 -31
- data/lib/active_record/database_configurations/connection_url_resolver.rb +1 -0
- data/lib/active_record/database_configurations/hash_config.rb +1 -1
- data/lib/active_record/database_configurations/url_config.rb +1 -1
- data/lib/active_record/database_configurations.rb +2 -1
- data/lib/active_record/enum.rb +52 -34
- data/lib/active_record/fixtures.rb +5 -2
- data/lib/active_record/gem_version.rb +1 -1
- data/lib/active_record/insert_all.rb +5 -1
- data/lib/active_record/internal_metadata.rb +2 -0
- data/lib/active_record/legacy_yaml_adapter.rb +1 -1
- data/lib/active_record/locking/optimistic.rb +14 -4
- data/lib/active_record/log_subscriber.rb +3 -2
- data/lib/active_record/migration/compatibility.rb +24 -1
- data/lib/active_record/migration.rb +1 -1
- data/lib/active_record/model_schema.rb +5 -5
- data/lib/active_record/railties/console_sandbox.rb +2 -4
- data/lib/active_record/railties/databases.rake +24 -17
- data/lib/active_record/reflection.rb +1 -1
- data/lib/active_record/relation/calculations.rb +8 -4
- data/lib/active_record/relation/finder_methods.rb +2 -2
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +3 -3
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +9 -5
- data/lib/active_record/relation/predicate_builder.rb +5 -6
- data/lib/active_record/relation/query_methods.rb +11 -8
- data/lib/active_record/relation/where_clause.rb +19 -16
- data/lib/active_record/relation.rb +10 -17
- data/lib/active_record/scoping/default.rb +1 -3
- data/lib/active_record/signed_id.rb +1 -1
- data/lib/active_record/statement_cache.rb +2 -2
- data/lib/active_record/table_metadata.rb +6 -3
- data/lib/active_record/tasks/database_tasks.rb +2 -1
- data/lib/active_record/test_fixtures.rb +42 -1
- data/lib/active_record/transactions.rb +4 -2
- data/lib/active_record/validations/numericality.rb +1 -1
- data/lib/active_record.rb +1 -1
- data/lib/arel/collectors/bind.rb +2 -2
- data/lib/arel/collectors/composite.rb +3 -3
- data/lib/arel/collectors/sql_string.rb +1 -1
- data/lib/arel/collectors/substitute_binds.rb +1 -1
- data/lib/arel/nodes/homogeneous_in.rb +4 -0
- data/lib/arel/predications.rb +2 -2
- data/lib/arel/visitors/to_sql.rb +1 -1
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 726b98d501c1bb19481f8961894653a362e7ee0bd9993c35ef25e9ad4d76ccf4
|
4
|
+
data.tar.gz: f479e8a86f16437cf977c04a0bb6f69783281176eeedb955348634114876b6c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 917b3e5292fa4e7927994fcab3f6b6c07d9615c8c755e1f4950a55bcf5d9232c53f116ceee41ba63d7f6bdf23bc9b3f0e778edfd102aa6327808374fdb8e1ba0
|
7
|
+
data.tar.gz: e772cf960f0a2c361cd2701b7ac765cefc86336bcf353741dc8dd4c56937db0392ba41b762ca9d26879702fbf74f2ff10197235715b0b7aa3b69e83e2fba1ca8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,410 @@
|
|
1
|
+
## Rails 6.1.5 (March 09, 2022) ##
|
2
|
+
|
3
|
+
* Fix `ActiveRecord::ConnectionAdapters::SchemaCache#deep_deduplicate` for Ruby 2.6.
|
4
|
+
|
5
|
+
Ruby 2.6 and 2.7 have slightly different implementations of the `String#@-` method.
|
6
|
+
In Ruby 2.6, the receiver of the `String#@-` method is modified under certain circumstances.
|
7
|
+
This was later identified as a bug (https://bugs.ruby-lang.org/issues/15926) and only
|
8
|
+
fixed in Ruby 2.7.
|
9
|
+
|
10
|
+
Before the changes in this commit, the
|
11
|
+
`ActiveRecord::ConnectionAdapters::SchemaCache#deep_deduplicate` method, which internally
|
12
|
+
calls the `String#@-` method, could also modify an input string argument in Ruby 2.6 --
|
13
|
+
changing a tainted, unfrozen string into a tainted, frozen string.
|
14
|
+
|
15
|
+
Fixes #43056
|
16
|
+
|
17
|
+
*Eric O'Hanlon*
|
18
|
+
|
19
|
+
* Fix migration compatibility to create SQLite references/belongs_to column as integer when
|
20
|
+
migration version is 6.0.
|
21
|
+
|
22
|
+
`reference`/`belongs_to` in migrations with version 6.0 were creating columns as
|
23
|
+
bigint instead of integer for the SQLite Adapter.
|
24
|
+
|
25
|
+
*Marcelo Lauxen*
|
26
|
+
|
27
|
+
* Fix dbconsole for 3-tier config.
|
28
|
+
|
29
|
+
*Eileen M. Uchitelle*
|
30
|
+
|
31
|
+
* Better handle SQL queries with invalid encoding.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Post.create(name: "broken \xC8 UTF-8")
|
35
|
+
```
|
36
|
+
|
37
|
+
Would cause all adapters to fail in a non controlled way in the code
|
38
|
+
responsible to detect write queries.
|
39
|
+
|
40
|
+
The query is now properly passed to the database connection, which might or might
|
41
|
+
not be able to handle it, but will either succeed or failed in a more correct way.
|
42
|
+
|
43
|
+
*Jean Boussier*
|
44
|
+
|
45
|
+
* Ignore persisted in-memory records when merging target lists.
|
46
|
+
|
47
|
+
*Kevin Sjöberg*
|
48
|
+
|
49
|
+
* Fix regression bug that caused ignoring additional conditions for preloading
|
50
|
+
`has_many` through relations.
|
51
|
+
|
52
|
+
Fixes #43132
|
53
|
+
|
54
|
+
*Alexander Pauly*
|
55
|
+
|
56
|
+
* Fix `ActiveRecord::InternalMetadata` to not be broken by
|
57
|
+
`config.active_record.record_timestamps = false`
|
58
|
+
|
59
|
+
Since the model always create the timestamp columns, it has to set them, otherwise it breaks
|
60
|
+
various DB management tasks.
|
61
|
+
|
62
|
+
Fixes #42983
|
63
|
+
|
64
|
+
*Jean Boussier*
|
65
|
+
|
66
|
+
* Fix duplicate active record objects on `inverse_of`.
|
67
|
+
|
68
|
+
*Justin Carvalho*
|
69
|
+
|
70
|
+
* Fix duplicate objects stored in has many association after save.
|
71
|
+
|
72
|
+
Fixes #42549.
|
73
|
+
|
74
|
+
*Alex Ghiculescu*
|
75
|
+
|
76
|
+
* Fix performance regression in `CollectionAssocation#build`.
|
77
|
+
|
78
|
+
*Alex Ghiculescu*
|
79
|
+
|
80
|
+
* Fix retrieving default value for text column for MariaDB.
|
81
|
+
|
82
|
+
*fatkodima*
|
83
|
+
|
84
|
+
|
85
|
+
## Rails 6.1.4.7 (March 08, 2022) ##
|
86
|
+
|
87
|
+
* No changes.
|
88
|
+
|
89
|
+
|
90
|
+
## Rails 6.1.4.6 (February 11, 2022) ##
|
91
|
+
|
92
|
+
* No changes.
|
93
|
+
|
94
|
+
|
95
|
+
## Rails 6.1.4.5 (February 11, 2022) ##
|
96
|
+
|
97
|
+
* No changes.
|
98
|
+
|
99
|
+
|
100
|
+
## Rails 6.1.4.4 (December 15, 2021) ##
|
101
|
+
|
102
|
+
* No changes.
|
103
|
+
|
104
|
+
|
105
|
+
## Rails 6.1.4.3 (December 14, 2021) ##
|
106
|
+
|
107
|
+
* No changes.
|
108
|
+
|
109
|
+
|
110
|
+
## Rails 6.1.4.2 (December 14, 2021) ##
|
111
|
+
|
112
|
+
* No changes.
|
113
|
+
|
114
|
+
|
115
|
+
## Rails 6.1.4.1 (August 19, 2021) ##
|
116
|
+
|
117
|
+
* No changes.
|
118
|
+
|
119
|
+
|
120
|
+
## Rails 6.1.4 (June 24, 2021) ##
|
121
|
+
|
122
|
+
* Do not try to rollback transactions that failed due to a `ActiveRecord::TransactionRollbackError`.
|
123
|
+
|
124
|
+
*Jamie McCarthy*
|
125
|
+
|
126
|
+
* Raise an error if `pool_config` is `nil` in `set_pool_config`.
|
127
|
+
|
128
|
+
*Eileen M. Uchitelle*
|
129
|
+
|
130
|
+
* Fix compatibility with `psych >= 4`.
|
131
|
+
|
132
|
+
Starting in Psych 4.0.0 `YAML.load` behaves like `YAML.safe_load`. To preserve compatibility
|
133
|
+
Active Record's schema cache loader and `YAMLColumn` now uses `YAML.unsafe_load` if available.
|
134
|
+
|
135
|
+
*Jean Boussier*
|
136
|
+
|
137
|
+
* Support using replicas when using `rails dbconsole`.
|
138
|
+
|
139
|
+
*Christopher Thornton*
|
140
|
+
|
141
|
+
* Restore connection pools after transactional tests.
|
142
|
+
|
143
|
+
*Eugene Kenny*
|
144
|
+
|
145
|
+
* Change `upsert_all` to fails cleanly for MySQL when `:unique_by` is used.
|
146
|
+
|
147
|
+
*Bastian Bartmann*
|
148
|
+
|
149
|
+
* Fix user-defined `self.default_scope` to respect table alias.
|
150
|
+
|
151
|
+
*Ryuta Kamizono*
|
152
|
+
|
153
|
+
* Clear `@cache_keys` cache after `update_all`, `delete_all`, `destroy_all`.
|
154
|
+
|
155
|
+
*Ryuta Kamizono*
|
156
|
+
|
157
|
+
* Changed Arel predications `contains` and `overlaps` to use
|
158
|
+
`quoted_node` so that PostgreSQL arrays are quoted properly.
|
159
|
+
|
160
|
+
*Bradley Priest*
|
161
|
+
|
162
|
+
* Fix `merge` when the `where` clauses have string contents.
|
163
|
+
|
164
|
+
*Ryuta Kamizono*
|
165
|
+
|
166
|
+
* Fix rollback of parent destruction with nested `dependent: :destroy`.
|
167
|
+
|
168
|
+
*Jacopo Beschi*
|
169
|
+
|
170
|
+
* Fix binds logging for `"WHERE ... IN ..."` statements.
|
171
|
+
|
172
|
+
*Ricardo Díaz*
|
173
|
+
|
174
|
+
* Handle `false` in relation strict loading checks.
|
175
|
+
|
176
|
+
Previously when a model had strict loading set to true and then had a
|
177
|
+
relation set `strict_loading` to false the false wasn't considered when
|
178
|
+
deciding whether to raise/warn about strict loading.
|
179
|
+
|
180
|
+
```
|
181
|
+
class Dog < ActiveRecord::Base
|
182
|
+
self.strict_loading_by_default = true
|
183
|
+
|
184
|
+
has_many :treats, strict_loading: false
|
185
|
+
end
|
186
|
+
```
|
187
|
+
|
188
|
+
In the example, `dog.treats` would still raise even though
|
189
|
+
`strict_loading` was set to false. This is a bug affecting more than
|
190
|
+
Active Storage which is why I made this PR superseding #41461. We need
|
191
|
+
to fix this for all applications since the behavior is a little
|
192
|
+
surprising. I took the test from #41461 and the code suggestion from #41453
|
193
|
+
with some additions.
|
194
|
+
|
195
|
+
*Eileen M. Uchitelle*, *Radamés Roriz*
|
196
|
+
|
197
|
+
* Fix numericality validator without precision.
|
198
|
+
|
199
|
+
*Ryuta Kamizono*
|
200
|
+
|
201
|
+
* Fix aggregate attribute on Enum types.
|
202
|
+
|
203
|
+
*Ryuta Kamizono*
|
204
|
+
|
205
|
+
* Fix `CREATE INDEX` statement generation for PostgreSQL.
|
206
|
+
|
207
|
+
*eltongo*
|
208
|
+
|
209
|
+
* Fix where clause on enum attribute when providing array of strings.
|
210
|
+
|
211
|
+
*Ryuta Kamizono*
|
212
|
+
|
213
|
+
* Fix `unprepared_statement` to work it when nesting.
|
214
|
+
|
215
|
+
*Ryuta Kamizono*
|
216
|
+
|
217
|
+
|
218
|
+
## Rails 6.1.3.2 (May 05, 2021) ##
|
219
|
+
|
220
|
+
* No changes.
|
221
|
+
|
222
|
+
|
223
|
+
## Rails 6.1.3.1 (March 26, 2021) ##
|
224
|
+
|
225
|
+
* No changes.
|
226
|
+
|
227
|
+
|
228
|
+
## Rails 6.1.3 (February 17, 2021) ##
|
229
|
+
|
230
|
+
* Fix the MySQL adapter to always set the right collation and charset
|
231
|
+
to the connection session.
|
232
|
+
|
233
|
+
*Rafael Mendonça França*
|
234
|
+
|
235
|
+
* Fix MySQL adapter handling of time objects when prepared statements
|
236
|
+
are enabled.
|
237
|
+
|
238
|
+
*Rafael Mendonça França*
|
239
|
+
|
240
|
+
* Fix scoping in enum fields using conditions that would generate
|
241
|
+
an `IN` clause.
|
242
|
+
|
243
|
+
*Ryuta Kamizono*
|
244
|
+
|
245
|
+
* Skip optimised #exist? query when #include? is called on a relation
|
246
|
+
with a having clause
|
247
|
+
|
248
|
+
Relations that have aliased select values AND a having clause that
|
249
|
+
references an aliased select value would generate an error when
|
250
|
+
#include? was called, due to an optimisation that would generate
|
251
|
+
call #exists? on the relation instead, which effectively alters
|
252
|
+
the select values of the query (and thus removes the aliased select
|
253
|
+
values), but leaves the having clause intact. Because the having
|
254
|
+
clause is then referencing an aliased column that is no longer
|
255
|
+
present in the simplified query, an ActiveRecord::InvalidStatement
|
256
|
+
error was raised.
|
257
|
+
|
258
|
+
An sample query affected by this problem:
|
259
|
+
|
260
|
+
```ruby
|
261
|
+
Author.select('COUNT(*) as total_posts', 'authors.*')
|
262
|
+
.joins(:posts)
|
263
|
+
.group(:id)
|
264
|
+
.having('total_posts > 2')
|
265
|
+
.include?(Author.first)
|
266
|
+
```
|
267
|
+
|
268
|
+
This change adds an addition check to the condition that skips the
|
269
|
+
simplified #exists? query, which simply checks for the presence of
|
270
|
+
a having clause.
|
271
|
+
|
272
|
+
Fixes #41417
|
273
|
+
|
274
|
+
*Michael Smart*
|
275
|
+
|
276
|
+
* Increment postgres prepared statement counter before making a prepared statement, so if the statement is aborted
|
277
|
+
without Rails knowledge (e.g., if app gets kill -9d during long-running query or due to Rack::Timeout), app won't end
|
278
|
+
up in perpetual crash state for being inconsistent with Postgres.
|
279
|
+
|
280
|
+
*wbharding*, *Martin Tepper*
|
281
|
+
|
282
|
+
|
283
|
+
## Rails 6.1.2.1 (February 10, 2021) ##
|
284
|
+
|
285
|
+
* Fix possible DoS vector in PostgreSQL money type
|
286
|
+
|
287
|
+
Carefully crafted input can cause a DoS via the regular expressions used
|
288
|
+
for validating the money format in the PostgreSQL adapter. This patch
|
289
|
+
fixes the regexp.
|
290
|
+
|
291
|
+
Thanks to @dee-see from Hackerone for this patch!
|
292
|
+
|
293
|
+
[CVE-2021-22880]
|
294
|
+
|
295
|
+
*Aaron Patterson*
|
296
|
+
|
297
|
+
|
298
|
+
## Rails 6.1.2 (February 09, 2021) ##
|
299
|
+
|
300
|
+
* Fix timestamp type for sqlite3.
|
301
|
+
|
302
|
+
*Eileen M. Uchitelle*
|
303
|
+
|
304
|
+
* Make destroy async transactional.
|
305
|
+
|
306
|
+
An active record rollback could occur while enqueuing a job. In this
|
307
|
+
case the job would enqueue even though the database deletion
|
308
|
+
rolledback putting things in a funky state.
|
309
|
+
|
310
|
+
Now the jobs are only enqueued until after the db transaction has been committed.
|
311
|
+
|
312
|
+
*Cory Gwin*
|
313
|
+
|
314
|
+
* Fix malformed packet error in MySQL statement for connection configuration.
|
315
|
+
|
316
|
+
*robinroestenburg*
|
317
|
+
|
318
|
+
* Connection specification now passes the "url" key as a configuration for the
|
319
|
+
adapter if the "url" protocol is "jdbc", "http", or "https". Previously only
|
320
|
+
urls with the "jdbc" prefix were passed to the Active Record Adapter, others
|
321
|
+
are assumed to be adapter specification urls.
|
322
|
+
|
323
|
+
Fixes #41137.
|
324
|
+
|
325
|
+
*Jonathan Bracy*
|
326
|
+
|
327
|
+
* Fix granular connection swapping when there are multiple abstract classes.
|
328
|
+
|
329
|
+
*Eileen M. Uchitelle*
|
330
|
+
|
331
|
+
* Fix `find_by` with custom primary key for belongs_to association.
|
332
|
+
|
333
|
+
*Ryuta Kamizono*
|
334
|
+
|
335
|
+
* Add support for `rails console --sandbox` for multiple database applications.
|
336
|
+
|
337
|
+
*alpaca-tc*
|
338
|
+
|
339
|
+
* Fix `where` on polymorphic association with empty array.
|
340
|
+
|
341
|
+
*Ryuta Kamizono*
|
342
|
+
|
343
|
+
* Fix preventing writes for `ApplicationRecord`.
|
344
|
+
|
345
|
+
*Eileen M. Uchitelle*
|
346
|
+
|
347
|
+
|
348
|
+
## Rails 6.1.1 (January 07, 2021) ##
|
349
|
+
|
350
|
+
* Fix fixtures loading when strict loading is enabled for the association.
|
351
|
+
|
352
|
+
*Alex Ghiculescu*
|
353
|
+
|
354
|
+
* Fix `where` with custom primary key for belongs_to association.
|
355
|
+
|
356
|
+
*Ryuta Kamizono*
|
357
|
+
|
358
|
+
* Fix `where` with aliased associations.
|
359
|
+
|
360
|
+
*Ryuta Kamizono*
|
361
|
+
|
362
|
+
* Fix `composed_of` with symbol mapping.
|
363
|
+
|
364
|
+
*Ryuta Kamizono*
|
365
|
+
|
366
|
+
* Don't skip money's type cast for pluck and calculations.
|
367
|
+
|
368
|
+
*Ryuta Kamizono*
|
369
|
+
|
370
|
+
* Fix `where` on polymorphic association with non Active Record object.
|
371
|
+
|
372
|
+
*Ryuta Kamizono*
|
373
|
+
|
374
|
+
* Make sure `db:prepare` works even the schema file doesn't exist.
|
375
|
+
|
376
|
+
*Rafael Mendonça França*
|
377
|
+
|
378
|
+
* Fix complicated `has_many :through` with nested where condition.
|
379
|
+
|
380
|
+
*Ryuta Kamizono*
|
381
|
+
|
382
|
+
* Handle STI models for `has_many dependent: :destroy_async`.
|
383
|
+
|
384
|
+
*Muhammad Usman*
|
385
|
+
|
386
|
+
* Restore possibility of passing `false` to :polymorphic option of `belongs_to`.
|
387
|
+
|
388
|
+
Previously, passing `false` would trigger the option validation logic
|
389
|
+
to throw an error saying :polymorphic would not be a valid option.
|
390
|
+
|
391
|
+
*glaszig*
|
392
|
+
|
393
|
+
* Allow adding nonnamed expression indexes to be revertible.
|
394
|
+
|
395
|
+
Fixes #40732.
|
396
|
+
|
397
|
+
Previously, the following code would raise an error, when executed while rolling back,
|
398
|
+
and the index name should be specified explicitly. Now, the index name is inferred
|
399
|
+
automatically.
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
add_index(:items, "to_tsvector('english', description)")
|
403
|
+
```
|
404
|
+
|
405
|
+
*fatkodima*
|
406
|
+
|
407
|
+
|
1
408
|
## Rails 6.1.0 (December 09, 2020) ##
|
2
409
|
|
3
410
|
* Only warn about negative enums if a positive form that would cause conflicts exists.
|
@@ -38,21 +445,21 @@
|
|
38
445
|
|
39
446
|
Before:
|
40
447
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
448
|
+
AnimalsRecord.connected_to(role: :reading) do
|
449
|
+
MealsRecord.connected_to(role: :reading) do
|
450
|
+
Dog.first # read from animals replica
|
451
|
+
Dinner.first # read from meals replica
|
452
|
+
Person.first # read from primary writer
|
453
|
+
end
|
46
454
|
end
|
47
|
-
end
|
48
455
|
|
49
456
|
After:
|
50
457
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
458
|
+
ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do
|
459
|
+
Dog.first # read from animals replica
|
460
|
+
Dinner.first # read from meals replica
|
461
|
+
Person.first # read from primary writer
|
462
|
+
end
|
56
463
|
|
57
464
|
*Eileen M. Uchitelle*, *John Crepezzi*
|
58
465
|
|
@@ -170,13 +577,13 @@
|
|
170
577
|
|
171
578
|
Before:
|
172
579
|
|
173
|
-
|
174
|
-
|
580
|
+
User.where.not(name: "Jon", role: "admin")
|
581
|
+
# SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
|
175
582
|
|
176
583
|
After:
|
177
584
|
|
178
|
-
|
179
|
-
|
585
|
+
User.where.not(name: "Jon", role: "admin")
|
586
|
+
# SELECT * FROM users WHERE NOT (name == 'Jon' AND role == 'admin')
|
180
587
|
|
181
588
|
*Rafael Mendonça França*
|
182
589
|
|
@@ -284,7 +691,7 @@
|
|
284
691
|
|
285
692
|
attribute :duration, :interval
|
286
693
|
|
287
|
-
To keep old behavior until
|
694
|
+
To keep old behavior until 7.0 is released:
|
288
695
|
|
289
696
|
attribute :duration, :string
|
290
697
|
|
@@ -456,8 +863,8 @@
|
|
456
863
|
*Ryuta Kamizono*
|
457
864
|
|
458
865
|
* Merging conditions on the same column no longer maintain both conditions,
|
459
|
-
and will be consistently replaced by the latter condition in Rails
|
460
|
-
To migrate to Rails
|
866
|
+
and will be consistently replaced by the latter condition in Rails 7.0.
|
867
|
+
To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`.
|
461
868
|
|
462
869
|
```ruby
|
463
870
|
# Rails 6.1 (IN clause is replaced by merger side equality condition)
|
@@ -466,10 +873,10 @@
|
|
466
873
|
# Rails 6.1 (both conflict conditions exists, deprecated)
|
467
874
|
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
|
468
875
|
|
469
|
-
# Rails 6.1 with rewhere to migrate to Rails
|
876
|
+
# Rails 6.1 with rewhere to migrate to Rails 7.0's behavior
|
470
877
|
Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob]
|
471
878
|
|
472
|
-
# Rails
|
879
|
+
# Rails 7.0 (same behavior with IN clause, mergee side condition is consistently replaced)
|
473
880
|
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
|
474
881
|
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]
|
475
882
|
```
|
@@ -561,7 +968,7 @@
|
|
561
968
|
|
562
969
|
* Deprecate aggregations with group by duplicated fields.
|
563
970
|
|
564
|
-
To migrate to Rails
|
971
|
+
To migrate to Rails 7.0's behavior, use `uniq!(:group)` to deduplicate group fields.
|
565
972
|
|
566
973
|
```ruby
|
567
974
|
accounts = Account.group(:firm_id)
|
@@ -585,7 +992,7 @@
|
|
585
992
|
|
586
993
|
* Deprecate duplicated query annotations.
|
587
994
|
|
588
|
-
To migrate to Rails
|
995
|
+
To migrate to Rails 7.0's behavior, use `uniq!(:annotate)` to deduplicate query annotations.
|
589
996
|
|
590
997
|
```ruby
|
591
998
|
accounts = Account.where(id: [1, 2]).annotate("david and mary")
|
@@ -863,14 +1270,14 @@
|
|
863
1270
|
Deprecated behavior:
|
864
1271
|
|
865
1272
|
```ruby
|
866
|
-
db_config = ActiveRecord::Base.configs_for(env_name: "development", spec_name: "primary")
|
1273
|
+
db_config = ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
|
867
1274
|
db_config.spec_name
|
868
1275
|
```
|
869
1276
|
|
870
1277
|
New behavior:
|
871
1278
|
|
872
1279
|
```ruby
|
873
|
-
db_config = ActiveRecord::Base.configs_for(env_name: "development", name: "primary")
|
1280
|
+
db_config = ActiveRecord::Base.configurations.configs_for(env_name: "development", name: "primary")
|
874
1281
|
db_config.name
|
875
1282
|
```
|
876
1283
|
|
@@ -1006,13 +1413,13 @@
|
|
1006
1413
|
|
1007
1414
|
* Deprecate `#remove_connection` in favor of `#remove_connection_pool` when called on the handler.
|
1008
1415
|
|
1009
|
-
`#remove_connection` is deprecated in order to support returning a `DatabaseConfig` object instead of a `Hash`. Use `#remove_connection_pool`, `#remove_connection` will be removed in
|
1416
|
+
`#remove_connection` is deprecated in order to support returning a `DatabaseConfig` object instead of a `Hash`. Use `#remove_connection_pool`, `#remove_connection` will be removed in Rails 7.0.
|
1010
1417
|
|
1011
1418
|
*Eileen M. Uchitelle*, *John Crepezzi*
|
1012
1419
|
|
1013
1420
|
* Deprecate `#default_hash` and it's alias `#[]` on database configurations.
|
1014
1421
|
|
1015
|
-
Applications should use `configs_for`. `#default_hash` and `#[]` will be removed in
|
1422
|
+
Applications should use `configs_for`. `#default_hash` and `#[]` will be removed in Rails 7.0.
|
1016
1423
|
|
1017
1424
|
*Eileen M. Uchitelle*, *John Crepezzi*
|
1018
1425
|
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -194,7 +194,7 @@ The latest version of Active Record can be installed with RubyGems:
|
|
194
194
|
|
195
195
|
Source code can be downloaded as part of the Rails project on GitHub:
|
196
196
|
|
197
|
-
* https://github.com/rails/rails/tree/
|
197
|
+
* https://github.com/rails/rails/tree/main/activerecord
|
198
198
|
|
199
199
|
|
200
200
|
== License
|
@@ -244,8 +244,8 @@ module ActiveRecord
|
|
244
244
|
private
|
245
245
|
def reader_method(name, class_name, mapping, allow_nil, constructor)
|
246
246
|
define_method(name) do
|
247
|
-
if @aggregation_cache[name].nil? && (!allow_nil || mapping.any? { |key, _| !
|
248
|
-
attrs = mapping.collect { |key, _|
|
247
|
+
if @aggregation_cache[name].nil? && (!allow_nil || mapping.any? { |key, _| !read_attribute(key).nil? })
|
248
|
+
attrs = mapping.collect { |key, _| read_attribute(key) }
|
249
249
|
object = constructor.respond_to?(:call) ?
|
250
250
|
constructor.call(*attrs) :
|
251
251
|
class_name.constantize.send(constructor, *attrs)
|
@@ -271,10 +271,10 @@ module ActiveRecord
|
|
271
271
|
end
|
272
272
|
|
273
273
|
if part.nil? && allow_nil
|
274
|
-
mapping.each { |key, _|
|
274
|
+
mapping.each { |key, _| write_attribute(key, nil) }
|
275
275
|
@aggregation_cache[name] = nil
|
276
276
|
else
|
277
|
-
mapping.each { |key, value|
|
277
|
+
mapping.each { |key, value| write_attribute(key, part.send(value)) }
|
278
278
|
@aggregation_cache[name] = part.freeze
|
279
279
|
end
|
280
280
|
end
|
@@ -27,6 +27,16 @@ module ActiveRecord
|
|
27
27
|
RUBY
|
28
28
|
end
|
29
29
|
|
30
|
+
def build(attributes = nil, &block)
|
31
|
+
if attributes.is_a?(Array)
|
32
|
+
attributes.collect { |attr| build(attr, &block) }
|
33
|
+
else
|
34
|
+
block = current_scope_restoring_block(&block)
|
35
|
+
scoping { _new(attributes, &block) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
alias new build
|
39
|
+
|
30
40
|
private
|
31
41
|
def _new(attributes, &block)
|
32
42
|
@association.build(attributes, &block)
|
@@ -211,12 +211,8 @@ module ActiveRecord
|
|
211
211
|
|
212
212
|
private
|
213
213
|
def find_target
|
214
|
-
if
|
215
|
-
Base.strict_loading_violation!(owner: owner.class,
|
216
|
-
end
|
217
|
-
|
218
|
-
if reflection.strict_loading? && owner.validation_context.nil?
|
219
|
-
Base.strict_loading_violation!(owner: owner.class, association: reflection.name)
|
214
|
+
if strict_loading? && owner.validation_context.nil?
|
215
|
+
Base.strict_loading_violation!(owner: owner.class, reflection: reflection)
|
220
216
|
end
|
221
217
|
|
222
218
|
scope = self.scope
|
@@ -231,6 +227,12 @@ module ActiveRecord
|
|
231
227
|
sc.execute(binds, klass.connection) { |record| set_inverse_instance(record) }
|
232
228
|
end
|
233
229
|
|
230
|
+
def strict_loading?
|
231
|
+
return reflection.strict_loading? if reflection.options.key?(:strict_loading)
|
232
|
+
|
233
|
+
owner.strict_loading?
|
234
|
+
end
|
235
|
+
|
234
236
|
# The scope for this association.
|
235
237
|
#
|
236
238
|
# Note that the association_scope is merged into the target_scope only when the
|
@@ -331,7 +333,11 @@ module ActiveRecord
|
|
331
333
|
end
|
332
334
|
|
333
335
|
def enqueue_destroy_association(options)
|
334
|
-
owner.class.destroy_association_async_job
|
336
|
+
job_class = owner.class.destroy_association_async_job
|
337
|
+
|
338
|
+
if job_class
|
339
|
+
owner._after_commit_jobs.push([job_class, options])
|
340
|
+
end
|
335
341
|
end
|
336
342
|
|
337
343
|
def inversable?(record)
|
@@ -131,11 +131,13 @@ module ActiveRecord
|
|
131
131
|
if scope_chain_item == chain_head.scope
|
132
132
|
scope.merge! item.except(:where, :includes, :unscope, :order)
|
133
133
|
elsif !item.references_values.empty?
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
134
|
+
scope.merge! item.only(:joins, :left_outer_joins)
|
135
|
+
|
136
|
+
associations = item.eager_load_values | item.includes_values
|
137
|
+
|
138
|
+
unless associations.empty?
|
139
|
+
scope.joins! item.construct_join_dependency(associations, Arel::Nodes::OuterJoin)
|
140
|
+
end
|
139
141
|
end
|
140
142
|
|
141
143
|
reflection.all_includes do
|