activerecord 6.0.0.rc1 → 6.0.3.rc1
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 +251 -3
- data/README.rdoc +1 -1
- data/lib/active_record.rb +1 -0
- data/lib/active_record/advisory_lock_base.rb +18 -0
- data/lib/active_record/aggregations.rb +0 -1
- data/lib/active_record/association_relation.rb +10 -8
- data/lib/active_record/associations.rb +2 -2
- data/lib/active_record/associations/alias_tracker.rb +0 -1
- data/lib/active_record/associations/association.rb +5 -1
- data/lib/active_record/associations/builder/collection_association.rb +2 -2
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +1 -3
- data/lib/active_record/associations/collection_association.rb +6 -2
- data/lib/active_record/associations/collection_proxy.rb +2 -3
- data/lib/active_record/associations/has_many_association.rb +0 -1
- data/lib/active_record/associations/join_dependency.rb +23 -9
- data/lib/active_record/associations/join_dependency/join_association.rb +12 -3
- data/lib/active_record/associations/preloader.rb +2 -3
- data/lib/active_record/associations/preloader/association.rb +3 -1
- data/lib/active_record/attribute_assignment.rb +0 -1
- data/lib/active_record/attribute_decorators.rb +0 -2
- data/lib/active_record/attribute_methods.rb +0 -51
- data/lib/active_record/attribute_methods/before_type_cast.rb +0 -1
- data/lib/active_record/attribute_methods/dirty.rb +8 -3
- data/lib/active_record/attribute_methods/primary_key.rb +0 -2
- data/lib/active_record/attribute_methods/read.rb +0 -1
- data/lib/active_record/attribute_methods/serialization.rb +0 -1
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +0 -2
- data/lib/active_record/attribute_methods/write.rb +0 -1
- data/lib/active_record/attributes.rb +0 -1
- data/lib/active_record/autosave_association.rb +11 -7
- data/lib/active_record/callbacks.rb +1 -2
- data/lib/active_record/coders/yaml_column.rb +0 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +107 -13
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +21 -15
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +5 -5
- data/lib/active_record/connection_adapters/abstract/quoting.rb +53 -0
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +1 -2
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +27 -27
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +55 -37
- data/lib/active_record/connection_adapters/abstract/transaction.rb +14 -7
- data/lib/active_record/connection_adapters/abstract_adapter.rb +62 -25
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +25 -32
- data/lib/active_record/connection_adapters/connection_specification.rb +3 -4
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +2 -2
- data/lib/active_record/connection_adapters/mysql/column.rb +1 -1
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +8 -12
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +0 -1
- data/lib/active_record/connection_adapters/mysql/quoting.rb +44 -7
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +1 -2
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +3 -1
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +8 -8
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +12 -4
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +9 -3
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +39 -2
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +15 -29
- data/lib/active_record/connection_adapters/postgresql/utils.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +17 -3
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +8 -7
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +38 -3
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +3 -3
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +23 -8
- data/lib/active_record/connection_adapters/statement_pool.rb +0 -1
- data/lib/active_record/connection_handling.rb +17 -22
- data/lib/active_record/core.rb +8 -6
- data/lib/active_record/counter_cache.rb +4 -1
- data/lib/active_record/database_configurations.rb +60 -31
- data/lib/active_record/database_configurations/url_config.rb +0 -1
- data/lib/active_record/dynamic_matchers.rb +2 -3
- data/lib/active_record/enum.rb +9 -0
- data/lib/active_record/explain.rb +0 -1
- data/lib/active_record/fixture_set/table_row.rb +0 -1
- data/lib/active_record/fixture_set/table_rows.rb +0 -1
- data/lib/active_record/fixtures.rb +11 -9
- data/lib/active_record/gem_version.rb +1 -1
- data/lib/active_record/inheritance.rb +0 -3
- data/lib/active_record/insert_all.rb +5 -6
- data/lib/active_record/internal_metadata.rb +1 -1
- data/lib/active_record/locking/optimistic.rb +0 -1
- data/lib/active_record/log_subscriber.rb +1 -1
- data/lib/active_record/middleware/database_selector.rb +3 -4
- data/lib/active_record/middleware/database_selector/resolver.rb +5 -8
- data/lib/active_record/migration.rb +43 -32
- data/lib/active_record/migration/command_recorder.rb +6 -18
- data/lib/active_record/migration/compatibility.rb +3 -3
- data/lib/active_record/migration/join_table.rb +0 -1
- data/lib/active_record/model_schema.rb +3 -2
- data/lib/active_record/nested_attributes.rb +0 -2
- data/lib/active_record/no_touching.rb +2 -2
- data/lib/active_record/null_relation.rb +0 -1
- data/lib/active_record/persistence.rb +4 -5
- data/lib/active_record/querying.rb +1 -1
- data/lib/active_record/railtie.rb +1 -2
- data/lib/active_record/railties/collection_cache_association_loading.rb +1 -1
- data/lib/active_record/railties/databases.rake +63 -23
- data/lib/active_record/reflection.rb +9 -9
- data/lib/active_record/relation.rb +13 -1
- data/lib/active_record/relation/batches.rb +0 -1
- data/lib/active_record/relation/calculations.rb +3 -5
- data/lib/active_record/relation/delegation.rb +7 -6
- data/lib/active_record/relation/finder_methods.rb +14 -4
- data/lib/active_record/relation/from_clause.rb +4 -0
- data/lib/active_record/relation/merger.rb +6 -3
- data/lib/active_record/relation/predicate_builder.rb +1 -5
- data/lib/active_record/relation/query_methods.rb +94 -55
- data/lib/active_record/relation/spawn_methods.rb +0 -1
- data/lib/active_record/relation/where_clause.rb +0 -1
- data/lib/active_record/result.rb +0 -1
- data/lib/active_record/sanitization.rb +30 -2
- data/lib/active_record/schema.rb +1 -1
- data/lib/active_record/schema_dumper.rb +5 -1
- data/lib/active_record/schema_migration.rb +1 -1
- data/lib/active_record/scoping.rb +0 -1
- data/lib/active_record/scoping/default.rb +0 -1
- data/lib/active_record/scoping/named.rb +3 -3
- data/lib/active_record/store.rb +1 -1
- data/lib/active_record/suppressor.rb +2 -2
- data/lib/active_record/table_metadata.rb +21 -10
- data/lib/active_record/tasks/database_tasks.rb +76 -8
- data/lib/active_record/tasks/mysql_database_tasks.rb +3 -2
- data/lib/active_record/tasks/postgresql_database_tasks.rb +0 -1
- data/lib/active_record/tasks/sqlite_database_tasks.rb +0 -1
- data/lib/active_record/test_databases.rb +1 -16
- data/lib/active_record/test_fixtures.rb +2 -1
- data/lib/active_record/timestamp.rb +26 -17
- data/lib/active_record/touch_later.rb +3 -2
- data/lib/active_record/transactions.rb +18 -19
- data/lib/active_record/type.rb +0 -1
- data/lib/active_record/type/adapter_specific_registry.rb +2 -5
- data/lib/active_record/type/hash_lookup_type_map.rb +0 -1
- data/lib/active_record/type/serialized.rb +0 -1
- data/lib/active_record/type/type_map.rb +0 -1
- data/lib/active_record/type/unsigned_integer.rb +0 -1
- data/lib/active_record/type_caster/connection.rb +16 -10
- data/lib/active_record/validations.rb +3 -3
- data/lib/active_record/validations/associated.rb +1 -2
- data/lib/arel.rb +17 -6
- data/lib/arel/predications.rb +5 -6
- data/lib/arel/visitors/depth_first.rb +1 -2
- data/lib/arel/visitors/dot.rb +0 -1
- data/lib/arel/visitors/mssql.rb +0 -1
- data/lib/arel/visitors/oracle.rb +1 -2
- data/lib/arel/visitors/oracle12.rb +0 -1
- data/lib/arel/visitors/postgresql.rb +0 -1
- data/lib/arel/visitors/sqlite.rb +0 -1
- data/lib/arel/visitors/to_sql.rb +23 -27
- data/lib/arel/visitors/visitor.rb +9 -6
- data/lib/arel/visitors/where_sql.rb +0 -1
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +0 -1
- data/lib/rails/generators/active_record/migration.rb +0 -1
- data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +1 -1
- data/lib/rails/generators/active_record/model/model_generator.rb +0 -1
- metadata +13 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ccce92664ea2ffdf668e08bd901b85522987ff1bb9eab653e7c46c46919788b
|
4
|
+
data.tar.gz: 66f3751f03d187d4275389d818904f9ac09d762ecaddae82a5f65a8b50abde94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c0002b9ff699757fb3178bb15f1237a64447a9b5a5af2b7c155bba9e723b0df02ca86499d2a782da561ae4b798c65aa523ffd4ff626fdbbf3763575bc1913a1
|
7
|
+
data.tar.gz: aab48d472ef1ed54a7a0089378834ab5911d9fe5266d5a068e08f12fa4f900b45da06dbb1879f6d2d1d2c637be854f1af113d87e5846e847ca7a4d85855a6f36
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,251 @@
|
|
1
|
+
## Rails 6.0.3.rc1 (April 30, 2020) ##
|
2
|
+
|
3
|
+
* Recommend applications don't use the `database` kwarg in `connected_to`
|
4
|
+
|
5
|
+
The database kwarg in `connected_to` was meant to be used for one-off scripts but is often used in requests. This is really dangerous because it re-establishes a connection every time. It's deprecated in 6.1 and will be removed in 6.2 without replacement. This change soft deprecates it in 6.0 by removing documentation.
|
6
|
+
|
7
|
+
*Eileen M. Uchitelle*
|
8
|
+
|
9
|
+
* Fix support for PostgreSQL 11+ partitioned indexes.
|
10
|
+
|
11
|
+
*Sebastián Palma*
|
12
|
+
|
13
|
+
* Add support for beginless ranges, introduced in Ruby 2.7.
|
14
|
+
|
15
|
+
*Josh Goodall*
|
16
|
+
|
17
|
+
* Fix insert_all with enum values
|
18
|
+
|
19
|
+
Fixes #38716.
|
20
|
+
|
21
|
+
*Joel Blum*
|
22
|
+
|
23
|
+
* Regexp-escape table name for MS SQL
|
24
|
+
|
25
|
+
Add `Regexp.escape` to one method in ActiveRecord, so that table names with regular expression characters in them work as expected. Since MS SQL Server uses "[" and "]" to quote table and column names, and those characters are regular expression characters, methods like `pluck` and `select` fail in certain cases when used with the MS SQL Server adapter.
|
26
|
+
|
27
|
+
*Larry Reid*
|
28
|
+
|
29
|
+
* Store advisory locks on their own named connection.
|
30
|
+
|
31
|
+
Previously advisory locks were taken out against a connection when a migration started. This works fine in single database applications but doesn't work well when migrations need to open new connections which results in the lock getting dropped.
|
32
|
+
|
33
|
+
In order to fix this we are storing the advisory lock on a new connection with the connection specification name `AdisoryLockBase`. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.
|
34
|
+
|
35
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
36
|
+
|
37
|
+
* Ensure `:reading` connections always raise if a write is attempted.
|
38
|
+
|
39
|
+
Now Rails will raise an `ActiveRecord::ReadOnlyError` if any connection on the reading handler attempts to make a write. If your reading role needs to write you should name the role something other than `:reading`.
|
40
|
+
|
41
|
+
*Eileen M. Uchitelle*
|
42
|
+
|
43
|
+
* Enforce fresh ETag header after a collection's contents change by adding
|
44
|
+
ActiveRecord::Relation#cache_key_with_version. This method will be used by
|
45
|
+
ActionController::ConditionalGet to ensure that when collection cache versioning
|
46
|
+
is enabled, requests using ConditionalGet don't return the same ETag header
|
47
|
+
after a collection is modified. Fixes #38078.
|
48
|
+
|
49
|
+
*Aaron Lipman*
|
50
|
+
|
51
|
+
* A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgresSQL `options`.
|
52
|
+
|
53
|
+
*Joshua Flanagan*
|
54
|
+
|
55
|
+
* Retain explicit selections on the base model after applying `includes` and `joins`.
|
56
|
+
|
57
|
+
Resolves #34889.
|
58
|
+
|
59
|
+
*Patrick Rebsch*
|
60
|
+
|
61
|
+
|
62
|
+
## Rails 6.0.2.2 (March 19, 2020) ##
|
63
|
+
|
64
|
+
* No changes.
|
65
|
+
|
66
|
+
|
67
|
+
## Rails 6.0.2.1 (December 18, 2019) ##
|
68
|
+
|
69
|
+
* No changes.
|
70
|
+
|
71
|
+
|
72
|
+
## Rails 6.0.2 (December 13, 2019) ##
|
73
|
+
|
74
|
+
* Share the same connection pool for primary and replica databases in the
|
75
|
+
transactional tests for the same database.
|
76
|
+
|
77
|
+
*Edouard Chin*
|
78
|
+
|
79
|
+
* Fix the preloader when one record is fetched using `after_initialize`
|
80
|
+
but not the entire collection.
|
81
|
+
|
82
|
+
*Bradley Price*
|
83
|
+
|
84
|
+
* Fix collection callbacks not terminating when `:abort` is thrown.
|
85
|
+
|
86
|
+
*Edouard Chin*, *Ryuta Kamizono*
|
87
|
+
|
88
|
+
* Correctly deprecate `where.not` working as NOR for relations.
|
89
|
+
|
90
|
+
12a9664 deprecated where.not working as NOR, however
|
91
|
+
doing a relation query like `where.not(relation: { ... })`
|
92
|
+
wouldn't be properly deprecated and `where.not` would work as
|
93
|
+
NAND instead.
|
94
|
+
|
95
|
+
*Edouard Chin*
|
96
|
+
|
97
|
+
* Fix `db:migrate` task with multiple databases to restore the connection
|
98
|
+
to the previous database.
|
99
|
+
|
100
|
+
The migrate task iterates and establish a connection over each db
|
101
|
+
resulting in the last one to be used by subsequent rake tasks.
|
102
|
+
We should reestablish a connection to the connection that was
|
103
|
+
established before the migrate tasks was run
|
104
|
+
|
105
|
+
*Edouard Chin*
|
106
|
+
|
107
|
+
* Fix multi-threaded issue for `AcceptanceValidator`.
|
108
|
+
|
109
|
+
*Ryuta Kamizono*
|
110
|
+
|
111
|
+
|
112
|
+
## Rails 6.0.1 (November 5, 2019) ##
|
113
|
+
|
114
|
+
* Common Table Expressions are allowed on read-only connections.
|
115
|
+
|
116
|
+
*Chris Morris*
|
117
|
+
|
118
|
+
* New record instantiation respects `unscope`.
|
119
|
+
|
120
|
+
*Ryuta Kamizono*
|
121
|
+
|
122
|
+
* Fixed a case where `find_in_batches` could halt too early.
|
123
|
+
|
124
|
+
*Takayuki Nakata*
|
125
|
+
|
126
|
+
* Autosaved associations always perform validations when a custom validation
|
127
|
+
context is used.
|
128
|
+
|
129
|
+
*Tekin Suleyman*
|
130
|
+
|
131
|
+
* `sql.active_record` notifications now include the `:connection` in
|
132
|
+
their payloads.
|
133
|
+
|
134
|
+
*Eugene Kenny*
|
135
|
+
|
136
|
+
* A rollback encountered in an `after_commit` callback does not reset
|
137
|
+
previously-committed record state.
|
138
|
+
|
139
|
+
*Ryuta Kamizono*
|
140
|
+
|
141
|
+
* Fixed that join order was lost when eager-loading.
|
142
|
+
|
143
|
+
*Ryuta Kamizono*
|
144
|
+
|
145
|
+
* `DESCRIBE` queries are allowed on read-only connections.
|
146
|
+
|
147
|
+
*Dylan Thacker-Smith*
|
148
|
+
|
149
|
+
* Fixed that records that had been `inspect`ed could not be marshaled.
|
150
|
+
|
151
|
+
*Eugene Kenny*
|
152
|
+
|
153
|
+
* The connection pool reaper thread is respawned in forked processes. This
|
154
|
+
fixes that idle connections in forked processes wouldn't be reaped.
|
155
|
+
|
156
|
+
*John Hawthorn*
|
157
|
+
|
158
|
+
* The memoized result of `ActiveRecord::Relation#take` is properly cleared
|
159
|
+
when `ActiveRecord::Relation#reset` or `ActiveRecord::Relation#reload`
|
160
|
+
is called.
|
161
|
+
|
162
|
+
*Anmol Arora*
|
163
|
+
|
164
|
+
* Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
|
165
|
+
|
166
|
+
*Hiroyuki Ishii*
|
167
|
+
|
168
|
+
* `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
|
169
|
+
|
170
|
+
*Eugene Kenny*
|
171
|
+
|
172
|
+
* Call `while_preventing_writes` directly from `connected_to`.
|
173
|
+
|
174
|
+
In some cases application authors want to use the database switching middleware and make explicit calls with `connected_to`. It's possible for an app to turn off writes and not turn them back on by the time we call `connected_to(role: :writing)`.
|
175
|
+
|
176
|
+
This change allows apps to fix this by assuming if a role is writing we want to allow writes, except in the case it's explicitly turned off.
|
177
|
+
|
178
|
+
*Eileen M. Uchitelle*
|
179
|
+
|
180
|
+
* Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
|
181
|
+
|
182
|
+
*Kir Shatrov*
|
183
|
+
|
184
|
+
|
185
|
+
## Rails 6.0.0 (August 16, 2019) ##
|
186
|
+
|
187
|
+
* Preserve user supplied joins order as much as possible.
|
188
|
+
|
189
|
+
Fixes #36761, #34328, #24281, #12953.
|
190
|
+
|
191
|
+
*Ryuta Kamizono*
|
192
|
+
|
193
|
+
* Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
|
194
|
+
|
195
|
+
*John Crepezzi*, *Eileen Uchitelle*
|
196
|
+
|
197
|
+
* Add a warning for enum elements with 'not_' prefix.
|
198
|
+
|
199
|
+
class Foo
|
200
|
+
enum status: [:sent, :not_sent]
|
201
|
+
end
|
202
|
+
|
203
|
+
*Edu Depetris*
|
204
|
+
|
205
|
+
* Make currency symbols optional for money column type in PostgreSQL
|
206
|
+
|
207
|
+
*Joel Schneider*
|
208
|
+
|
209
|
+
|
210
|
+
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
211
|
+
|
212
|
+
* Add database_exists? method to connection adapters to check if a database exists.
|
213
|
+
|
214
|
+
*Guilherme Mansur*
|
215
|
+
|
216
|
+
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
217
|
+
|
218
|
+
Fixes #36022.
|
219
|
+
|
220
|
+
*Ryuta Kamizono*
|
221
|
+
|
222
|
+
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
223
|
+
|
224
|
+
Fixes #36465.
|
225
|
+
|
226
|
+
*Jeff Doering*
|
227
|
+
|
228
|
+
* Fix sqlite3 collation parsing when using decimal columns.
|
229
|
+
|
230
|
+
*Martin R. Schuster*
|
231
|
+
|
232
|
+
* Fix invalid schema when primary key column has a comment.
|
233
|
+
|
234
|
+
Fixes #29966.
|
235
|
+
|
236
|
+
*Guilherme Goettems Schneider*
|
237
|
+
|
238
|
+
* Fix table comment also being applied to the primary key column.
|
239
|
+
|
240
|
+
*Guilherme Goettems Schneider*
|
241
|
+
|
242
|
+
* Fix merging left_joins to maintain its own `join_type` context.
|
243
|
+
|
244
|
+
Fixes #36103.
|
245
|
+
|
246
|
+
*Ryuta Kamizono*
|
247
|
+
|
248
|
+
|
1
249
|
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
2
250
|
|
3
251
|
* Add `touch` option to `has_one` association.
|
@@ -347,7 +595,7 @@
|
|
347
595
|
`GET` and `HEAD` requests will read from the replica unless there was
|
348
596
|
a write in the last 2 seconds, otherwise they will read from the primary.
|
349
597
|
Non-get requests will always write to the primary. The middleware accepts
|
350
|
-
an argument for a Resolver class and
|
598
|
+
an argument for a Resolver class and an Operations class where you are able
|
351
599
|
to change how the auto-switcher works to be most beneficial for your
|
352
600
|
application.
|
353
601
|
|
@@ -414,7 +662,7 @@
|
|
414
662
|
|
415
663
|
*Rafael Mendonça França*
|
416
664
|
|
417
|
-
* Deprecate `config.
|
665
|
+
* Deprecate `config.active_record.sqlite3.represent_boolean_as_integer`.
|
418
666
|
|
419
667
|
*Rafael Mendonça França*
|
420
668
|
|
@@ -781,7 +1029,7 @@
|
|
781
1029
|
*Darwin Wu*
|
782
1030
|
|
783
1031
|
* Configuration item `config.filter_parameters` could also filter out
|
784
|
-
sensitive values of database columns when
|
1032
|
+
sensitive values of database columns when calling `#inspect`.
|
785
1033
|
We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
|
786
1034
|
specify sensitive attributes to specific model.
|
787
1035
|
|
data/README.rdoc
CHANGED
@@ -216,4 +216,4 @@ Bug reports for the Ruby on Rails project can be filed here:
|
|
216
216
|
|
217
217
|
Feature requests should be discussed on the rails-core mailing list here:
|
218
218
|
|
219
|
-
* https://
|
219
|
+
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
data/lib/active_record.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
# This class is used to create a connection that we can use for advisory
|
5
|
+
# locks. This will take out a "global" lock that can't be accidentally
|
6
|
+
# removed if a new connection is established during a migration.
|
7
|
+
class AdvisoryLockBase < ActiveRecord::Base # :nodoc:
|
8
|
+
self.abstract_class = true
|
9
|
+
|
10
|
+
self.connection_specification_name = "AdvisoryLockBase"
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def _internal?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
4
|
class AssociationRelation < Relation
|
5
|
-
def initialize(klass, association)
|
5
|
+
def initialize(klass, association, **)
|
6
6
|
super(klass)
|
7
7
|
@association = association
|
8
8
|
end
|
@@ -15,21 +15,23 @@ module ActiveRecord
|
|
15
15
|
other == records
|
16
16
|
end
|
17
17
|
|
18
|
-
def build(
|
19
|
-
|
18
|
+
def build(attributes = nil, &block)
|
19
|
+
block = _deprecated_scope_block("new", &block)
|
20
|
+
scoping { @association.build(attributes, &block) }
|
20
21
|
end
|
21
22
|
alias new build
|
22
23
|
|
23
|
-
def create(
|
24
|
-
|
24
|
+
def create(attributes = nil, &block)
|
25
|
+
block = _deprecated_scope_block("create", &block)
|
26
|
+
scoping { @association.create(attributes, &block) }
|
25
27
|
end
|
26
28
|
|
27
|
-
def create!(
|
28
|
-
|
29
|
+
def create!(attributes = nil, &block)
|
30
|
+
block = _deprecated_scope_block("create!", &block)
|
31
|
+
scoping { @association.create!(attributes, &block) }
|
29
32
|
end
|
30
33
|
|
31
34
|
private
|
32
|
-
|
33
35
|
def exec_queries
|
34
36
|
super do |record|
|
35
37
|
@association.set_inverse_instance_from_queries(record)
|
@@ -92,7 +92,7 @@ module ActiveRecord
|
|
92
92
|
through_reflection = reflection.through_reflection
|
93
93
|
source_reflection_names = reflection.source_reflection_names
|
94
94
|
source_associations = reflection.through_reflection.klass._reflections.keys
|
95
|
-
super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence(two_words_connector: ' or ', last_word_connector: ', or '
|
95
|
+
super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence(two_words_connector: ' or ', last_word_connector: ', or ')} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence(two_words_connector: ' or ', last_word_connector: ', or ')}?")
|
96
96
|
else
|
97
97
|
super("Could not find the source association(s).")
|
98
98
|
end
|
@@ -1857,7 +1857,7 @@ module ActiveRecord
|
|
1857
1857
|
hm_options[k] = options[k] if options.key? k
|
1858
1858
|
end
|
1859
1859
|
|
1860
|
-
has_many name, scope, hm_options, &extension
|
1860
|
+
has_many name, scope, **hm_options, &extension
|
1861
1861
|
_reflections[name.to_s].parent_reflection = habtm_reflection
|
1862
1862
|
end
|
1863
1863
|
end
|
@@ -95,7 +95,11 @@ module ActiveRecord
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def scope
|
98
|
-
|
98
|
+
if (scope = klass.current_scope) && scope.try(:proxy_association) == self
|
99
|
+
scope.spawn
|
100
|
+
else
|
101
|
+
target_scope.merge!(association_scope)
|
102
|
+
end
|
99
103
|
end
|
100
104
|
|
101
105
|
def reset_scope
|
@@ -22,9 +22,9 @@ module ActiveRecord::Associations::Builder # :nodoc:
|
|
22
22
|
|
23
23
|
def self.define_extensions(model, name, &block)
|
24
24
|
if block_given?
|
25
|
-
extension_module_name = "#{
|
25
|
+
extension_module_name = "#{name.to_s.camelize}AssociationExtension"
|
26
26
|
extension = Module.new(&block)
|
27
|
-
model.
|
27
|
+
model.const_set(extension_module_name, extension)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -46,7 +46,6 @@ module ActiveRecord::Associations::Builder # :nodoc:
|
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
49
|
-
|
50
49
|
def self.suppress_composite_primary_key(pk)
|
51
50
|
pk unless pk.is_a?(Array)
|
52
51
|
end
|
@@ -63,7 +62,7 @@ module ActiveRecord::Associations::Builder # :nodoc:
|
|
63
62
|
|
64
63
|
def middle_reflection(join_model)
|
65
64
|
middle_name = [lhs_model.name.downcase.pluralize,
|
66
|
-
association_name].join("_").gsub("::", "_").to_sym
|
65
|
+
association_name.to_s].sort.join("_").gsub("::", "_").to_sym
|
67
66
|
middle_options = middle_options join_model
|
68
67
|
|
69
68
|
HasMany.create_reflection(lhs_model,
|
@@ -73,7 +72,6 @@ module ActiveRecord::Associations::Builder # :nodoc:
|
|
73
72
|
end
|
74
73
|
|
75
74
|
private
|
76
|
-
|
77
75
|
def middle_options(join_model)
|
78
76
|
middle_options = {}
|
79
77
|
middle_options[:class_name] = "#{lhs_model.name}::#{join_model.name}"
|