activerecord 6.1.7.2 → 7.0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1295 -1007
- data/README.rdoc +1 -1
- data/lib/active_record/aggregations.rb +1 -1
- data/lib/active_record/association_relation.rb +0 -10
- data/lib/active_record/associations/association.rb +33 -17
- data/lib/active_record/associations/association_scope.rb +1 -3
- data/lib/active_record/associations/belongs_to_association.rb +15 -4
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +10 -2
- data/lib/active_record/associations/builder/association.rb +8 -2
- data/lib/active_record/associations/builder/belongs_to.rb +19 -6
- data/lib/active_record/associations/builder/collection_association.rb +10 -3
- data/lib/active_record/associations/builder/has_many.rb +3 -2
- data/lib/active_record/associations/builder/has_one.rb +2 -1
- data/lib/active_record/associations/builder/singular_association.rb +2 -2
- data/lib/active_record/associations/collection_association.rb +19 -21
- data/lib/active_record/associations/collection_proxy.rb +10 -5
- data/lib/active_record/associations/disable_joins_association_scope.rb +59 -0
- data/lib/active_record/associations/has_many_association.rb +8 -5
- data/lib/active_record/associations/has_many_through_association.rb +2 -1
- data/lib/active_record/associations/has_one_association.rb +10 -7
- data/lib/active_record/associations/has_one_through_association.rb +1 -1
- data/lib/active_record/associations/join_dependency.rb +23 -15
- data/lib/active_record/associations/preloader/association.rb +186 -52
- data/lib/active_record/associations/preloader/batch.rb +48 -0
- data/lib/active_record/associations/preloader/branch.rb +147 -0
- data/lib/active_record/associations/preloader/through_association.rb +49 -13
- data/lib/active_record/associations/preloader.rb +39 -113
- data/lib/active_record/associations/singular_association.rb +8 -2
- data/lib/active_record/associations/through_association.rb +3 -3
- data/lib/active_record/associations.rb +124 -95
- data/lib/active_record/asynchronous_queries_tracker.rb +60 -0
- data/lib/active_record/attribute_assignment.rb +1 -1
- data/lib/active_record/attribute_methods/before_type_cast.rb +7 -2
- data/lib/active_record/attribute_methods/dirty.rb +49 -16
- data/lib/active_record/attribute_methods/primary_key.rb +2 -2
- data/lib/active_record/attribute_methods/query.rb +2 -2
- data/lib/active_record/attribute_methods/read.rb +7 -5
- data/lib/active_record/attribute_methods/serialization.rb +57 -19
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +8 -3
- data/lib/active_record/attribute_methods/write.rb +7 -10
- data/lib/active_record/attribute_methods.rb +14 -15
- data/lib/active_record/attributes.rb +24 -35
- data/lib/active_record/autosave_association.rb +8 -23
- data/lib/active_record/base.rb +19 -1
- data/lib/active_record/callbacks.rb +2 -2
- data/lib/active_record/coders/yaml_column.rb +4 -8
- data/lib/active_record/connection_adapters/abstract/connection_handler.rb +292 -0
- data/lib/active_record/connection_adapters/abstract/connection_pool/queue.rb +209 -0
- data/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb +76 -0
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +47 -561
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +0 -17
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +46 -22
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +24 -12
- data/lib/active_record/connection_adapters/abstract/quoting.rb +42 -72
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +4 -17
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +38 -13
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +14 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +80 -24
- data/lib/active_record/connection_adapters/abstract/transaction.rb +15 -22
- data/lib/active_record/connection_adapters/abstract_adapter.rb +149 -74
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +105 -81
- data/lib/active_record/connection_adapters/column.rb +4 -0
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +36 -24
- data/lib/active_record/connection_adapters/mysql/quoting.rb +37 -21
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +7 -1
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +20 -1
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +12 -6
- data/lib/active_record/connection_adapters/pool_config.rb +7 -7
- data/lib/active_record/connection_adapters/postgresql/column.rb +17 -1
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +19 -12
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +8 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +5 -0
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +53 -14
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/timestamp.rb +15 -0
- data/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb +30 -0
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +18 -6
- data/lib/active_record/connection_adapters/postgresql/oid.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +71 -71
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +34 -0
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +21 -1
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +22 -1
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +25 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +37 -19
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +206 -105
- data/lib/active_record/connection_adapters/schema_cache.rb +39 -38
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +25 -19
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +28 -16
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +17 -15
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +96 -32
- data/lib/active_record/connection_adapters.rb +6 -5
- data/lib/active_record/connection_handling.rb +49 -55
- data/lib/active_record/core.rb +123 -148
- data/lib/active_record/database_configurations/connection_url_resolver.rb +2 -1
- data/lib/active_record/database_configurations/database_config.rb +12 -9
- data/lib/active_record/database_configurations/hash_config.rb +63 -5
- data/lib/active_record/database_configurations/url_config.rb +2 -2
- data/lib/active_record/database_configurations.rb +15 -32
- data/lib/active_record/delegated_type.rb +53 -12
- data/lib/active_record/destroy_association_async_job.rb +1 -1
- data/lib/active_record/disable_joins_association_relation.rb +39 -0
- data/lib/active_record/dynamic_matchers.rb +1 -1
- data/lib/active_record/encryption/cipher/aes256_gcm.rb +98 -0
- data/lib/active_record/encryption/cipher.rb +53 -0
- data/lib/active_record/encryption/config.rb +44 -0
- data/lib/active_record/encryption/configurable.rb +67 -0
- data/lib/active_record/encryption/context.rb +35 -0
- data/lib/active_record/encryption/contexts.rb +72 -0
- data/lib/active_record/encryption/derived_secret_key_provider.rb +12 -0
- data/lib/active_record/encryption/deterministic_key_provider.rb +14 -0
- data/lib/active_record/encryption/encryptable_record.rb +206 -0
- data/lib/active_record/encryption/encrypted_attribute_type.rb +140 -0
- data/lib/active_record/encryption/encrypted_fixtures.rb +38 -0
- data/lib/active_record/encryption/encrypting_only_encryptor.rb +12 -0
- data/lib/active_record/encryption/encryptor.rb +155 -0
- data/lib/active_record/encryption/envelope_encryption_key_provider.rb +55 -0
- data/lib/active_record/encryption/errors.rb +15 -0
- data/lib/active_record/encryption/extended_deterministic_queries.rb +160 -0
- data/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb +28 -0
- data/lib/active_record/encryption/key.rb +28 -0
- data/lib/active_record/encryption/key_generator.rb +42 -0
- data/lib/active_record/encryption/key_provider.rb +46 -0
- data/lib/active_record/encryption/message.rb +33 -0
- data/lib/active_record/encryption/message_serializer.rb +90 -0
- data/lib/active_record/encryption/null_encryptor.rb +21 -0
- data/lib/active_record/encryption/properties.rb +76 -0
- data/lib/active_record/encryption/read_only_null_encryptor.rb +24 -0
- data/lib/active_record/encryption/scheme.rb +99 -0
- data/lib/active_record/encryption.rb +55 -0
- data/lib/active_record/enum.rb +50 -43
- data/lib/active_record/errors.rb +67 -4
- data/lib/active_record/explain_registry.rb +11 -6
- data/lib/active_record/fixture_set/file.rb +15 -1
- data/lib/active_record/fixture_set/table_row.rb +41 -6
- data/lib/active_record/fixture_set/table_rows.rb +4 -4
- data/lib/active_record/fixtures.rb +20 -23
- data/lib/active_record/future_result.rb +139 -0
- data/lib/active_record/gem_version.rb +4 -4
- data/lib/active_record/inheritance.rb +55 -17
- data/lib/active_record/insert_all.rb +80 -14
- data/lib/active_record/integration.rb +4 -3
- data/lib/active_record/internal_metadata.rb +1 -5
- data/lib/active_record/legacy_yaml_adapter.rb +2 -39
- data/lib/active_record/locking/optimistic.rb +10 -9
- data/lib/active_record/locking/pessimistic.rb +10 -4
- data/lib/active_record/log_subscriber.rb +23 -7
- data/lib/active_record/middleware/database_selector/resolver.rb +6 -10
- data/lib/active_record/middleware/database_selector.rb +18 -6
- data/lib/active_record/middleware/shard_selector.rb +60 -0
- data/lib/active_record/migration/command_recorder.rb +7 -7
- data/lib/active_record/migration/compatibility.rb +84 -2
- data/lib/active_record/migration/join_table.rb +1 -1
- data/lib/active_record/migration.rb +114 -83
- data/lib/active_record/model_schema.rb +58 -59
- data/lib/active_record/nested_attributes.rb +13 -12
- data/lib/active_record/no_touching.rb +3 -3
- data/lib/active_record/null_relation.rb +2 -6
- data/lib/active_record/persistence.rb +228 -60
- data/lib/active_record/query_cache.rb +2 -2
- data/lib/active_record/query_logs.rb +149 -0
- data/lib/active_record/querying.rb +16 -6
- data/lib/active_record/railtie.rb +136 -22
- data/lib/active_record/railties/controller_runtime.rb +1 -1
- data/lib/active_record/railties/databases.rake +78 -136
- data/lib/active_record/readonly_attributes.rb +11 -0
- data/lib/active_record/reflection.rb +73 -50
- data/lib/active_record/relation/batches/batch_enumerator.rb +19 -5
- data/lib/active_record/relation/batches.rb +6 -6
- data/lib/active_record/relation/calculations.rb +43 -38
- data/lib/active_record/relation/delegation.rb +7 -7
- data/lib/active_record/relation/finder_methods.rb +31 -35
- data/lib/active_record/relation/merger.rb +20 -13
- data/lib/active_record/relation/predicate_builder.rb +1 -6
- data/lib/active_record/relation/query_attribute.rb +5 -11
- data/lib/active_record/relation/query_methods.rb +276 -67
- data/lib/active_record/relation/record_fetch_warning.rb +7 -9
- data/lib/active_record/relation/spawn_methods.rb +2 -2
- data/lib/active_record/relation/where_clause.rb +10 -19
- data/lib/active_record/relation.rb +189 -88
- data/lib/active_record/result.rb +17 -7
- data/lib/active_record/runtime_registry.rb +9 -13
- data/lib/active_record/sanitization.rb +17 -12
- data/lib/active_record/schema.rb +38 -23
- data/lib/active_record/schema_dumper.rb +25 -19
- data/lib/active_record/schema_migration.rb +4 -4
- data/lib/active_record/scoping/default.rb +60 -13
- data/lib/active_record/scoping/named.rb +3 -11
- data/lib/active_record/scoping.rb +64 -34
- data/lib/active_record/serialization.rb +6 -1
- data/lib/active_record/signed_id.rb +3 -3
- data/lib/active_record/store.rb +1 -1
- data/lib/active_record/suppressor.rb +11 -15
- data/lib/active_record/tasks/database_tasks.rb +127 -60
- data/lib/active_record/tasks/mysql_database_tasks.rb +1 -1
- data/lib/active_record/tasks/postgresql_database_tasks.rb +19 -13
- data/lib/active_record/test_databases.rb +1 -1
- data/lib/active_record/test_fixtures.rb +9 -6
- data/lib/active_record/timestamp.rb +3 -4
- data/lib/active_record/transactions.rb +9 -14
- data/lib/active_record/translation.rb +3 -3
- data/lib/active_record/type/adapter_specific_registry.rb +32 -7
- data/lib/active_record/type/hash_lookup_type_map.rb +34 -1
- data/lib/active_record/type/internal/timezone.rb +2 -2
- data/lib/active_record/type/serialized.rb +1 -1
- data/lib/active_record/type/type_map.rb +17 -20
- data/lib/active_record/type.rb +1 -2
- data/lib/active_record/validations/associated.rb +4 -4
- data/lib/active_record/validations/presence.rb +2 -2
- data/lib/active_record/validations/uniqueness.rb +4 -4
- data/lib/active_record/version.rb +1 -1
- data/lib/active_record.rb +225 -27
- data/lib/arel/attributes/attribute.rb +0 -8
- data/lib/arel/crud.rb +28 -22
- data/lib/arel/delete_manager.rb +18 -4
- data/lib/arel/filter_predications.rb +9 -0
- data/lib/arel/insert_manager.rb +2 -3
- data/lib/arel/nodes/casted.rb +1 -1
- data/lib/arel/nodes/delete_statement.rb +12 -13
- data/lib/arel/nodes/filter.rb +10 -0
- data/lib/arel/nodes/function.rb +1 -0
- data/lib/arel/nodes/insert_statement.rb +2 -2
- data/lib/arel/nodes/select_core.rb +2 -2
- data/lib/arel/nodes/select_statement.rb +2 -2
- data/lib/arel/nodes/update_statement.rb +8 -3
- data/lib/arel/nodes.rb +1 -0
- data/lib/arel/predications.rb +11 -3
- data/lib/arel/select_manager.rb +10 -4
- data/lib/arel/table.rb +0 -1
- data/lib/arel/tree_manager.rb +0 -12
- data/lib/arel/update_manager.rb +18 -4
- data/lib/arel/visitors/dot.rb +80 -90
- data/lib/arel/visitors/mysql.rb +8 -2
- data/lib/arel/visitors/postgresql.rb +0 -10
- data/lib/arel/visitors/to_sql.rb +58 -2
- data/lib/arel.rb +2 -1
- data/lib/rails/generators/active_record/application_record/templates/application_record.rb.tt +1 -1
- data/lib/rails/generators/active_record/model/templates/abstract_base_class.rb.tt +1 -1
- data/lib/rails/generators/active_record/model/templates/model.rb.tt +1 -1
- data/lib/rails/generators/active_record/model/templates/module.rb.tt +2 -2
- data/lib/rails/generators/active_record/multi_db/multi_db_generator.rb +16 -0
- data/lib/rails/generators/active_record/multi_db/templates/multi_db.rb.tt +44 -0
- metadata +53 -9
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 7.0.4.2 (January 24, 2023) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails
|
6
|
+
## Rails 7.0.4.1 (January 17, 2023) ##
|
7
7
|
|
8
8
|
* Make sanitize_as_sql_comment more strict
|
9
9
|
|
@@ -33,7 +33,8 @@
|
|
33
33
|
|
34
34
|
[CVE-2022-44566]
|
35
35
|
|
36
|
-
|
36
|
+
|
37
|
+
## Rails 7.0.4 (September 09, 2022) ##
|
37
38
|
|
38
39
|
* Symbol is allowed by default for YAML columns
|
39
40
|
|
@@ -46,13 +47,91 @@
|
|
46
47
|
|
47
48
|
*Jean Boussier*
|
48
49
|
|
49
|
-
*
|
50
|
+
* Add `timestamptz` as a time zone aware type for PostgreSQL
|
50
51
|
|
51
|
-
|
52
|
+
This is required for correctly parsing `timestamp with time zone` values in your database.
|
52
53
|
|
53
|
-
|
54
|
+
If you don't want this, you can opt out by adding this initializer:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
ActiveRecord::Base.time_zone_aware_types -= [:timestamptz]
|
58
|
+
```
|
59
|
+
|
60
|
+
*Alex Ghiculescu*
|
61
|
+
|
62
|
+
* Fix supporting timezone awareness for `tsrange` and `tstzrange` array columns.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
# In database migrations
|
66
|
+
add_column :shops, :open_hours, :tsrange, array: true
|
67
|
+
# In app config
|
68
|
+
ActiveRecord::Base.time_zone_aware_types += [:tsrange]
|
69
|
+
# In the code times are properly converted to app time zone
|
70
|
+
Shop.create!(open_hours: [Time.current..8.hour.from_now])
|
71
|
+
```
|
72
|
+
|
73
|
+
*Wojciech Wnętrzak*
|
74
|
+
|
75
|
+
* Resolve issue where a relation cache_version could be left stale.
|
54
76
|
|
55
|
-
|
77
|
+
Previously, when `reset` was called on a relation object it did not reset the cache_versions
|
78
|
+
ivar. This led to a confusing situation where despite having the correct data the relation
|
79
|
+
still reported a stale cache_version.
|
80
|
+
|
81
|
+
Usage:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
developers = Developer.all
|
85
|
+
developers.cache_version
|
86
|
+
|
87
|
+
Developer.update_all(updated_at: Time.now.utc + 1.second)
|
88
|
+
|
89
|
+
developers.cache_version # Stale cache_version
|
90
|
+
developers.reset
|
91
|
+
developers.cache_version # Returns the current correct cache_version
|
92
|
+
```
|
93
|
+
|
94
|
+
Fixes #45341.
|
95
|
+
|
96
|
+
*Austen Madden*
|
97
|
+
|
98
|
+
* Fix `load_async` when called on an association proxy.
|
99
|
+
|
100
|
+
Calling `load_async` directly an association would schedule
|
101
|
+
a query but never use it.
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
comments = post.comments.load_async # schedule a query
|
105
|
+
comments.to_a # perform an entirely new sync query
|
106
|
+
```
|
107
|
+
|
108
|
+
Now it does use the async query, however note that it doesn't
|
109
|
+
cause the association to be loaded.
|
110
|
+
|
111
|
+
*Jean Boussier*
|
112
|
+
|
113
|
+
* Fix eager loading for models without primary keys.
|
114
|
+
|
115
|
+
*Anmol Chopra*, *Matt Lawrence*, and *Jonathan Hefner*
|
116
|
+
|
117
|
+
* `rails db:schema:{dump,load}` now checks `ENV["SCHEMA_FORMAT"]` before config
|
118
|
+
|
119
|
+
Since `rails db:structure:{dump,load}` was deprecated there wasn't a simple
|
120
|
+
way to dump a schema to both SQL and Ruby formats. You can now do this with
|
121
|
+
an environment variable. For example:
|
122
|
+
|
123
|
+
```
|
124
|
+
SCHEMA_FORMAT=sql rake db:schema:dump
|
125
|
+
```
|
126
|
+
|
127
|
+
*Alex Ghiculescu*
|
128
|
+
|
129
|
+
* Fix Hstore deserialize regression.
|
130
|
+
|
131
|
+
*edsharp*
|
132
|
+
|
133
|
+
|
134
|
+
## Rails 7.0.3.1 (July 12, 2022) ##
|
56
135
|
|
57
136
|
* Change ActiveRecord::Coders::YAMLColumn default to safe_load
|
58
137
|
|
@@ -80,1723 +159,1932 @@
|
|
80
159
|
[CVE-2022-32224]
|
81
160
|
|
82
161
|
|
83
|
-
## Rails
|
162
|
+
## Rails 7.0.3 (May 09, 2022) ##
|
84
163
|
|
85
|
-
*
|
164
|
+
* Some internal housekeeping on reloads could break custom `respond_to?`
|
165
|
+
methods in class objects that referenced reloadable constants. See
|
166
|
+
[#44125](https://github.com/rails/rails/issues/44125) for details.
|
86
167
|
|
168
|
+
*Xavier Noria*
|
87
169
|
|
88
|
-
|
170
|
+
* Fixed MariaDB default function support.
|
89
171
|
|
90
|
-
|
172
|
+
Defaults would be written wrong in "db/schema.rb" and not work correctly
|
173
|
+
if using `db:schema:load`. Further more the function name would be
|
174
|
+
added as string content when saving new records.
|
91
175
|
|
176
|
+
*kaspernj*
|
92
177
|
|
93
|
-
|
178
|
+
* Fix `remove_foreign_key` with `:if_exists` option when foreign key actually exists.
|
94
179
|
|
95
|
-
*
|
180
|
+
*fatkodima*
|
96
181
|
|
97
|
-
|
98
|
-
In Ruby 2.6, the receiver of the `String#-@` method is modified under certain circumstances.
|
99
|
-
This was later identified as a bug (https://bugs.ruby-lang.org/issues/15926) and only
|
100
|
-
fixed in Ruby 2.7.
|
182
|
+
* Remove `--no-comments` flag in structure dumps for PostgreSQL
|
101
183
|
|
102
|
-
|
103
|
-
|
104
|
-
calls the `String#-@` method, could also modify an input string argument in Ruby 2.6 --
|
105
|
-
changing a tainted, unfrozen string into a tainted, frozen string.
|
184
|
+
This broke some apps that used custom schema comments. If you don't want
|
185
|
+
comments in your structure dump, you can use:
|
106
186
|
|
107
|
-
|
187
|
+
```ruby
|
188
|
+
ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = ['--no-comments']
|
189
|
+
```
|
108
190
|
|
109
|
-
*
|
191
|
+
*Alex Ghiculescu*
|
110
192
|
|
111
|
-
*
|
112
|
-
migration version is 6.0.
|
193
|
+
* Use the model name as a prefix when filtering encrypted attributes from logs.
|
113
194
|
|
114
|
-
`
|
115
|
-
|
195
|
+
For example, when encrypting `Person#name` it will add `person.name` as a filter
|
196
|
+
parameter, instead of just `name`. This prevents unintended filtering of parameters
|
197
|
+
with a matching name in other models.
|
116
198
|
|
117
|
-
*
|
199
|
+
*Jorge Manrubia*
|
118
200
|
|
119
|
-
* Fix
|
201
|
+
* Fix quoting of `ActiveSupport::Duration` and `Rational` numbers in the MySQL adapter.
|
120
202
|
|
121
|
-
*
|
203
|
+
*Kevin McPhillips*
|
122
204
|
|
123
|
-
*
|
205
|
+
* Fix `change_column_comment` to preserve column's AUTO_INCREMENT in the MySQL adapter
|
124
206
|
|
125
|
-
|
126
|
-
Post.create(name: "broken \xC8 UTF-8")
|
127
|
-
```
|
207
|
+
*fatkodima*
|
128
208
|
|
129
|
-
|
130
|
-
responsible to detect write queries.
|
209
|
+
## Rails 7.0.2.4 (April 26, 2022) ##
|
131
210
|
|
132
|
-
|
133
|
-
not be able to handle it, but will either succeed or failed in a more correct way.
|
211
|
+
* No changes.
|
134
212
|
|
135
|
-
*Jean Boussier*
|
136
213
|
|
137
|
-
|
214
|
+
## Rails 7.0.2.3 (March 08, 2022) ##
|
138
215
|
|
139
|
-
|
216
|
+
* No changes.
|
140
217
|
|
141
|
-
* Fix regression bug that caused ignoring additional conditions for preloading
|
142
|
-
`has_many` through relations.
|
143
218
|
|
144
|
-
|
219
|
+
## Rails 7.0.2.2 (February 11, 2022) ##
|
145
220
|
|
146
|
-
|
221
|
+
* No changes.
|
147
222
|
|
148
|
-
* Fix `ActiveRecord::InternalMetadata` to not be broken by
|
149
|
-
`config.active_record.record_timestamps = false`
|
150
223
|
|
151
|
-
|
152
|
-
various DB management tasks.
|
224
|
+
## Rails 7.0.2.1 (February 11, 2022) ##
|
153
225
|
|
154
|
-
|
226
|
+
* No changes.
|
155
227
|
|
156
|
-
*Jean Boussier*
|
157
228
|
|
158
|
-
|
229
|
+
## Rails 7.0.2 (February 08, 2022) ##
|
159
230
|
|
160
|
-
|
231
|
+
* Fix `PG.connect` keyword arguments deprecation warning on ruby 2.7.
|
161
232
|
|
162
|
-
*
|
233
|
+
*Nikita Vasilevsky*
|
163
234
|
|
164
|
-
|
235
|
+
* Fix the ability to exclude encryption params from being autofiltered.
|
165
236
|
|
166
|
-
*
|
237
|
+
*Mark Gangl*
|
167
238
|
|
168
|
-
*
|
239
|
+
* Dump the precision for datetime columns following the new defaults.
|
169
240
|
|
170
|
-
*
|
241
|
+
*Rafael Mendonça França*
|
171
242
|
|
172
|
-
*
|
243
|
+
* Make sure encrypted attributes are not being filtered twice.
|
173
244
|
|
174
|
-
*
|
245
|
+
*Nikita Vasilevsky*
|
175
246
|
|
247
|
+
* Dump the database schema containing the current Rails version.
|
176
248
|
|
177
|
-
|
249
|
+
Since https://github.com/rails/rails/pull/42297, Rails now generate datetime columns
|
250
|
+
with a default precision of 6. This means that users upgrading to Rails 7.0 from 6.1,
|
251
|
+
when loading the database schema, would get the new precision value, which would not match
|
252
|
+
the production schema.
|
178
253
|
|
179
|
-
|
254
|
+
To avoid this the schema dumper will generate the new format which will include the Rails
|
255
|
+
version and will look like this:
|
180
256
|
|
257
|
+
```
|
258
|
+
ActiveRecord::Schema[7.0].define
|
259
|
+
```
|
181
260
|
|
182
|
-
|
261
|
+
When upgrading from Rails 6.1 to Rails 7.0, you can run the `rails app:update` task that will
|
262
|
+
set the current schema version to 6.1.
|
183
263
|
|
184
|
-
*
|
264
|
+
*Rafael Mendonça França*
|
185
265
|
|
266
|
+
* Fix parsing expression for PostgreSQL generated column.
|
186
267
|
|
187
|
-
|
268
|
+
*fatkodima*
|
188
269
|
|
189
|
-
*
|
270
|
+
* Fix `Mysql2::Error: Commands out of sync; you can't run this command now`
|
271
|
+
when bulk-inserting fixtures that exceed `max_allowed_packet` configuration.
|
190
272
|
|
273
|
+
*Nikita Vasilevsky*
|
191
274
|
|
192
|
-
|
275
|
+
* Fix error when saving an association with a relation named `record`.
|
193
276
|
|
194
|
-
*
|
277
|
+
*Dorian Marié*
|
195
278
|
|
279
|
+
* Fix `MySQL::SchemaDumper` behavior about datetime precision value.
|
196
280
|
|
197
|
-
|
281
|
+
*y0t4*
|
198
282
|
|
199
|
-
*
|
283
|
+
* Improve associated with no reflection error.
|
200
284
|
|
285
|
+
*Nikolai*
|
201
286
|
|
202
|
-
|
287
|
+
* Fix PG.connect keyword arguments deprecation warning on ruby 2.7.
|
203
288
|
|
204
|
-
|
289
|
+
Fixes #44307.
|
205
290
|
|
291
|
+
*Nikita Vasilevsky*
|
206
292
|
|
207
|
-
|
293
|
+
* Fix passing options to `check_constraint` from `change_table`.
|
208
294
|
|
209
|
-
*
|
295
|
+
*Frederick Cheung*
|
210
296
|
|
211
297
|
|
212
|
-
## Rails
|
298
|
+
## Rails 7.0.1 (January 06, 2022) ##
|
213
299
|
|
214
|
-
* Do not try to rollback transactions that failed due to a `ActiveRecord::TransactionRollbackError`.
|
215
300
|
|
216
|
-
|
301
|
+
* Change `QueryMethods#in_order_of` to drop records not listed in values.
|
217
302
|
|
218
|
-
|
303
|
+
`in_order_of` now filters down to the values provided, to match the behavior of the `Enumerable` version.
|
219
304
|
|
220
|
-
*
|
305
|
+
*Kevin Newton*
|
221
306
|
|
222
|
-
*
|
307
|
+
* Allow named expression indexes to be revertible.
|
223
308
|
|
224
|
-
|
225
|
-
Active Record's schema cache loader and `YAMLColumn` now uses `YAML.unsafe_load` if available.
|
309
|
+
Previously, the following code would raise an error in a reversible migration executed while rolling back, due to the index name not being used in the index removal.
|
226
310
|
|
227
|
-
|
311
|
+
```ruby
|
312
|
+
add_index(:settings, "(data->'property')", using: :gin, name: :index_settings_data_property)
|
313
|
+
```
|
228
314
|
|
229
|
-
|
315
|
+
Fixes #43331.
|
230
316
|
|
231
|
-
*
|
317
|
+
*Oliver Günther*
|
232
318
|
|
233
|
-
*
|
319
|
+
* Better error messages when association name is invalid in the argument of `ActiveRecord::QueryMethods::WhereChain#missing`.
|
234
320
|
|
235
|
-
*
|
321
|
+
*ykpythemind*
|
236
322
|
|
237
|
-
*
|
323
|
+
* Fix ordered migrations for single db in multi db environment.
|
238
324
|
|
239
|
-
*
|
325
|
+
*Himanshu*
|
240
326
|
|
241
|
-
*
|
327
|
+
* Extract `on update CURRENT_TIMESTAMP` for mysql2 adapter.
|
242
328
|
|
243
|
-
*
|
329
|
+
*Kazuhiro Masuda*
|
244
330
|
|
245
|
-
*
|
331
|
+
* Fix incorrect argument in PostgreSQL structure dump tasks.
|
246
332
|
|
247
|
-
|
333
|
+
Updating the `--no-comment` argument added in Rails 7 to the correct `--no-comments` argument.
|
248
334
|
|
249
|
-
*
|
250
|
-
`quoted_node` so that PostgreSQL arrays are quoted properly.
|
335
|
+
*Alex Dent*
|
251
336
|
|
252
|
-
|
337
|
+
* Fix schema dumping column default SQL values for sqlite3.
|
253
338
|
|
254
|
-
*
|
339
|
+
*fatkodima*
|
255
340
|
|
256
|
-
|
341
|
+
* Correctly parse complex check constraint expressions for PostgreSQL.
|
257
342
|
|
258
|
-
*
|
343
|
+
*fatkodima*
|
259
344
|
|
260
|
-
|
345
|
+
* Fix `timestamptz` attributes on PostgreSQL handle blank inputs.
|
346
|
+
|
347
|
+
*Alex Ghiculescu*
|
348
|
+
|
349
|
+
* Fix migration compatibility to create SQLite references/belongs_to column as integer when migration version is 6.0.
|
261
350
|
|
262
|
-
|
351
|
+
Reference/belongs_to in migrations with version 6.0 were creating columns as
|
352
|
+
bigint instead of integer for the SQLite Adapter.
|
353
|
+
|
354
|
+
*Marcelo Lauxen*
|
263
355
|
|
264
|
-
|
356
|
+
* Fix joining through a polymorphic association.
|
265
357
|
|
266
|
-
*
|
358
|
+
*Alexandre Ruban*
|
267
359
|
|
268
|
-
|
269
|
-
relation set `strict_loading` to false the false wasn't considered when
|
270
|
-
deciding whether to raise/warn about strict loading.
|
360
|
+
* Fix `QueryMethods#in_order_of` to handle empty order list.
|
271
361
|
|
362
|
+
```ruby
|
363
|
+
Post.in_order_of(:id, []).to_a
|
272
364
|
```
|
273
|
-
class Dog < ActiveRecord::Base
|
274
|
-
self.strict_loading_by_default = true
|
275
365
|
|
276
|
-
|
366
|
+
Also more explicitly set the column as secondary order, so that any other
|
367
|
+
value is still ordered.
|
368
|
+
|
369
|
+
*Jean Boussier*
|
370
|
+
|
371
|
+
* Fix `rails dbconsole` for 3-tier config.
|
372
|
+
|
373
|
+
*Eileen M. Uchitelle*
|
374
|
+
|
375
|
+
* Fix quoting of column aliases generated by calculation methods.
|
376
|
+
|
377
|
+
Since the alias is derived from the table name, we can't assume the result
|
378
|
+
is a valid identifier.
|
379
|
+
|
380
|
+
```ruby
|
381
|
+
class Test < ActiveRecord::Base
|
382
|
+
self.table_name = '1abc'
|
277
383
|
end
|
384
|
+
Test.group(:id).count
|
385
|
+
# syntax error at or near "1" (ActiveRecord::StatementInvalid)
|
386
|
+
# LINE 1: SELECT COUNT(*) AS count_all, "1abc"."id" AS 1abc_id FROM "1...
|
278
387
|
```
|
279
388
|
|
280
|
-
|
281
|
-
`strict_loading` was set to false. This is a bug affecting more than
|
282
|
-
Active Storage which is why I made this PR superseding #41461. We need
|
283
|
-
to fix this for all applications since the behavior is a little
|
284
|
-
surprising. I took the test from #41461 and the code suggestion from #41453
|
285
|
-
with some additions.
|
286
|
-
|
287
|
-
*Eileen M. Uchitelle*, *Radamés Roriz*
|
389
|
+
*Jean Boussier*
|
288
390
|
|
289
|
-
* Fix numericality validator without precision.
|
290
391
|
|
291
|
-
|
392
|
+
## Rails 7.0.0 (December 15, 2021) ##
|
292
393
|
|
293
|
-
*
|
394
|
+
* Better handle SQL queries with invalid encoding.
|
294
395
|
|
295
|
-
|
396
|
+
```ruby
|
397
|
+
Post.create(name: "broken \xC8 UTF-8")
|
398
|
+
```
|
296
399
|
|
297
|
-
|
400
|
+
Would cause all adapters to fail in a non controlled way in the code
|
401
|
+
responsible to detect write queries.
|
298
402
|
|
299
|
-
|
403
|
+
The query is now properly passed to the database connection, which might or might
|
404
|
+
not be able to handle it, but will either succeed or failed in a more correct way.
|
300
405
|
|
301
|
-
*
|
406
|
+
*Jean Boussier*
|
302
407
|
|
303
|
-
|
408
|
+
* Move database and shard selection config options to a generator.
|
304
409
|
|
305
|
-
|
410
|
+
Rather than generating the config options in `production.rb` when applications are created, applications can now run a generator to create an initializer and uncomment / update options as needed. All multi-db configuration can be implemented in this initializer.
|
306
411
|
|
307
|
-
*
|
412
|
+
*Eileen M. Uchitelle*
|
308
413
|
|
309
414
|
|
310
|
-
## Rails
|
415
|
+
## Rails 7.0.0.rc3 (December 14, 2021) ##
|
311
416
|
|
312
417
|
* No changes.
|
313
418
|
|
314
419
|
|
315
|
-
## Rails
|
420
|
+
## Rails 7.0.0.rc2 (December 14, 2021) ##
|
316
421
|
|
317
422
|
* No changes.
|
318
423
|
|
319
424
|
|
320
|
-
## Rails
|
425
|
+
## Rails 7.0.0.rc1 (December 06, 2021) ##
|
321
426
|
|
322
|
-
*
|
323
|
-
to the connection session.
|
427
|
+
* Remove deprecated `ActiveRecord::DatabaseConfigurations::DatabaseConfig#spec_name`.
|
324
428
|
|
325
429
|
*Rafael Mendonça França*
|
326
430
|
|
327
|
-
*
|
328
|
-
are enabled.
|
431
|
+
* Remove deprecated `ActiveRecord::Connection#in_clause_length`.
|
329
432
|
|
330
433
|
*Rafael Mendonça França*
|
331
434
|
|
332
|
-
*
|
333
|
-
an `IN` clause.
|
435
|
+
* Remove deprecated `ActiveRecord::Connection#allowed_index_name_length`.
|
334
436
|
|
335
|
-
*
|
437
|
+
*Rafael Mendonça França*
|
336
438
|
|
337
|
-
*
|
338
|
-
with a having clause
|
439
|
+
* Remove deprecated `ActiveRecord::Base#remove_connection`.
|
339
440
|
|
340
|
-
|
341
|
-
references an aliased select value would generate an error when
|
342
|
-
#include? was called, due to an optimisation that would generate
|
343
|
-
call #exists? on the relation instead, which effectively alters
|
344
|
-
the select values of the query (and thus removes the aliased select
|
345
|
-
values), but leaves the having clause intact. Because the having
|
346
|
-
clause is then referencing an aliased column that is no longer
|
347
|
-
present in the simplified query, an ActiveRecord::InvalidStatement
|
348
|
-
error was raised.
|
441
|
+
*Rafael Mendonça França*
|
349
442
|
|
350
|
-
|
443
|
+
* Load STI Models in fixtures
|
351
444
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
.group(:id)
|
356
|
-
.having('total_posts > 2')
|
357
|
-
.include?(Author.first)
|
358
|
-
```
|
445
|
+
Data from Fixtures now loads based on the specific class for models with
|
446
|
+
Single Table Inheritance. This affects enums defined in subclasses, previously
|
447
|
+
the value of these fields was not parsed and remained `nil`
|
359
448
|
|
360
|
-
|
361
|
-
simplified #exists? query, which simply checks for the presence of
|
362
|
-
a having clause.
|
449
|
+
*Andres Howard*
|
363
450
|
|
364
|
-
|
451
|
+
* `#authenticate` returns false when the password is blank instead of raising an error.
|
365
452
|
|
366
|
-
*
|
453
|
+
*Muhammad Muhammad Ibrahim*
|
367
454
|
|
368
|
-
*
|
369
|
-
without Rails knowledge (e.g., if app gets kill -9d during long-running query or due to Rack::Timeout), app won't end
|
370
|
-
up in perpetual crash state for being inconsistent with Postgres.
|
455
|
+
* Fix `ActiveRecord::QueryMethods#in_order_of` behavior for integer enums.
|
371
456
|
|
372
|
-
|
457
|
+
`ActiveRecord::QueryMethods#in_order_of` didn't work as expected for enums stored as integers in the database when passing an array of strings or symbols as the order argument. This unexpected behavior occurred because the string or symbol values were not casted to match the integers in the database.
|
373
458
|
|
459
|
+
The following example now works as expected:
|
374
460
|
|
375
|
-
|
461
|
+
```ruby
|
462
|
+
class Book < ApplicationRecord
|
463
|
+
enum status: [:proposed, :written, :published]
|
464
|
+
end
|
376
465
|
|
377
|
-
|
466
|
+
Book.in_order_of(:status, %w[written published proposed])
|
467
|
+
```
|
378
468
|
|
379
|
-
|
380
|
-
for validating the money format in the PostgreSQL adapter. This patch
|
381
|
-
fixes the regexp.
|
469
|
+
*Alexandre Ruban*
|
382
470
|
|
383
|
-
|
471
|
+
* Ignore persisted in-memory records when merging target lists.
|
384
472
|
|
385
|
-
|
473
|
+
*Kevin Sjöberg*
|
386
474
|
|
387
|
-
|
475
|
+
* Add a new option `:update_only` to `upsert_all` to configure the list of columns to update in case of conflict.
|
388
476
|
|
477
|
+
Before, you could only customize the update SQL sentence via `:on_duplicate`. There is now a new option `:update_only` that lets you provide a list of columns to update in case of conflict:
|
389
478
|
|
390
|
-
|
479
|
+
```ruby
|
480
|
+
Commodity.upsert_all(
|
481
|
+
[
|
482
|
+
{ id: 2, name: "Copper", price: 4.84 },
|
483
|
+
{ id: 4, name: "Gold", price: 1380.87 },
|
484
|
+
{ id: 6, name: "Aluminium", price: 0.35 }
|
485
|
+
],
|
486
|
+
update_only: [:price] # Only prices will be updated
|
487
|
+
)
|
488
|
+
```
|
391
489
|
|
392
|
-
*
|
490
|
+
*Jorge Manrubia*
|
393
491
|
|
394
|
-
|
492
|
+
* Remove deprecated `ActiveRecord::Result#map!` and `ActiveRecord::Result#collect!`.
|
395
493
|
|
396
|
-
*
|
494
|
+
*Rafael Mendonça França*
|
397
495
|
|
398
|
-
|
399
|
-
case the job would enqueue even though the database deletion
|
400
|
-
rolledback putting things in a funky state.
|
496
|
+
* Remove deprecated `ActiveRecord::Base.configurations.to_h`.
|
401
497
|
|
402
|
-
|
498
|
+
*Rafael Mendonça França*
|
403
499
|
|
404
|
-
|
500
|
+
* Remove deprecated `ActiveRecord::Base.configurations.default_hash`.
|
405
501
|
|
406
|
-
*
|
502
|
+
*Rafael Mendonça França*
|
407
503
|
|
408
|
-
|
504
|
+
* Remove deprecated `ActiveRecord::Base.arel_attribute`.
|
409
505
|
|
410
|
-
*
|
411
|
-
adapter if the "url" protocol is "jdbc", "http", or "https". Previously only
|
412
|
-
urls with the "jdbc" prefix were passed to the Active Record Adapter, others
|
413
|
-
are assumed to be adapter specification urls.
|
506
|
+
*Rafael Mendonça França*
|
414
507
|
|
415
|
-
|
508
|
+
* Remove deprecated `ActiveRecord::Base.connection_config`.
|
416
509
|
|
417
|
-
*
|
510
|
+
*Rafael Mendonça França*
|
418
511
|
|
419
|
-
*
|
512
|
+
* Filter attributes in SQL logs
|
420
513
|
|
421
|
-
|
514
|
+
Previously, SQL queries in logs containing `ActiveRecord::Base.filter_attributes` were not filtered.
|
422
515
|
|
423
|
-
|
516
|
+
Now, the filter attributes will be masked `[FILTERED]` in the logs when `prepared_statement` is enabled.
|
424
517
|
|
425
|
-
|
518
|
+
```
|
519
|
+
# Before:
|
520
|
+
Foo Load (0.2ms) SELECT "foos".* FROM "foos" WHERE "foos"."passw" = ? LIMIT ? [["passw", "hello"], ["LIMIT", 1]]
|
426
521
|
|
427
|
-
|
522
|
+
# After:
|
523
|
+
Foo Load (0.5ms) SELECT "foos".* FROM "foos" WHERE "foos"."passw" = ? LIMIT ? [["passw", "[FILTERED]"], ["LIMIT", 1]]
|
524
|
+
```
|
428
525
|
|
429
|
-
*
|
526
|
+
*Aishwarya Subramanian*
|
430
527
|
|
431
|
-
*
|
528
|
+
* Remove deprecated `Tasks::DatabaseTasks.spec`.
|
432
529
|
|
433
|
-
*
|
530
|
+
*Rafael Mendonça França*
|
434
531
|
|
435
|
-
*
|
532
|
+
* Remove deprecated `Tasks::DatabaseTasks.current_config`.
|
436
533
|
|
437
|
-
*
|
534
|
+
*Rafael Mendonça França*
|
438
535
|
|
536
|
+
* Deprecate `Tasks::DatabaseTasks.schema_file_type`.
|
439
537
|
|
440
|
-
|
538
|
+
*Rafael Mendonça França*
|
441
539
|
|
442
|
-
*
|
540
|
+
* Remove deprecated `Tasks::DatabaseTasks.dump_filename`.
|
443
541
|
|
444
|
-
*
|
542
|
+
*Rafael Mendonça França*
|
445
543
|
|
446
|
-
*
|
544
|
+
* Remove deprecated `Tasks::DatabaseTasks.schema_file`.
|
447
545
|
|
448
|
-
*
|
546
|
+
*Rafael Mendonça França*
|
449
547
|
|
450
|
-
*
|
548
|
+
* Remove deprecated `environment` and `name` arguments from `Tasks::DatabaseTasks.schema_up_to_date?`.
|
451
549
|
|
452
|
-
*
|
550
|
+
*Rafael Mendonça França*
|
453
551
|
|
454
|
-
*
|
552
|
+
* Merging conditions on the same column no longer maintain both conditions,
|
553
|
+
and will be consistently replaced by the latter condition.
|
455
554
|
|
456
|
-
|
555
|
+
```ruby
|
556
|
+
# Rails 6.1 (IN clause is replaced by merger side equality condition)
|
557
|
+
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
|
558
|
+
# Rails 6.1 (both conflict conditions exists, deprecated)
|
559
|
+
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
|
560
|
+
# Rails 6.1 with rewhere to migrate to Rails 7.0's behavior
|
561
|
+
Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob]
|
562
|
+
# Rails 7.0 (same behavior with IN clause, mergee side condition is consistently replaced)
|
563
|
+
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
|
564
|
+
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]
|
457
565
|
|
458
|
-
*
|
566
|
+
*Rafael Mendonça França*
|
459
567
|
|
460
|
-
|
568
|
+
* Remove deprecated support to `Model.reorder(nil).first` to search using non-deterministic order.
|
461
569
|
|
462
|
-
*
|
570
|
+
*Rafael Mendonça França*
|
463
571
|
|
464
|
-
|
572
|
+
* Remove deprecated rake tasks:
|
465
573
|
|
466
|
-
*
|
574
|
+
* `db:schema:load_if_ruby`
|
575
|
+
* `db:structure:dump`
|
576
|
+
* `db:structure:load`
|
577
|
+
* `db:structure:load_if_sql`
|
578
|
+
* `db:structure:dump:#{name}`
|
579
|
+
* `db:structure:load:#{name}`
|
580
|
+
* `db:test:load_structure`
|
581
|
+
* `db:test:load_structure:#{name}`
|
467
582
|
|
468
583
|
*Rafael Mendonça França*
|
469
584
|
|
470
|
-
*
|
471
|
-
|
472
|
-
*Ryuta Kamizono*
|
473
|
-
|
474
|
-
* Handle STI models for `has_many dependent: :destroy_async`.
|
585
|
+
* Remove deprecated `DatabaseConfig#config` method.
|
475
586
|
|
476
|
-
*
|
587
|
+
*Rafael Mendonça França*
|
477
588
|
|
478
|
-
*
|
589
|
+
* Rollback transactions when the block returns earlier than expected.
|
479
590
|
|
480
|
-
|
481
|
-
to throw an error saying :polymorphic would not be a valid option.
|
591
|
+
Before this change, when a transaction block returned early, the transaction would be committed.
|
482
592
|
|
483
|
-
|
593
|
+
The problem is that timeouts triggered inside the transaction block was also making the incomplete transaction
|
594
|
+
to be committed, so in order to avoid this mistake, the transaction block is rolled back.
|
484
595
|
|
485
|
-
*
|
596
|
+
*Rafael Mendonça França*
|
486
597
|
|
487
|
-
|
598
|
+
* Add middleware for automatic shard swapping.
|
488
599
|
|
489
|
-
|
490
|
-
and the index name should be specified explicitly. Now, the index name is inferred
|
491
|
-
automatically.
|
600
|
+
Provides a basic middleware to perform automatic shard swapping. Applications will provide a resolver which will determine for an individual request which shard should be used. Example:
|
492
601
|
|
493
602
|
```ruby
|
494
|
-
|
603
|
+
config.active_record.shard_resolver = ->(request) {
|
604
|
+
subdomain = request.subdomain
|
605
|
+
tenant = Tenant.find_by_subdomain!(subdomain)
|
606
|
+
tenant.shard
|
607
|
+
}
|
495
608
|
```
|
496
609
|
|
497
|
-
|
610
|
+
See guides for more details.
|
498
611
|
|
612
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
499
613
|
|
500
|
-
|
614
|
+
* Remove deprecated support to pass a column to `type_cast`.
|
501
615
|
|
502
|
-
*
|
616
|
+
*Rafael Mendonça França*
|
503
617
|
|
504
|
-
|
618
|
+
* Remove deprecated support to type cast to database values `ActiveRecord::Base` objects.
|
505
619
|
|
506
|
-
*
|
620
|
+
*Rafael Mendonça França*
|
507
621
|
|
508
|
-
*
|
622
|
+
* Remove deprecated support to quote `ActiveRecord::Base` objects.
|
509
623
|
|
510
624
|
*Rafael Mendonça França*
|
511
625
|
|
512
|
-
*
|
626
|
+
* Remove deprecacated support to resolve connection using `"primary"` as connection specification name.
|
513
627
|
|
514
|
-
|
628
|
+
*Rafael Mendonça França*
|
515
629
|
|
516
|
-
|
630
|
+
* Remove deprecation warning when using `:interval` column is used in PostgreSQL database.
|
517
631
|
|
518
|
-
|
632
|
+
Now, interval columns will return `ActiveSupport::Duration` objects instead of strings.
|
519
633
|
|
520
|
-
|
521
|
-
class AdminAuthor
|
522
|
-
delegate_missing_to :@author
|
634
|
+
To keep the old behavior, you can add this line to your model:
|
523
635
|
|
524
|
-
|
525
|
-
|
526
|
-
end
|
527
|
-
end
|
528
|
-
|
529
|
-
Post.where(author: AdminAuthor.new(author))
|
636
|
+
```ruby
|
637
|
+
attribute :column, :string
|
530
638
|
```
|
531
639
|
|
532
|
-
*
|
640
|
+
*Rafael Mendonça França*
|
533
641
|
|
534
|
-
*
|
642
|
+
* Remove deprecated support to YAML load `ActiveRecord::Base` instance in the Rails 4.2 and 4.1 formats.
|
535
643
|
|
536
|
-
|
644
|
+
*Rafael Mendonça França*
|
537
645
|
|
538
|
-
|
646
|
+
* Remove deprecated option `:spec_name` in the `configs_for` method.
|
539
647
|
|
540
|
-
|
541
|
-
MealsRecord.connected_to(role: :reading) do
|
542
|
-
Dog.first # read from animals replica
|
543
|
-
Dinner.first # read from meals replica
|
544
|
-
Person.first # read from primary writer
|
545
|
-
end
|
546
|
-
end
|
648
|
+
*Rafael Mendonça França*
|
547
649
|
|
548
|
-
|
650
|
+
* Remove deprecated `ActiveRecord::Base.allow_unsafe_raw_sql`.
|
549
651
|
|
550
|
-
|
551
|
-
Dog.first # read from animals replica
|
552
|
-
Dinner.first # read from meals replica
|
553
|
-
Person.first # read from primary writer
|
554
|
-
end
|
652
|
+
*Rafael Mendonça França*
|
555
653
|
|
556
|
-
|
654
|
+
* Fix regression bug that caused ignoring additional conditions for preloading has_many-through relations.
|
557
655
|
|
558
|
-
|
656
|
+
Fixes #43132
|
559
657
|
|
560
|
-
|
658
|
+
*Alexander Pauly*
|
561
659
|
|
562
|
-
|
660
|
+
* Fix `has_many` inversing recursion on models with recursive associations.
|
563
661
|
|
564
|
-
*
|
662
|
+
*Gannon McGibbon*
|
565
663
|
|
566
|
-
*
|
664
|
+
* Add `accepts_nested_attributes_for` support for `delegated_type`
|
567
665
|
|
568
|
-
|
666
|
+
```ruby
|
667
|
+
class Entry < ApplicationRecord
|
668
|
+
delegated_type :entryable, types: %w[ Message Comment ]
|
669
|
+
accepts_nested_attributes_for :entryable
|
670
|
+
end
|
569
671
|
|
570
|
-
|
672
|
+
entry = Entry.create(entryable_type: 'Message', entryable_attributes: { content: 'Hello world' })
|
673
|
+
# => #<Entry:0x00>
|
674
|
+
# id: 1
|
675
|
+
# entryable_id: 1,
|
676
|
+
# entryable_type: 'Message'
|
677
|
+
# ...>
|
678
|
+
|
679
|
+
entry.entryable
|
680
|
+
# => #<Message:0x01>
|
681
|
+
# id: 1
|
682
|
+
# content: 'Hello world'
|
683
|
+
# ...>
|
684
|
+
```
|
571
685
|
|
572
|
-
|
686
|
+
Previously it would raise an error:
|
573
687
|
|
574
|
-
|
688
|
+
```ruby
|
689
|
+
Entry.create(entryable_type: 'Message', entryable_attributes: { content: 'Hello world' })
|
690
|
+
# ArgumentError: Cannot build association `entryable'. Are you trying to build a polymorphic one-to-one association?
|
691
|
+
```
|
575
692
|
|
576
|
-
|
693
|
+
*Sjors Baltus*
|
577
694
|
|
578
|
-
|
695
|
+
* Use subquery for DELETE with GROUP_BY and HAVING clauses.
|
579
696
|
|
580
|
-
|
697
|
+
Prior to this change, deletes with GROUP_BY and HAVING were returning an error.
|
581
698
|
|
582
|
-
|
583
|
-
no longer enforce case sensitive comparison by default.
|
699
|
+
After this change, GROUP_BY and HAVING are valid clauses in DELETE queries, generating the following query:
|
584
700
|
|
585
|
-
|
701
|
+
```sql
|
702
|
+
DELETE FROM "posts" WHERE "posts"."id" IN (
|
703
|
+
SELECT "posts"."id" FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id" GROUP BY "posts"."id" HAVING (count(comments.id) >= 2))
|
704
|
+
) [["flagged", "t"]]
|
705
|
+
```
|
586
706
|
|
587
|
-
*
|
707
|
+
*Ignacio Chiazzo Cardarello*
|
588
708
|
|
589
|
-
|
590
|
-
`table_name_length`
|
591
|
-
`columns_per_table`
|
592
|
-
`indexes_per_table`
|
593
|
-
`columns_per_multicolumn_index`
|
594
|
-
`sql_query_length`
|
595
|
-
`joins_per_query`
|
709
|
+
* Use subquery for UPDATE with GROUP_BY and HAVING clauses.
|
596
710
|
|
597
|
-
|
711
|
+
Prior to this change, updates with GROUP_BY and HAVING were being ignored, generating a SQL like this:
|
598
712
|
|
599
|
-
|
713
|
+
```sql
|
714
|
+
UPDATE "posts" SET "flagged" = ? WHERE "posts"."id" IN (
|
715
|
+
SELECT "posts"."id" FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
|
716
|
+
) [["flagged", "t"]]
|
717
|
+
```
|
600
718
|
|
601
|
-
|
719
|
+
After this change, GROUP_BY and HAVING clauses are used as a subquery in updates, like this:
|
602
720
|
|
603
|
-
|
721
|
+
```sql
|
722
|
+
UPDATE "posts" SET "flagged" = ? WHERE "posts"."id" IN (
|
723
|
+
SELECT "posts"."id" FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
|
724
|
+
GROUP BY posts.id HAVING (count(comments.id) >= 2)
|
725
|
+
) [["flagged", "t"]]
|
726
|
+
```
|
604
727
|
|
605
|
-
*
|
728
|
+
*Ignacio Chiazzo Cardarello*
|
606
729
|
|
607
|
-
*
|
730
|
+
* Add support for setting the filename of the schema or structure dump in the database config.
|
608
731
|
|
609
|
-
|
732
|
+
Applications may now set their the filename or path of the schema / structure dump file in their database configuration.
|
610
733
|
|
611
|
-
|
734
|
+
```yaml
|
735
|
+
production:
|
736
|
+
primary:
|
737
|
+
database: my_db
|
738
|
+
schema_dump: my_schema_dump_filename.rb
|
739
|
+
animals:
|
740
|
+
database: animals_db
|
741
|
+
schema_dump: false
|
742
|
+
```
|
612
743
|
|
613
|
-
|
744
|
+
The filename set in `schema_dump` will be used by the application. If set to `false` the schema will not be dumped. The database tasks are responsible for adding the database directory to the filename. If a full path is provided, the Rails tasks will use that instead of `ActiveRecord::DatabaseTasks.db_dir`.
|
614
745
|
|
615
|
-
*
|
746
|
+
*Eileen M. Uchitelle*, *Ryan Kerr*
|
616
747
|
|
617
|
-
|
748
|
+
* Add `ActiveRecord::Base.prohibit_shard_swapping` to prevent attempts to change the shard within a block.
|
618
749
|
|
619
|
-
*
|
750
|
+
*John Crepezzi*, *Eileen M. Uchitelle*
|
620
751
|
|
621
|
-
|
752
|
+
* Filter unchanged attributes with default function from insert query when `partial_inserts` is disabled.
|
622
753
|
|
623
|
-
*
|
624
|
-
in initialization block and callbacks.
|
754
|
+
*Akshay Birajdar*, *Jacopo Beschi*
|
625
755
|
|
626
|
-
|
756
|
+
* Add support for FILTER clause (SQL:2003) to Arel.
|
627
757
|
|
628
|
-
|
629
|
-
User.find_by(name: "David") # => nil
|
630
|
-
end
|
758
|
+
Currently supported by PostgreSQL 9.4+ and SQLite 3.30+.
|
631
759
|
|
632
|
-
|
760
|
+
*Andrey Novikov*
|
633
761
|
|
634
|
-
|
635
|
-
User.find_by(name: "David") # => #<User name: "David", ...>
|
636
|
-
end
|
762
|
+
* Automatically set timestamps on record creation during bulk insert/upsert
|
637
763
|
|
638
|
-
|
764
|
+
Prior to this change, only updates during an upsert operation (e.g. `upsert_all`) would touch timestamps (`updated_{at,on}`). Now, record creations also touch timestamp columns (`{created,updated}_{at,on}`).
|
639
765
|
|
640
|
-
|
766
|
+
This behaviour is controlled by the `<model>.record_timestamps` config, matching the behaviour of `create`, `update`, etc. It can also be overridden by using the `record_timestamps:` keyword argument.
|
641
767
|
|
642
|
-
|
643
|
-
scope :david, -> { User.where(name: "David") }
|
644
|
-
end
|
768
|
+
Note that this means `upsert_all` on models with `record_timestamps = false` will no longer touch `updated_{at,on}` automatically.
|
645
769
|
|
646
|
-
|
770
|
+
*Sam Bostock*
|
647
771
|
|
648
|
-
|
649
|
-
# SELECT * FROM users WHERE name = 'John' AND name = 'David'
|
772
|
+
* Don't require `role` when passing `shard` to `connected_to`.
|
650
773
|
|
651
|
-
|
774
|
+
`connected_to` can now be called with a `shard` only. Note that `role` is still inherited if `connected_to` calls are nested.
|
652
775
|
|
653
|
-
|
654
|
-
# SELECT * FROM users WHERE name = 'David'
|
776
|
+
*Eileen M. Uchitelle*
|
655
777
|
|
656
|
-
|
778
|
+
* Add option to lazily load the schema cache on the connection.
|
657
779
|
|
658
|
-
|
780
|
+
Previously, the only way to load the schema cache in Active Record was through the Railtie on boot. This option provides the ability to load the schema cache on the connection after it's been established. Loading the cache lazily on the connection can be beneficial for Rails applications that use multiple databases because it will load the cache at the time the connection is established. Currently Railties doesn't have access to the connections before boot.
|
659
781
|
|
660
|
-
`
|
661
|
-
`each`
|
662
|
-
`first`
|
663
|
-
`values`
|
664
|
-
`[]=`
|
782
|
+
To use the cache, set `config.active_record.lazily_load_schema_cache = true` in your application configuration. In addition a `schema_cache_path` should be set in your database configuration if you don't want to use the default "db/schema_cache.yml" path.
|
665
783
|
|
666
|
-
*
|
784
|
+
*Eileen M. Uchitelle*
|
667
785
|
|
668
|
-
* `
|
786
|
+
* Allow automatic `inverse_of` detection for associations with scopes.
|
669
787
|
|
670
|
-
|
788
|
+
Automatic `inverse_of` detection now works for associations with scopes. For
|
789
|
+
example, the `comments` association here now automatically detects
|
790
|
+
`inverse_of: :post`, so we don't need to pass that option:
|
671
791
|
|
672
|
-
|
673
|
-
|
792
|
+
```ruby
|
793
|
+
class Post < ActiveRecord::Base
|
794
|
+
has_many :comments, -> { visible }
|
795
|
+
end
|
674
796
|
|
675
|
-
|
797
|
+
class Comment < ActiveRecord::Base
|
798
|
+
belongs_to :post
|
799
|
+
end
|
800
|
+
```
|
676
801
|
|
677
|
-
|
678
|
-
|
802
|
+
Note that the automatic detection still won't work if the inverse
|
803
|
+
association has a scope. In this example a scope on the `post` association
|
804
|
+
would still prevent Rails from finding the inverse for the `comments`
|
805
|
+
association.
|
679
806
|
|
680
|
-
|
807
|
+
This will be the default for new apps in Rails 7. To opt in:
|
808
|
+
|
809
|
+
```ruby
|
810
|
+
config.active_record.automatic_scope_inversing = true
|
811
|
+
```
|
681
812
|
|
682
|
-
*
|
813
|
+
*Daniel Colson*, *Chris Bloom*
|
683
814
|
|
684
|
-
|
815
|
+
* Accept optional transaction args to `ActiveRecord::Locking::Pessimistic#with_lock`
|
685
816
|
|
686
|
-
|
817
|
+
`#with_lock` now accepts transaction options like `requires_new:`,
|
818
|
+
`isolation:`, and `joinable:`
|
687
819
|
|
688
|
-
*
|
820
|
+
*John Mileham*
|
689
821
|
|
690
|
-
*
|
822
|
+
* Adds support for deferrable foreign key constraints in PostgreSQL.
|
691
823
|
|
692
|
-
|
824
|
+
By default, foreign key constraints in PostgreSQL are checked after each statement. This works for most use cases,
|
825
|
+
but becomes a major limitation when creating related records before the parent record is inserted into the database.
|
826
|
+
One example of this is looking up / creating a person via one or more unique alias.
|
693
827
|
|
694
|
-
|
695
|
-
|
828
|
+
```ruby
|
829
|
+
Person.transaction do
|
830
|
+
alias = Alias
|
831
|
+
.create_with(user_id: SecureRandom.uuid)
|
832
|
+
.create_or_find_by(name: "DHH")
|
833
|
+
|
834
|
+
person = Person
|
835
|
+
.create_with(name: "David Heinemeier Hansson")
|
836
|
+
.create_or_find_by(id: alias.user_id)
|
837
|
+
end
|
838
|
+
```
|
696
839
|
|
697
|
-
|
840
|
+
Using the default behavior, the transaction would fail when executing the first `INSERT` statement.
|
698
841
|
|
699
|
-
|
842
|
+
By passing the `:deferrable` option to the `add_foreign_key` statement in migrations, it's possible to defer this
|
843
|
+
check.
|
700
844
|
|
701
|
-
|
845
|
+
```ruby
|
846
|
+
add_foreign_key :aliases, :person, deferrable: true
|
847
|
+
```
|
702
848
|
|
703
|
-
|
849
|
+
Passing `deferrable: true` doesn't change the default behavior, but allows manually deferring the check using
|
850
|
+
`SET CONSTRAINTS ALL DEFERRED` within a transaction. This will cause the foreign keys to be checked after the
|
851
|
+
transaction.
|
704
852
|
|
705
|
-
|
853
|
+
It's also possible to adjust the default behavior from an immediate check (after the statement), to a deferred check
|
854
|
+
(after the transaction):
|
706
855
|
|
707
856
|
```ruby
|
708
|
-
|
709
|
-
|
710
|
-
Dog.first # reads from default replica
|
857
|
+
add_foreign_key :aliases, :person, deferrable: :deferred
|
858
|
+
```
|
711
859
|
|
712
|
-
|
713
|
-
User.first # reads from default replica
|
714
|
-
Dog.first # reads from shard one primary
|
715
|
-
end
|
860
|
+
*Benedikt Deicke*
|
716
861
|
|
717
|
-
|
718
|
-
Dog.first # reads from default replica
|
862
|
+
* Allow configuring Postgres password through the socket URL.
|
719
863
|
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
864
|
+
For example:
|
865
|
+
```ruby
|
866
|
+
ActiveRecord::DatabaseConfigurations::UrlConfig.new(
|
867
|
+
:production, :production, 'postgres:///?user=user&password=secret&dbname=app', {}
|
868
|
+
).configuration_hash
|
725
869
|
```
|
726
870
|
|
727
|
-
|
871
|
+
will now return,
|
728
872
|
|
729
|
-
|
873
|
+
```ruby
|
874
|
+
{ :user=>"user", :password=>"secret", :dbname=>"app", :adapter=>"postgresql" }
|
875
|
+
```
|
730
876
|
|
731
|
-
*
|
877
|
+
*Abeid Ahmed*
|
732
878
|
|
733
|
-
*
|
879
|
+
* PostgreSQL: support custom enum types
|
734
880
|
|
735
|
-
|
881
|
+
In migrations, use `create_enum` to add a new enum type, and `t.enum` to add a column.
|
736
882
|
|
737
883
|
```ruby
|
738
|
-
|
739
|
-
|
740
|
-
|
884
|
+
def up
|
885
|
+
create_enum :mood, ["happy", "sad"]
|
886
|
+
|
887
|
+
change_table :cats do |t|
|
888
|
+
t.enum :current_mood, enum_type: "mood", default: "happy", null: false
|
889
|
+
end
|
890
|
+
end
|
741
891
|
```
|
742
892
|
|
743
|
-
|
893
|
+
Enums will be presented correctly in `schema.rb`. Note that this is only supported by
|
894
|
+
the PostgreSQL adapter.
|
744
895
|
|
745
|
-
*
|
896
|
+
*Alex Ghiculescu*
|
746
897
|
|
747
|
-
*
|
898
|
+
* Avoid COMMENT statements in PostgreSQL structure dumps
|
748
899
|
|
749
|
-
|
900
|
+
COMMENT statements are now omitted from the output of `db:structure:dump` when using PostgreSQL >= 11.
|
901
|
+
This allows loading the dump without a pgsql superuser account.
|
750
902
|
|
751
|
-
|
903
|
+
Fixes #36816, #43107.
|
752
904
|
|
753
|
-
|
754
|
-
class Article < ApplicationRecord
|
755
|
-
validates_uniqueness_of :title, conditions: ->(article) {
|
756
|
-
published_at = article.published_at
|
757
|
-
where(published_at: published_at.beginning_of_year..published_at.end_of_year)
|
758
|
-
}
|
759
|
-
end
|
760
|
-
```
|
905
|
+
*Janosch Müller*
|
761
906
|
|
762
|
-
|
907
|
+
* Add support for generated columns in PostgreSQL adapter
|
763
908
|
|
764
|
-
|
765
|
-
|
909
|
+
Generated columns are supported since version 12.0 of PostgreSQL. This adds
|
910
|
+
support of those to the PostgreSQL adapter.
|
766
911
|
|
767
912
|
```ruby
|
768
|
-
|
769
|
-
|
913
|
+
create_table :users do |t|
|
914
|
+
t.string :name
|
915
|
+
t.virtual :name_upcased, type: :string, as: 'upper(name)', stored: true
|
916
|
+
end
|
770
917
|
```
|
771
918
|
|
772
|
-
|
919
|
+
*Michał Begejowicz*
|
773
920
|
|
774
|
-
*Eugene Kenny*
|
775
921
|
|
776
|
-
|
777
|
-
`ActiveSupport::Duration` when loading records from database and
|
778
|
-
serialization to ISO 8601 formatted duration string on save.
|
779
|
-
Add support to define a column in migrations and get it in a schema dump.
|
780
|
-
Optional column precision is supported.
|
922
|
+
## Rails 7.0.0.alpha2 (September 15, 2021) ##
|
781
923
|
|
782
|
-
|
924
|
+
* No changes.
|
783
925
|
|
784
|
-
attribute :duration, :interval
|
785
926
|
|
786
|
-
|
927
|
+
## Rails 7.0.0.alpha1 (September 15, 2021) ##
|
787
928
|
|
788
|
-
|
929
|
+
* Remove warning when overwriting existing scopes
|
789
930
|
|
790
|
-
|
931
|
+
Removes the following unnecessary warning message that appeared when overwriting existing scopes
|
791
932
|
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
end
|
933
|
+
```
|
934
|
+
Creating scope :my_scope_name. Overwriting existing method "MyClass.my_scope_name" when overwriting existing scopes
|
935
|
+
```
|
796
936
|
|
797
|
-
|
798
|
-
attribute :duration, :interval
|
799
|
-
end
|
937
|
+
*Weston Ganger*
|
800
938
|
|
801
|
-
|
802
|
-
Event.last.duration # => 2 days
|
803
|
-
Event.last.duration.iso8601 # => "P2D"
|
804
|
-
Event.new(duration: 'P1DT12H3S').duration # => 1 day, 12 hours, and 3 seconds
|
805
|
-
Event.new(duration: '1 day') # Unknown value will be ignored and NULL will be written to database
|
939
|
+
* Use full precision for `updated_at` in `insert_all`/`upsert_all`
|
806
940
|
|
807
|
-
|
941
|
+
`CURRENT_TIMESTAMP` provides differing precision depending on the database,
|
942
|
+
and not all databases support explicitly specifying additional precision.
|
808
943
|
|
809
|
-
|
944
|
+
Instead, we delegate to the new `connection.high_precision_current_timestamp`
|
945
|
+
for the SQL to produce a high precision timestamp on the current database.
|
810
946
|
|
811
|
-
|
812
|
-
class Account < ActiveRecord::Base
|
813
|
-
belongs_to :supplier, dependent: :destroy_async
|
814
|
-
end
|
815
|
-
```
|
947
|
+
Fixes #42992
|
816
948
|
|
817
|
-
|
949
|
+
*Sam Bostock*
|
818
950
|
|
819
|
-
|
951
|
+
* Add ssl support for postgresql database tasks
|
820
952
|
|
821
|
-
|
953
|
+
Add `PGSSLMODE`, `PGSSLCERT`, `PGSSLKEY` and `PGSSLROOTCERT` to pg_env from database config
|
954
|
+
when running postgresql database tasks.
|
822
955
|
|
823
|
-
|
956
|
+
```yaml
|
957
|
+
# config/database.yml
|
824
958
|
|
825
|
-
|
959
|
+
production:
|
960
|
+
sslmode: verify-full
|
961
|
+
sslcert: client.crt
|
962
|
+
sslkey: client.key
|
963
|
+
sslrootcert: ca.crt
|
964
|
+
```
|
826
965
|
|
827
|
-
|
966
|
+
Environment variables
|
828
967
|
|
829
|
-
|
968
|
+
```
|
969
|
+
PGSSLMODE=verify-full
|
970
|
+
PGSSLCERT=client.crt
|
971
|
+
PGSSLKEY=client.key
|
972
|
+
PGSSLROOTCERT=ca.crt
|
973
|
+
```
|
830
974
|
|
831
|
-
|
832
|
-
`ActiveRecord::StatementInvalid` when they encounter a connection error.
|
975
|
+
Fixes #42994
|
833
976
|
|
834
|
-
*
|
977
|
+
*Michael Bayucot*
|
835
978
|
|
836
|
-
*
|
837
|
-
`ActiveRecord::StatementInvalid` when it can't connect to the MySQL server.
|
979
|
+
* Avoid scoping update callbacks in `ActiveRecord::Relation#update!`.
|
838
980
|
|
839
|
-
|
981
|
+
Making it consistent with how scoping is applied only to the query in `ActiveRecord::Relation#update`
|
982
|
+
and not also to the callbacks from the update itself.
|
840
983
|
|
841
|
-
*
|
984
|
+
*Dylan Thacker-Smith*
|
842
985
|
|
843
|
-
|
986
|
+
* Fix 2 cases that inferred polymorphic class from the association's `foreign_type`
|
987
|
+
using `String#constantize` instead of the model's `polymorphic_class_for`.
|
844
988
|
|
845
|
-
|
989
|
+
When updating a polymorphic association, the old `foreign_type` was not inferred correctly when:
|
990
|
+
1. `touch`ing the previously associated record
|
991
|
+
2. updating the previously associated record's `counter_cache`
|
846
992
|
|
847
|
-
|
993
|
+
*Jimmy Bourassa*
|
848
994
|
|
849
|
-
|
995
|
+
* Add config option for ignoring tables when dumping the schema cache.
|
996
|
+
|
997
|
+
Applications can now be configured to ignore certain tables when dumping the schema cache.
|
850
998
|
|
851
|
-
|
999
|
+
The configuration option can table an array of tables:
|
852
1000
|
|
853
1001
|
```ruby
|
854
|
-
|
855
|
-
|
856
|
-
has_many :children, class_name: "Comment", foreign_key: :parent_id
|
857
|
-
end
|
1002
|
+
config.active_record.schema_cache_ignored_tables = ["ignored_table", "another_ignored_table"]
|
1003
|
+
```
|
858
1004
|
|
859
|
-
|
860
|
-
|
1005
|
+
Or a regex:
|
1006
|
+
|
1007
|
+
```ruby
|
1008
|
+
config.active_record.schema_cache_ignored_tables = [/^_/]
|
861
1009
|
```
|
862
1010
|
|
863
|
-
*
|
1011
|
+
*Eileen M. Uchitelle*
|
864
1012
|
|
865
|
-
*
|
1013
|
+
* Make schema cache methods return consistent results.
|
866
1014
|
|
867
|
-
|
868
|
-
|
1015
|
+
Previously the schema cache methods `primary_keys`, `columns`, `columns_hash`, and `indexes`
|
1016
|
+
would behave differently than one another when a table didn't exist and differently across
|
1017
|
+
database adapters. This change unifies the behavior so each method behaves the same regardless
|
1018
|
+
of adapter.
|
869
1019
|
|
870
|
-
|
1020
|
+
The behavior now is:
|
871
1021
|
|
872
|
-
|
1022
|
+
`columns`: (unchanged) raises a db error if the table does not exist.
|
1023
|
+
`columns_hash`: (unchanged) raises a db error if the table does not exist.
|
1024
|
+
`primary_keys`: (unchanged) returns `nil` if the table does not exist.
|
1025
|
+
`indexes`: (changed for mysql2) returns `[]` if the table does not exist.
|
873
1026
|
|
874
|
-
*
|
875
|
-
`rails db:schema:{load, dump}` tasks to work with either `:ruby` or `:sql` format,
|
876
|
-
depending on `config.active_record.schema_format` configuration value.
|
1027
|
+
*Eileen M. Uchitelle*
|
877
1028
|
|
878
|
-
|
1029
|
+
* Reestablish connection to previous database after after running `db:schema:load:name`
|
879
1030
|
|
880
|
-
|
1031
|
+
After running `db:schema:load:name` the previous connection is restored.
|
881
1032
|
|
882
|
-
|
883
|
-
post = Post.select("UPPER(title) AS title").first
|
884
|
-
post.title # => "WELCOME TO THE WEBLOG"
|
885
|
-
post.body # => ActiveModel::MissingAttributeError
|
1033
|
+
*Jacopo Beschi*
|
886
1034
|
|
887
|
-
|
888
|
-
post = Post.select("UPPER(title) AS title").eager_load(:comments).first
|
889
|
-
post.title # => "Welcome to the weblog"
|
890
|
-
post.body # => "Such a lovely day"
|
1035
|
+
* Add database config option `database_tasks`
|
891
1036
|
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
post.body # => ActiveModel::MissingAttributeError
|
896
|
-
```
|
1037
|
+
If you would like to connect to an external database without any database
|
1038
|
+
management tasks such as schema management, migrations, seeds, etc. you can set
|
1039
|
+
the per database config option `database_tasks: false`
|
897
1040
|
|
898
|
-
|
1041
|
+
```yaml
|
1042
|
+
# config/database.yml
|
899
1043
|
|
900
|
-
|
1044
|
+
production:
|
1045
|
+
primary:
|
1046
|
+
database: my_database
|
1047
|
+
adapter: mysql2
|
1048
|
+
animals:
|
1049
|
+
database: my_animals_database
|
1050
|
+
adapter: mysql2
|
1051
|
+
database_tasks: false
|
1052
|
+
```
|
901
1053
|
|
902
|
-
|
903
|
-
class Post < ActiveRecord::Base
|
904
|
-
attribute :written_at, default: -> { Time.now.utc }
|
905
|
-
end
|
1054
|
+
*Weston Ganger*
|
906
1055
|
|
907
|
-
|
908
|
-
Post.type_for_attribute(:written_at) # => #<Type::Value ... precision: nil, ...>
|
1056
|
+
* Fix `ActiveRecord::InternalMetadata` to not be broken by `config.active_record.record_timestamps = false`
|
909
1057
|
|
910
|
-
|
911
|
-
|
912
|
-
```
|
1058
|
+
Since the model always create the timestamp columns, it has to set them, otherwise it breaks
|
1059
|
+
various DB management tasks.
|
913
1060
|
|
914
|
-
|
1061
|
+
Fixes #42983
|
1062
|
+
|
1063
|
+
* Add `ActiveRecord::QueryLogs`.
|
915
1064
|
|
916
|
-
|
1065
|
+
Configurable tags can be automatically added to all SQL queries generated by Active Record.
|
917
1066
|
|
918
1067
|
```ruby
|
919
|
-
|
920
|
-
|
1068
|
+
# config/application.rb
|
1069
|
+
module MyApp
|
1070
|
+
class Application < Rails::Application
|
1071
|
+
config.active_record.query_log_tags_enabled = true
|
1072
|
+
end
|
921
1073
|
end
|
922
|
-
|
923
|
-
Book.new.status # => "published"
|
924
1074
|
```
|
925
1075
|
|
926
|
-
|
1076
|
+
By default the application, controller and action details are added to the query tags:
|
927
1077
|
|
928
|
-
|
1078
|
+
```ruby
|
1079
|
+
class BooksController < ApplicationController
|
1080
|
+
def index
|
1081
|
+
@books = Book.all
|
1082
|
+
end
|
1083
|
+
end
|
1084
|
+
```
|
929
1085
|
|
930
|
-
|
1086
|
+
```ruby
|
1087
|
+
GET /books
|
1088
|
+
# SELECT * FROM books /*application:MyApp;controller:books;action:index*/
|
1089
|
+
```
|
931
1090
|
|
932
|
-
|
933
|
-
allows you to specify that all string columns should be frozen unless
|
934
|
-
otherwise specified. This will reduce memory pressure for applications which
|
935
|
-
do not generally mutate string properties of Active Record objects.
|
1091
|
+
Custom tags containing static values and Procs can be defined in the application configuration:
|
936
1092
|
|
937
|
-
|
1093
|
+
```ruby
|
1094
|
+
config.active_record.query_log_tags = [
|
1095
|
+
:application,
|
1096
|
+
:controller,
|
1097
|
+
:action,
|
1098
|
+
{
|
1099
|
+
custom_static: "foo",
|
1100
|
+
custom_dynamic: -> { Time.now }
|
1101
|
+
}
|
1102
|
+
]
|
1103
|
+
```
|
938
1104
|
|
939
|
-
*
|
1105
|
+
*Keeran Raj Hawoldar*, *Eileen M. Uchitelle*, *Kasper Timm Hansen*
|
940
1106
|
|
941
|
-
|
1107
|
+
* Added support for multiple databases to `rails db:setup` and `rails db:reset`.
|
942
1108
|
|
943
|
-
*
|
1109
|
+
*Ryan Hall*
|
944
1110
|
|
945
|
-
|
946
|
-
david_and_mary = Author.where(id: [david, mary])
|
947
|
-
mary_and_bob = Author.where(id: [mary, bob])
|
1111
|
+
* Add `ActiveRecord::Relation#structurally_compatible?`.
|
948
1112
|
|
949
|
-
|
1113
|
+
Adds a query method by which a user can tell if the relation that they're
|
1114
|
+
about to use for `#or` or `#and` is structurally compatible with the
|
1115
|
+
receiver.
|
950
1116
|
|
951
|
-
|
952
|
-
david_and_mary.or(mary_and_bob) # => [david, mary, bob]
|
953
|
-
```
|
1117
|
+
*Kevin Newton*
|
954
1118
|
|
955
|
-
|
1119
|
+
* Add `ActiveRecord::QueryMethods#in_order_of`.
|
956
1120
|
|
957
|
-
|
958
|
-
|
959
|
-
|
1121
|
+
This allows you to specify an explicit order that you'd like records
|
1122
|
+
returned in based on a SQL expression. By default, this will be accomplished
|
1123
|
+
using a case statement, as in:
|
960
1124
|
|
961
1125
|
```ruby
|
962
|
-
|
963
|
-
|
1126
|
+
Post.in_order_of(:id, [3, 5, 1])
|
1127
|
+
```
|
964
1128
|
|
965
|
-
|
966
|
-
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
|
1129
|
+
will generate the SQL:
|
967
1130
|
|
968
|
-
|
969
|
-
|
1131
|
+
```sql
|
1132
|
+
SELECT "posts".* FROM "posts" ORDER BY CASE "posts"."id" WHEN 3 THEN 1 WHEN 5 THEN 2 WHEN 1 THEN 3 ELSE 4 END ASC
|
1133
|
+
```
|
970
1134
|
|
971
|
-
|
972
|
-
|
973
|
-
|
1135
|
+
However, because this functionality is built into MySQL in the form of the
|
1136
|
+
`FIELD` function, that connection adapter will generate the following SQL
|
1137
|
+
instead:
|
1138
|
+
|
1139
|
+
```sql
|
1140
|
+
SELECT "posts".* FROM "posts" ORDER BY FIELD("posts"."id", 1, 5, 3) DESC
|
974
1141
|
```
|
975
1142
|
|
976
|
-
*
|
1143
|
+
*Kevin Newton*
|
977
1144
|
|
978
|
-
*
|
1145
|
+
* Fix `eager_loading?` when ordering with `Symbol`.
|
979
1146
|
|
980
|
-
|
1147
|
+
`eager_loading?` is triggered correctly when using `order` with symbols.
|
981
1148
|
|
982
|
-
|
1149
|
+
```ruby
|
1150
|
+
scope = Post.includes(:comments).order(:"comments.label")
|
1151
|
+
=> true
|
1152
|
+
```
|
983
1153
|
|
984
|
-
|
985
|
-
`ActiveRecord::Persistence.upsert_all` was used with the name of an expression index, an error
|
986
|
-
was raised. Adding a guard around the formatting behavior for the `:unique_by` corrects this.
|
1154
|
+
*Jacopo Beschi*
|
987
1155
|
|
988
|
-
|
1156
|
+
* Two change tracking methods are added for `belongs_to` associations.
|
989
1157
|
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
t.index "lower(name)", unique: true
|
994
|
-
end
|
1158
|
+
The `association_changed?` method (assuming an association named `:association`) returns true
|
1159
|
+
if a different associated object has been assigned and the foreign key will be updated in the
|
1160
|
+
next save.
|
995
1161
|
|
996
|
-
|
997
|
-
|
1162
|
+
The `association_previously_changed?` method returns true if the previous save updated the
|
1163
|
+
association to reference a different associated object.
|
998
1164
|
|
999
|
-
|
1165
|
+
*George Claghorn*
|
1000
1166
|
|
1001
|
-
|
1167
|
+
* Add option to disable schema dump per-database.
|
1002
1168
|
|
1003
|
-
|
1169
|
+
Dumping the schema is on by default for all databases in an application. To turn it off for a
|
1170
|
+
specific database, use the `schema_dump` option:
|
1004
1171
|
|
1005
|
-
|
1172
|
+
```yaml
|
1173
|
+
# config/database.yml
|
1006
1174
|
|
1007
|
-
|
1008
|
-
|
1009
|
-
remove_check_constraint :products, name: "price_check"
|
1175
|
+
production:
|
1176
|
+
schema_dump: false
|
1010
1177
|
```
|
1011
1178
|
|
1012
|
-
*
|
1179
|
+
*Luis Vasconcellos*, *Eileen M. Uchitelle*
|
1013
1180
|
|
1014
|
-
*
|
1015
|
-
to enable/disable strict_loading mode by default for a model. The configuration's value is
|
1016
|
-
inheritable by subclasses, but they can override that value and it will not impact parent class.
|
1181
|
+
* Fix `eager_loading?` when ordering with `Hash` syntax.
|
1017
1182
|
|
1018
|
-
|
1183
|
+
`eager_loading?` is triggered correctly when using `order` with hash syntax
|
1184
|
+
on an outer table.
|
1019
1185
|
|
1020
1186
|
```ruby
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
has_many :projects
|
1025
|
-
end
|
1026
|
-
|
1027
|
-
dev = Developer.first
|
1028
|
-
dev.projects.first
|
1029
|
-
# => ActiveRecord::StrictLoadingViolationError Exception: Developer is marked as strict_loading and Project cannot be lazily loaded.
|
1187
|
+
Post.includes(:comments).order({ "comments.label": :ASC }).eager_loading?
|
1188
|
+
# => true
|
1030
1189
|
```
|
1031
1190
|
|
1032
|
-
*
|
1191
|
+
*Jacopo Beschi*
|
1033
1192
|
|
1034
|
-
*
|
1193
|
+
* Move the forcing of clear text encoding to the `ActiveRecord::Encryption::Encryptor`.
|
1035
1194
|
|
1036
|
-
|
1195
|
+
Fixes #42699.
|
1037
1196
|
|
1038
|
-
*
|
1197
|
+
*J Smith*
|
1039
1198
|
|
1040
|
-
|
1041
|
-
|
1042
|
-
```ruby
|
1043
|
-
create_table "accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
|
1044
|
-
end
|
1045
|
-
```
|
1199
|
+
* `partial_inserts` is now disabled by default in new apps.
|
1046
1200
|
|
1047
|
-
|
1201
|
+
This will be the default for new apps in Rails 7. To opt in:
|
1048
1202
|
|
1049
1203
|
```ruby
|
1050
|
-
|
1051
|
-
end
|
1204
|
+
config.active_record.partial_inserts = true
|
1052
1205
|
```
|
1053
1206
|
|
1054
|
-
|
1207
|
+
If a migration removes the default value of a column, this option
|
1208
|
+
would cause old processes to no longer be able to create new records.
|
1055
1209
|
|
1056
|
-
|
1057
|
-
|
1210
|
+
If you need to remove a column, you should first use `ignored_columns`
|
1211
|
+
to stop using it.
|
1058
1212
|
|
1059
|
-
*
|
1213
|
+
*Jean Boussier*
|
1060
1214
|
|
1061
|
-
*
|
1215
|
+
* Rails can now verify foreign keys after loading fixtures in tests.
|
1062
1216
|
|
1063
|
-
|
1217
|
+
This will be the default for new apps in Rails 7. To opt in:
|
1064
1218
|
|
1065
1219
|
```ruby
|
1066
|
-
|
1067
|
-
|
1068
|
-
# duplicated group fields, deprecated.
|
1069
|
-
accounts.merge(accounts.where.not(credit_limit: nil)).sum(:credit_limit)
|
1070
|
-
# => {
|
1071
|
-
# [1, 1] => 50,
|
1072
|
-
# [2, 2] => 60
|
1073
|
-
# }
|
1074
|
-
|
1075
|
-
# use `uniq!(:group)` to deduplicate group fields.
|
1076
|
-
accounts.merge(accounts.where.not(credit_limit: nil)).uniq!(:group).sum(:credit_limit)
|
1077
|
-
# => {
|
1078
|
-
# 1 => 50,
|
1079
|
-
# 2 => 60
|
1080
|
-
# }
|
1220
|
+
config.active_record.verify_foreign_keys_for_fixtures = true
|
1081
1221
|
```
|
1082
1222
|
|
1083
|
-
|
1223
|
+
Tests will not run if there is a foreign key constraint violation in your fixture data.
|
1084
1224
|
|
1085
|
-
|
1225
|
+
The feature is supported by SQLite and PostgreSQL, other adapters can also add support for it.
|
1086
1226
|
|
1087
|
-
|
1227
|
+
*Alex Ghiculescu*
|
1088
1228
|
|
1089
|
-
|
1090
|
-
accounts = Account.where(id: [1, 2]).annotate("david and mary")
|
1229
|
+
* Clear cached `has_one` association after setting `belongs_to` association to `nil`.
|
1091
1230
|
|
1092
|
-
|
1093
|
-
|
1094
|
-
# SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */ /* david and mary */
|
1231
|
+
After setting a `belongs_to` relation to `nil` and updating an unrelated attribute on the owner,
|
1232
|
+
the owner should still return `nil` on the `has_one` relation.
|
1095
1233
|
|
1096
|
-
#
|
1097
|
-
accounts.merge(accounts.rewhere(id: 3)).uniq!(:annotate)
|
1098
|
-
# SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */
|
1099
|
-
```
|
1234
|
+
Fixes #42597.
|
1100
1235
|
|
1101
|
-
*
|
1236
|
+
*Michiel de Mare*
|
1102
1237
|
|
1103
|
-
*
|
1238
|
+
* OpenSSL constants are now used for Digest computations.
|
1104
1239
|
|
1105
|
-
|
1106
|
-
cache. This avoids raising an unnecessary `ActiveRecord::StaleObjectError`
|
1107
|
-
upon subsequent transactions by maintaining parity with the corresponding
|
1108
|
-
database record's `lock_version` column.
|
1240
|
+
*Dirkjan Bussink*
|
1109
1241
|
|
1110
|
-
|
1242
|
+
* Adds support for `if_not_exists` to `add_foreign_key` and `if_exists` to `remove_foreign_key`.
|
1111
1243
|
|
1112
|
-
|
1244
|
+
Applications can set their migrations to ignore exceptions raised when adding a foreign key
|
1245
|
+
that already exists or when removing a foreign key that does not exist.
|
1246
|
+
|
1247
|
+
Example Usage:
|
1113
1248
|
|
1114
|
-
|
1249
|
+
```ruby
|
1250
|
+
class AddAuthorsForeignKeyToArticles < ActiveRecord::Migration[7.0]
|
1251
|
+
def change
|
1252
|
+
add_foreign_key :articles, :authors, if_not_exists: true
|
1253
|
+
end
|
1254
|
+
end
|
1255
|
+
```
|
1115
1256
|
|
1116
1257
|
```ruby
|
1117
|
-
|
1258
|
+
class RemoveAuthorsForeignKeyFromArticles < ActiveRecord::Migration[7.0]
|
1259
|
+
def change
|
1260
|
+
remove_foreign_key :articles, :authors, if_exists: true
|
1261
|
+
end
|
1262
|
+
end
|
1263
|
+
```
|
1118
1264
|
|
1119
|
-
|
1120
|
-
david_and_mary.merge(Author.where(id: bob)) # => []
|
1265
|
+
*Roberto Miranda*
|
1121
1266
|
|
1122
|
-
|
1123
|
-
david_and_mary.merge(Author.rewhere(id: bob)) # => [bob]
|
1267
|
+
* Prevent polluting ENV during postgresql structure dump/load.
|
1124
1268
|
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1269
|
+
Some configuration parameters were provided to pg_dump / psql via
|
1270
|
+
environment variables which persisted beyond the command being run, and may
|
1271
|
+
have caused subsequent commands and connections to fail. Tasks running
|
1272
|
+
across multiple postgresql databases like `rails db:test:prepare` may have
|
1273
|
+
been affected.
|
1128
1274
|
|
1129
|
-
*
|
1275
|
+
*Samuel Cochran*
|
1130
1276
|
|
1131
|
-
*
|
1132
|
-
set to expire and scoped with a purpose. This is particularly useful for things like password reset
|
1133
|
-
or email verification, where you want the bearer of the signed id to be able to interact with the
|
1134
|
-
underlying record, but usually only within a certain time period.
|
1277
|
+
* Set precision 6 by default for `datetime` columns.
|
1135
1278
|
|
1136
|
-
|
1137
|
-
signed_id = User.first.signed_id expires_in: 15.minutes, purpose: :password_reset
|
1279
|
+
By default, datetime columns will have microseconds precision instead of seconds precision.
|
1138
1280
|
|
1139
|
-
|
1281
|
+
*Roberto Miranda*
|
1140
1282
|
|
1141
|
-
|
1142
|
-
User.find_signed signed_id, purpose: :password_reset # => nil, since the signed id has expired
|
1283
|
+
* Allow preloading of associations with instance dependent scopes.
|
1143
1284
|
|
1144
|
-
|
1145
|
-
User.find_signed signed_id, purpose: :password_reset # => User.first
|
1285
|
+
*John Hawthorn*, *John Crepezzi*, *Adam Hess*, *Eileen M. Uchitelle*, *Dinah Shi*
|
1146
1286
|
|
1147
|
-
|
1148
|
-
```
|
1287
|
+
* Do not try to rollback transactions that failed due to a `ActiveRecord::TransactionRollbackError`.
|
1149
1288
|
|
1150
|
-
*
|
1289
|
+
*Jamie McCarthy*
|
1151
1290
|
|
1152
|
-
*
|
1291
|
+
* Active Record Encryption will now encode values as UTF-8 when using deterministic
|
1292
|
+
encryption. The encoding is part of the encrypted payload, so different encodings for
|
1293
|
+
different values result in different ciphertexts. This can break unique constraints and
|
1294
|
+
queries.
|
1153
1295
|
|
1154
|
-
|
1296
|
+
The new behavior is configurable via `active_record.encryption.forced_encoding_for_deterministic_encryption`
|
1297
|
+
that is `Encoding::UTF_8` by default. It can be disabled by setting it to `nil`.
|
1155
1298
|
|
1156
|
-
*
|
1299
|
+
*Jorge Manrubia*
|
1157
1300
|
|
1158
|
-
|
1301
|
+
* The MySQL adapter now cast numbers and booleans bind parameters to string for safety reasons.
|
1159
1302
|
|
1160
|
-
|
1303
|
+
When comparing a string and a number in a query, MySQL converts the string to a number. So for
|
1304
|
+
instance `"foo" = 0`, will implicitly cast `"foo"` to `0` and will evaluate to `TRUE` which can
|
1305
|
+
lead to security vulnerabilities.
|
1161
1306
|
|
1162
|
-
|
1307
|
+
Active Record already protect against that vulnerability when it knows the type of the column
|
1308
|
+
being compared, however until now it was still vulnerable when using bind parameters:
|
1163
1309
|
|
1164
1310
|
```ruby
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
posts.count
|
1169
|
-
# => { false => 10 }
|
1311
|
+
User.where("login_token = ?", 0).first
|
1312
|
+
```
|
1170
1313
|
|
1171
|
-
|
1172
|
-
posts.unscope(where: :hidden).count
|
1173
|
-
# => { false => 11, true => 1 }
|
1314
|
+
Would perform:
|
1174
1315
|
|
1175
|
-
|
1176
|
-
|
1177
|
-
# => { false => 11 }
|
1316
|
+
```sql
|
1317
|
+
SELECT * FROM `users` WHERE `login_token` = 0 LIMIT 1;
|
1178
1318
|
```
|
1179
1319
|
|
1180
|
-
|
1320
|
+
Now it will perform:
|
1181
1321
|
|
1182
|
-
|
1322
|
+
```sql
|
1323
|
+
SELECT * FROM `users` WHERE `login_token` = '0' LIMIT 1;
|
1324
|
+
```
|
1183
1325
|
|
1184
|
-
|
1185
|
-
steve = Person.find_by(name: "Steve")
|
1186
|
-
david = Author.find_by(name: "David")
|
1326
|
+
*Jean Boussier*
|
1187
1327
|
|
1188
|
-
|
1328
|
+
* Fixture configurations (`_fixture`) are now strictly validated.
|
1189
1329
|
|
1190
|
-
|
1191
|
-
|
1330
|
+
If an error will be raised if that entry contains unknown keys while previously it
|
1331
|
+
would silently have no effects.
|
1192
1332
|
|
1193
|
-
|
1194
|
-
relation.rewhere(writer: david).to_a # => [david]
|
1195
|
-
```
|
1333
|
+
*Jean Boussier*
|
1196
1334
|
|
1197
|
-
|
1335
|
+
* Add `ActiveRecord::Base.update!` that works like `ActiveRecord::Base.update` but raises exceptions.
|
1198
1336
|
|
1199
|
-
|
1337
|
+
This allows for the same behavior as the instance method `#update!` at a class level.
|
1200
1338
|
|
1201
1339
|
```ruby
|
1202
|
-
|
1203
|
-
=> #<Knot id: 1, created_at: "2016-05-05 01:29:47.116928000 +0000">
|
1340
|
+
Person.update!(:all, state: "confirmed")
|
1204
1341
|
```
|
1205
1342
|
|
1206
|
-
*
|
1343
|
+
*Dorian Marié*
|
1207
1344
|
|
1208
|
-
*
|
1345
|
+
* Add `ActiveRecord::Base#attributes_for_database`.
|
1209
1346
|
|
1210
|
-
|
1347
|
+
Returns attributes with values for assignment to the database.
|
1211
1348
|
|
1212
|
-
*
|
1349
|
+
*Chris Salzberg*
|
1213
1350
|
|
1214
|
-
|
1351
|
+
* Use an empty query to check if the PostgreSQL connection is still active.
|
1215
1352
|
|
1216
|
-
|
1353
|
+
An empty query is faster than `SELECT 1`.
|
1217
1354
|
|
1218
|
-
*
|
1355
|
+
*Heinrich Lee Yu*
|
1219
1356
|
|
1220
|
-
*
|
1357
|
+
* Add `ActiveRecord::Base#previously_persisted?`.
|
1221
1358
|
|
1222
|
-
|
1359
|
+
Returns `true` if the object has been previously persisted but now it has been deleted.
|
1223
1360
|
|
1224
|
-
*
|
1361
|
+
* Deprecate `partial_writes` in favor of `partial_inserts` and `partial_updates`.
|
1225
1362
|
|
1226
|
-
|
1363
|
+
This allows to have a different behavior on update and create.
|
1227
1364
|
|
1228
|
-
*
|
1365
|
+
*Jean Boussier*
|
1229
1366
|
|
1230
|
-
*
|
1367
|
+
* Fix compatibility with `psych >= 4`.
|
1231
1368
|
|
1232
|
-
|
1369
|
+
Starting in Psych 4.0.0 `YAML.load` behaves like `YAML.safe_load`. To preserve compatibility,
|
1370
|
+
Active Record's schema cache loader and `YAMLColumn` now uses `YAML.unsafe_load` if available.
|
1233
1371
|
|
1234
|
-
*
|
1372
|
+
*Jean Boussier*
|
1235
1373
|
|
1236
|
-
|
1374
|
+
* `ActiveRecord::Base.logger` is now a `class_attribute`.
|
1237
1375
|
|
1238
|
-
|
1376
|
+
This means it can no longer be accessed directly through `@@logger`, and that setting `logger =`
|
1377
|
+
on a subclass won't change the parent's logger.
|
1239
1378
|
|
1240
|
-
*
|
1379
|
+
*Jean Boussier*
|
1241
1380
|
|
1242
|
-
|
1243
|
-
index won't be added.
|
1381
|
+
* Add `.asc.nulls_first` for all databases. Unfortunately MySQL still doesn't like `nulls_last`.
|
1244
1382
|
|
1245
|
-
|
1383
|
+
*Keenan Brock*
|
1246
1384
|
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1385
|
+
* Improve performance of `one?` and `many?` by limiting the generated count query to 2 results.
|
1386
|
+
|
1387
|
+
*Gonzalo Riestra*
|
1388
|
+
|
1389
|
+
* Don't check type when using `if_not_exists` on `add_column`.
|
1390
|
+
|
1391
|
+
Previously, if a migration called `add_column` with the `if_not_exists` option set to true
|
1392
|
+
the `column_exists?` check would look for a column with the same name and type as the migration.
|
1250
1393
|
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1394
|
+
Recently it was discovered that the type passed to the migration is not always the same type
|
1395
|
+
as the column after migration. For example a column set to `:mediumblob` in the migration will
|
1396
|
+
be casted to `binary` when calling `column.type`. Since there is no straightforward way to cast
|
1397
|
+
the type to the database type without running the migration, we opted to drop the type check from
|
1398
|
+
`add_column`. This means that migrations adding a duplicate column with a different type will no
|
1399
|
+
longer raise an error.
|
1254
1400
|
|
1255
|
-
*
|
1401
|
+
*Eileen M. Uchitelle*
|
1402
|
+
|
1403
|
+
* Log a warning message when running SQLite in production.
|
1256
1404
|
|
1257
|
-
|
1405
|
+
Using SQLite in production ENV is generally discouraged. SQLite is also the default adapter
|
1406
|
+
in a new Rails application.
|
1407
|
+
For the above reasons log a warning message when running SQLite in production.
|
1258
1408
|
|
1259
|
-
|
1409
|
+
The warning can be disabled by setting `config.active_record.sqlite3_production_warning=false`.
|
1260
1410
|
|
1261
|
-
*
|
1411
|
+
*Jacopo Beschi*
|
1262
1412
|
|
1263
|
-
|
1413
|
+
* Add option to disable joins for `has_one` associations.
|
1264
1414
|
|
1265
|
-
|
1415
|
+
In a multiple database application, associations can't join across
|
1416
|
+
databases. When set, this option instructs Rails to generate 2 or
|
1417
|
+
more queries rather than generating joins for `has_one` associations.
|
1266
1418
|
|
1267
|
-
|
1419
|
+
Set the option on a has one through association:
|
1268
1420
|
|
1269
1421
|
```ruby
|
1270
|
-
Person
|
1271
|
-
|
1422
|
+
class Person
|
1423
|
+
has_one :dog
|
1424
|
+
has_one :veterinarian, through: :dog, disable_joins: true
|
1272
1425
|
end
|
1273
1426
|
```
|
1274
1427
|
|
1275
|
-
|
1428
|
+
Then instead of generating join SQL, two queries are used for `@person.veterinarian`:
|
1429
|
+
|
1430
|
+
```
|
1431
|
+
SELECT "dogs"."id" FROM "dogs" WHERE "dogs"."person_id" = ? [["person_id", 1]]
|
1432
|
+
SELECT "veterinarians".* FROM "veterinarians" WHERE "veterinarians"."dog_id" = ? [["dog_id", 1]]
|
1433
|
+
```
|
1276
1434
|
|
1277
|
-
*
|
1435
|
+
*Sarah Vessels*, *Eileen M. Uchitelle*
|
1278
1436
|
|
1279
|
-
|
1437
|
+
* `Arel::Visitors::Dot` now renders a complete set of properties when visiting
|
1438
|
+
`Arel::Nodes::SelectCore`, `SelectStatement`, `InsertStatement`, `UpdateStatement`, and
|
1439
|
+
`DeleteStatement`, which fixes #42026. Previously, some properties were omitted.
|
1280
1440
|
|
1281
|
-
*
|
1441
|
+
*Mike Dalessio*
|
1282
1442
|
|
1283
|
-
*
|
1443
|
+
* `Arel::Visitors::Dot` now supports `Arel::Nodes::Bin`, `Case`, `CurrentRow`, `Distinct`,
|
1444
|
+
`DistinctOn`, `Else`, `Except`, `InfixOperation`, `Intersect`, `Lock`, `NotRegexp`, `Quoted`,
|
1445
|
+
`Regexp`, `UnaryOperation`, `Union`, `UnionAll`, `When`, and `With`. Previously, these node
|
1446
|
+
types caused an exception to be raised by `Arel::Visitors::Dot#accept`.
|
1284
1447
|
|
1285
|
-
|
1448
|
+
*Mike Dalessio*
|
1286
1449
|
|
1287
|
-
|
1450
|
+
* Optimize `remove_columns` to use a single SQL statement.
|
1288
1451
|
|
1289
|
-
|
1452
|
+
```ruby
|
1453
|
+
remove_columns :my_table, :col_one, :col_two
|
1454
|
+
```
|
1290
1455
|
|
1291
|
-
|
1456
|
+
Now results in the following SQL:
|
1292
1457
|
|
1293
|
-
|
1458
|
+
```sql
|
1459
|
+
ALTER TABLE "my_table" DROP COLUMN "col_one", DROP COLUMN "col_two"
|
1460
|
+
```
|
1294
1461
|
|
1295
|
-
*
|
1462
|
+
*Jon Dufresne*
|
1296
1463
|
|
1297
|
-
*
|
1464
|
+
* Ensure `has_one` autosave association callbacks get called once.
|
1298
1465
|
|
1299
|
-
|
1466
|
+
Change the `has_one` autosave callback to be non cyclic as well.
|
1467
|
+
By doing this the autosave callback are made more consistent for
|
1468
|
+
all 3 cases: `has_many`, `has_one`, and `belongs_to`.
|
1300
1469
|
|
1301
|
-
|
1470
|
+
*Petrik de Heus*
|
1302
1471
|
|
1303
|
-
|
1472
|
+
* Add option to disable joins for associations.
|
1304
1473
|
|
1305
|
-
|
1474
|
+
In a multiple database application, associations can't join across
|
1475
|
+
databases. When set, this option instructs Rails to generate 2 or
|
1476
|
+
more queries rather than generating joins for associations.
|
1306
1477
|
|
1307
|
-
|
1478
|
+
Set the option on a has many through association:
|
1308
1479
|
|
1309
|
-
|
1480
|
+
```ruby
|
1481
|
+
class Dog
|
1482
|
+
has_many :treats, through: :humans, disable_joins: true
|
1483
|
+
has_many :humans
|
1484
|
+
end
|
1485
|
+
```
|
1310
1486
|
|
1311
|
-
|
1487
|
+
Then instead of generating join SQL, two queries are used for `@dog.treats`:
|
1312
1488
|
|
1313
|
-
|
1489
|
+
```
|
1490
|
+
SELECT "humans"."id" FROM "humans" WHERE "humans"."dog_id" = ? [["dog_id", 1]]
|
1491
|
+
SELECT "treats".* FROM "treats" WHERE "treats"."human_id" IN (?, ?, ?) [["human_id", 1], ["human_id", 2], ["human_id", 3]]
|
1492
|
+
```
|
1314
1493
|
|
1315
|
-
*Eileen M. Uchitelle*, *
|
1494
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*, *Lee Quarella*
|
1316
1495
|
|
1317
|
-
* Add
|
1496
|
+
* Add setting for enumerating column names in SELECT statements.
|
1318
1497
|
|
1319
|
-
|
1498
|
+
Adding a column to a PostgreSQL database, for example, while the application is running can
|
1499
|
+
change the result of wildcard `SELECT *` queries, which invalidates the result
|
1500
|
+
of cached prepared statements and raises a `PreparedStatementCacheExpired` error.
|
1320
1501
|
|
1321
|
-
|
1502
|
+
When enabled, Active Record will avoid wildcards and always include column names
|
1503
|
+
in `SELECT` queries, which will return consistent results and avoid prepared
|
1504
|
+
statement errors.
|
1322
1505
|
|
1323
|
-
|
1506
|
+
Before:
|
1324
1507
|
|
1325
|
-
```
|
1326
|
-
|
1327
|
-
|
1328
|
-
primary:
|
1329
|
-
database: my_database
|
1330
|
-
primary_shard_one:
|
1331
|
-
database: my_database_shard_one
|
1508
|
+
```ruby
|
1509
|
+
Book.limit(5)
|
1510
|
+
# SELECT * FROM books LIMIT 5
|
1332
1511
|
```
|
1333
1512
|
|
1334
|
-
|
1513
|
+
After:
|
1335
1514
|
|
1336
1515
|
```ruby
|
1337
|
-
|
1338
|
-
|
1516
|
+
# config/application.rb
|
1517
|
+
module MyApp
|
1518
|
+
class Application < Rails::Application
|
1519
|
+
config.active_record.enumerate_columns_in_select_statements = true
|
1520
|
+
end
|
1521
|
+
end
|
1339
1522
|
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1523
|
+
# or, configure per-model
|
1524
|
+
class Book < ApplicationRecord
|
1525
|
+
self.enumerate_columns_in_select_statements = true
|
1526
|
+
end
|
1344
1527
|
```
|
1345
1528
|
|
1346
|
-
Swap between shards in your controller / model code:
|
1347
|
-
|
1348
1529
|
```ruby
|
1349
|
-
|
1350
|
-
|
1351
|
-
end
|
1530
|
+
Book.limit(5)
|
1531
|
+
# SELECT id, author_id, name, format, status, language, etc FROM books LIMIT 5
|
1352
1532
|
```
|
1353
1533
|
|
1354
|
-
|
1534
|
+
*Matt Duszynski*
|
1355
1535
|
|
1356
|
-
|
1536
|
+
* Allow passing SQL as `on_duplicate` value to `#upsert_all` to make it possible to use raw SQL to update columns on conflict:
|
1357
1537
|
|
1358
|
-
|
1538
|
+
```ruby
|
1539
|
+
Book.upsert_all(
|
1540
|
+
[{ id: 1, status: 1 }, { id: 2, status: 1 }],
|
1541
|
+
on_duplicate: Arel.sql("status = GREATEST(books.status, EXCLUDED.status)")
|
1542
|
+
)
|
1543
|
+
```
|
1359
1544
|
|
1360
|
-
|
1545
|
+
*Vladimir Dementyev*
|
1361
1546
|
|
1362
|
-
|
1547
|
+
* Allow passing SQL as `returning` statement to `#upsert_all`:
|
1363
1548
|
|
1364
1549
|
```ruby
|
1365
|
-
|
1366
|
-
|
1550
|
+
Article.insert_all(
|
1551
|
+
[
|
1552
|
+
{ title: "Article 1", slug: "article-1", published: false },
|
1553
|
+
{ title: "Article 2", slug: "article-2", published: false }
|
1554
|
+
],
|
1555
|
+
returning: Arel.sql("id, (xmax = '0') as inserted, name as new_name")
|
1556
|
+
)
|
1367
1557
|
```
|
1368
1558
|
|
1369
|
-
|
1559
|
+
*Vladimir Dementyev*
|
1370
1560
|
|
1371
|
-
|
1372
|
-
db_config = ActiveRecord::Base.configurations.configs_for(env_name: "development", name: "primary")
|
1373
|
-
db_config.name
|
1374
|
-
```
|
1561
|
+
* Deprecate `legacy_connection_handling`.
|
1375
1562
|
|
1376
1563
|
*Eileen M. Uchitelle*
|
1377
1564
|
|
1378
|
-
* Add
|
1565
|
+
* Add attribute encryption support.
|
1379
1566
|
|
1380
|
-
|
1381
|
-
|
1567
|
+
Encrypted attributes are declared at the model level. These
|
1568
|
+
are regular Active Record attributes backed by a column with
|
1569
|
+
the same name. The system will transparently encrypt these
|
1570
|
+
attributes before saving them into the database and will
|
1571
|
+
decrypt them when retrieving their values.
|
1382
1572
|
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
rails db:drop:animals
|
1390
|
-
rails db:migrate
|
1391
|
-
rails db:migrate:primary
|
1392
|
-
rails db:migrate:animals
|
1573
|
+
|
1574
|
+
```ruby
|
1575
|
+
class Person < ApplicationRecord
|
1576
|
+
encrypts :name
|
1577
|
+
encrypts :email_address, deterministic: true
|
1578
|
+
end
|
1393
1579
|
```
|
1394
1580
|
|
1395
|
-
|
1396
|
-
|
1581
|
+
You can learn more in the [Active Record Encryption
|
1582
|
+
guide](https://edgeguides.rubyonrails.org/active_record_encryption.html).
|
1397
1583
|
|
1398
|
-
|
1399
|
-
rails db:schema:dump
|
1400
|
-
rails db:schema:dump:primary
|
1401
|
-
rails db:schema:dump:animals
|
1402
|
-
rails db:schema:load
|
1403
|
-
rails db:schema:load:primary
|
1404
|
-
rails db:schema:load:animals
|
1405
|
-
rails db:structure:dump
|
1406
|
-
rails db:structure:dump:primary
|
1407
|
-
rails db:structure:dump:animals
|
1408
|
-
rails db:structure:load
|
1409
|
-
rails db:structure:load:primary
|
1410
|
-
rails db:structure:load:animals
|
1411
|
-
rails db:test:prepare
|
1412
|
-
rails db:test:prepare:primary
|
1413
|
-
rails db:test:prepare:animals
|
1414
|
-
```
|
1584
|
+
*Jorge Manrubia*
|
1415
1585
|
|
1416
|
-
|
1586
|
+
* Changed Arel predications `contains` and `overlaps` to use
|
1587
|
+
`quoted_node` so that PostgreSQL arrays are quoted properly.
|
1417
1588
|
|
1418
|
-
*
|
1589
|
+
*Bradley Priest*
|
1419
1590
|
|
1420
|
-
|
1591
|
+
* Add mode argument to record level `strict_loading!`.
|
1421
1592
|
|
1422
|
-
|
1593
|
+
This argument can be used when enabling strict loading for a single record
|
1594
|
+
to specify that we only want to raise on n plus one queries.
|
1423
1595
|
|
1424
1596
|
```ruby
|
1425
|
-
|
1426
|
-
has_many :projects, strict_loading: true
|
1427
|
-
end
|
1597
|
+
developer.strict_loading!(mode: :n_plus_one_only)
|
1428
1598
|
|
1429
|
-
|
1430
|
-
|
1431
|
-
# => ActiveRecord::StrictLoadingViolationError: The projects association is marked as strict_loading and cannot be lazily loaded.
|
1599
|
+
developer.projects.to_a # Does not raise
|
1600
|
+
developer.projects.first.client # Raises StrictLoadingViolationError
|
1432
1601
|
```
|
1433
1602
|
|
1434
|
-
|
1603
|
+
Previously, enabling strict loading would cause any lazily loaded
|
1604
|
+
association to raise an error. Using `n_plus_one_only` mode allows us to
|
1605
|
+
lazily load belongs_to, has_many, and other associations that are fetched
|
1606
|
+
through a single query.
|
1435
1607
|
|
1436
|
-
*
|
1608
|
+
*Dinah Shi*
|
1437
1609
|
|
1438
|
-
|
1610
|
+
* Fix Float::INFINITY assignment to datetime column with postgresql adapter.
|
1439
1611
|
|
1440
|
-
|
1612
|
+
Before:
|
1441
1613
|
|
1442
1614
|
```ruby
|
1443
|
-
|
1444
|
-
|
1445
|
-
# => ActiveRecord::StrictLoadingViolationError: Developer is marked as strict_loading and AuditLog cannot be lazily loaded.
|
1446
|
-
```
|
1615
|
+
# With this config
|
1616
|
+
ActiveRecord::Base.time_zone_aware_attributes = true
|
1447
1617
|
|
1448
|
-
|
1618
|
+
# and the following schema:
|
1619
|
+
create_table "postgresql_infinities" do |t|
|
1620
|
+
t.datetime "datetime"
|
1621
|
+
end
|
1449
1622
|
|
1450
|
-
|
1623
|
+
# This test fails
|
1624
|
+
record = PostgresqlInfinity.create!(datetime: Float::INFINITY)
|
1625
|
+
assert_equal Float::INFINITY, record.datetime # record.datetime gets nil
|
1626
|
+
```
|
1451
1627
|
|
1452
|
-
|
1628
|
+
After this commit, `record.datetime` gets `Float::INFINITY` as expected.
|
1453
1629
|
|
1454
|
-
*
|
1630
|
+
*Shunichi Ikegami*
|
1455
1631
|
|
1456
|
-
|
1632
|
+
* Type cast enum values by the original attribute type.
|
1457
1633
|
|
1458
|
-
|
1634
|
+
The notable thing about this change is that unknown labels will no longer match 0 on MySQL.
|
1459
1635
|
|
1460
1636
|
```ruby
|
1461
|
-
class
|
1462
|
-
|
1463
|
-
add_column :posts, :title, :string, if_not_exists: true
|
1464
|
-
end
|
1637
|
+
class Book < ActiveRecord::Base
|
1638
|
+
enum :status, { proposed: 0, written: 1, published: 2 }
|
1465
1639
|
end
|
1466
1640
|
```
|
1467
1641
|
|
1642
|
+
Before:
|
1643
|
+
|
1468
1644
|
```ruby
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1645
|
+
# SELECT `books`.* FROM `books` WHERE `books`.`status` = 'prohibited' LIMIT 1
|
1646
|
+
Book.find_by(status: :prohibited)
|
1647
|
+
# => #<Book id: 1, status: "proposed", ...> (for mysql2 adapter)
|
1648
|
+
# => ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: invalid input syntax for type integer: "prohibited" (for postgresql adapter)
|
1649
|
+
# => nil (for sqlite3 adapter)
|
1474
1650
|
```
|
1475
1651
|
|
1476
|
-
|
1477
|
-
|
1478
|
-
* Regexp-escape table name for MS SQL Server.
|
1479
|
-
|
1480
|
-
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.
|
1481
|
-
|
1482
|
-
*Larry Reid*
|
1483
|
-
|
1484
|
-
* Store advisory locks on their own named connection.
|
1652
|
+
After:
|
1485
1653
|
|
1486
|
-
|
1654
|
+
```ruby
|
1655
|
+
# SELECT `books`.* FROM `books` WHERE `books`.`status` IS NULL LIMIT 1
|
1656
|
+
Book.find_by(status: :prohibited)
|
1657
|
+
# => nil (for all adapters)
|
1658
|
+
```
|
1487
1659
|
|
1488
|
-
|
1660
|
+
*Ryuta Kamizono*
|
1489
1661
|
|
1490
|
-
|
1662
|
+
* Fixtures for `has_many :through` associations now load timestamps on join tables.
|
1491
1663
|
|
1492
|
-
|
1664
|
+
Given this fixture:
|
1493
1665
|
|
1494
|
-
|
1666
|
+
```yml
|
1667
|
+
### monkeys.yml
|
1668
|
+
george:
|
1669
|
+
name: George the Monkey
|
1670
|
+
fruits: apple
|
1495
1671
|
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
database: blog_development
|
1500
|
-
pool: 5
|
1501
|
-
schema_cache_path: tmp/schema/main.yml
|
1672
|
+
### fruits.yml
|
1673
|
+
apple:
|
1674
|
+
name: apple
|
1502
1675
|
```
|
1503
1676
|
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1677
|
+
If the join table (`fruit_monkeys`) contains `created_at` or `updated_at` columns,
|
1678
|
+
these will now be populated when loading the fixture. Previously, fixture loading
|
1679
|
+
would crash if these columns were required, and leave them as null otherwise.
|
1507
1680
|
|
1508
|
-
|
1509
|
-
|
1510
|
-
*Eileen M. Uchitelle*, *John Crepezzi*
|
1511
|
-
|
1512
|
-
* Deprecate `#default_hash` and it's alias `#[]` on database configurations.
|
1681
|
+
*Alex Ghiculescu*
|
1513
1682
|
|
1514
|
-
|
1683
|
+
* Allow applications to configure the thread pool for async queries.
|
1515
1684
|
|
1516
|
-
|
1685
|
+
Some applications may want one thread pool per database whereas others want to use
|
1686
|
+
a single global thread pool for all queries. By default, Rails will set `async_query_executor`
|
1687
|
+
to `nil` which will not initialize any executor. If `load_async` is called and no executor
|
1688
|
+
has been configured, the query will be executed in the foreground.
|
1517
1689
|
|
1518
|
-
|
1690
|
+
To create one thread pool for all database connections to use applications can set
|
1691
|
+
`config.active_record.async_query_executor` to `:global_thread_pool` and optionally define
|
1692
|
+
`config.active_record.global_executor_concurrency`. This defaults to 4. For applications that want
|
1693
|
+
to have a thread pool for each database connection, `config.active_record.async_query_executor` can
|
1694
|
+
be set to `:multi_thread_pool`. The configuration for each thread pool is set in the database
|
1695
|
+
configuration.
|
1519
1696
|
|
1520
|
-
*
|
1697
|
+
*Eileen M. Uchitelle*
|
1521
1698
|
|
1522
|
-
*
|
1699
|
+
* Allow new syntax for `enum` to avoid leading `_` from reserved options.
|
1523
1700
|
|
1524
1701
|
Before:
|
1525
1702
|
|
1526
1703
|
```ruby
|
1527
|
-
|
1704
|
+
class Book < ActiveRecord::Base
|
1705
|
+
enum status: [ :proposed, :written ], _prefix: true, _scopes: false
|
1706
|
+
enum cover: [ :hard, :soft ], _suffix: true, _default: :hard
|
1707
|
+
end
|
1528
1708
|
```
|
1529
1709
|
|
1530
1710
|
After:
|
1531
1711
|
|
1532
1712
|
```ruby
|
1533
|
-
|
1713
|
+
class Book < ActiveRecord::Base
|
1714
|
+
enum :status, [ :proposed, :written ], prefix: true, scopes: false
|
1715
|
+
enum :cover, [ :hard, :soft ], suffix: true, default: :hard
|
1716
|
+
end
|
1534
1717
|
```
|
1535
1718
|
|
1536
|
-
*
|
1537
|
-
|
1538
|
-
* Ensure `:reading` connections always raise if a write is attempted.
|
1539
|
-
|
1540
|
-
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`.
|
1541
|
-
|
1542
|
-
*Eileen M. Uchitelle*
|
1543
|
-
|
1544
|
-
* Deprecate `"primary"` as the `connection_specification_name` for `ActiveRecord::Base`.
|
1545
|
-
|
1546
|
-
`"primary"` has been deprecated as the `connection_specification_name` for `ActiveRecord::Base` in favor of using `"ActiveRecord::Base"`. This change affects calls to `ActiveRecord::Base.connection_handler.retrieve_connection` and `ActiveRecord::Base.connection_handler.remove_connection`. If you're calling these methods with `"primary"`, please switch to `"ActiveRecord::Base"`.
|
1719
|
+
*Ryuta Kamizono*
|
1547
1720
|
|
1548
|
-
|
1721
|
+
* Add `ActiveRecord::Relation#load_async`.
|
1549
1722
|
|
1550
|
-
|
1551
|
-
support for casting floats using a database columns' precision value.
|
1723
|
+
This method schedules the query to be performed asynchronously from a thread pool.
|
1552
1724
|
|
1553
|
-
|
1725
|
+
If the result is accessed before a background thread had the opportunity to perform
|
1726
|
+
the query, it will be performed in the foreground.
|
1554
1727
|
|
1555
|
-
|
1556
|
-
|
1557
|
-
ActionController::ConditionalGet to ensure that when collection cache versioning
|
1558
|
-
is enabled, requests using ConditionalGet don't return the same ETag header
|
1559
|
-
after a collection is modified.
|
1728
|
+
This is useful for queries that can be performed long enough before their result will be
|
1729
|
+
needed, or for controllers which need to perform several independent queries.
|
1560
1730
|
|
1561
|
-
|
1731
|
+
```ruby
|
1732
|
+
def index
|
1733
|
+
@categories = Category.some_complex_scope.load_async
|
1734
|
+
@posts = Post.some_complex_scope.load_async
|
1735
|
+
end
|
1736
|
+
```
|
1562
1737
|
|
1563
|
-
|
1738
|
+
Active Record logs will also include timing info for the duration of how long
|
1739
|
+
the main thread had to wait to access the result. This timing is useful to know
|
1740
|
+
whether or not it's worth to load the query asynchronously.
|
1564
1741
|
|
1565
|
-
|
1566
|
-
|
1742
|
+
```
|
1743
|
+
DEBUG -- : Category Load (62.1ms) SELECT * FROM `categories` LIMIT 50
|
1744
|
+
DEBUG -- : ASYNC Post Load (64ms) (db time 126.1ms) SELECT * FROM `posts` LIMIT 100
|
1745
|
+
```
|
1567
1746
|
|
1568
|
-
|
1747
|
+
The duration in the first set of parens is how long the main thread was blocked
|
1748
|
+
waiting for the results, and the second set of parens with "db time" is how long
|
1749
|
+
the entire query took to execute.
|
1569
1750
|
|
1570
|
-
*
|
1751
|
+
*Jean Boussier*
|
1571
1752
|
|
1572
|
-
|
1753
|
+
* Implemented `ActiveRecord::Relation#excluding` method.
|
1573
1754
|
|
1574
|
-
|
1755
|
+
This method excludes the specified record (or collection of records) from
|
1756
|
+
the resulting relation:
|
1575
1757
|
|
1576
1758
|
```ruby
|
1577
|
-
|
1578
|
-
|
1759
|
+
Post.excluding(post)
|
1760
|
+
Post.excluding(post_one, post_two)
|
1579
1761
|
```
|
1580
1762
|
|
1581
|
-
|
1763
|
+
Also works on associations:
|
1582
1764
|
|
1583
1765
|
```ruby
|
1584
|
-
|
1585
|
-
|
1586
|
-
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(@db_config.env_name, @db_config.spec_name, config)
|
1766
|
+
post.comments.excluding(comment)
|
1767
|
+
post.comments.excluding(comment_one, comment_two)
|
1587
1768
|
```
|
1588
1769
|
|
1589
|
-
|
1590
|
-
|
1591
|
-
* Remove `:connection_id` from the `sql.active_record` notification.
|
1770
|
+
This is short-hand for `Post.where.not(id: post.id)` (for a single record)
|
1771
|
+
and `Post.where.not(id: [post_one.id, post_two.id])` (for a collection).
|
1592
1772
|
|
1593
|
-
*
|
1773
|
+
*Glen Crawford*
|
1594
1774
|
|
1595
|
-
*
|
1775
|
+
* Skip optimised #exist? query when #include? is called on a relation
|
1776
|
+
with a having clause.
|
1596
1777
|
|
1597
|
-
|
1778
|
+
Relations that have aliased select values AND a having clause that
|
1779
|
+
references an aliased select value would generate an error when
|
1780
|
+
#include? was called, due to an optimisation that would generate
|
1781
|
+
call #exists? on the relation instead, which effectively alters
|
1782
|
+
the select values of the query (and thus removes the aliased select
|
1783
|
+
values), but leaves the having clause intact. Because the having
|
1784
|
+
clause is then referencing an aliased column that is no longer
|
1785
|
+
present in the simplified query, an ActiveRecord::InvalidStatement
|
1786
|
+
error was raised.
|
1598
1787
|
|
1599
|
-
|
1788
|
+
A sample query affected by this problem:
|
1600
1789
|
|
1601
|
-
|
1602
|
-
|
1790
|
+
```ruby
|
1791
|
+
Author.select('COUNT(*) as total_posts', 'authors.*')
|
1792
|
+
.joins(:posts)
|
1793
|
+
.group(:id)
|
1794
|
+
.having('total_posts > 2')
|
1795
|
+
.include?(Author.first)
|
1796
|
+
```
|
1603
1797
|
|
1604
|
-
This change
|
1605
|
-
|
1798
|
+
This change adds an addition check to the condition that skips the
|
1799
|
+
simplified #exists? query, which simply checks for the presence of
|
1800
|
+
a having clause.
|
1606
1801
|
|
1607
|
-
|
1802
|
+
Fixes #41417.
|
1608
1803
|
|
1609
|
-
*
|
1804
|
+
*Michael Smart*
|
1610
1805
|
|
1611
|
-
|
1806
|
+
* Increment postgres prepared statement counter before making a prepared statement, so if the statement is aborted
|
1807
|
+
without Rails knowledge (e.g., if app gets killed during long-running query or due to Rack::Timeout), app won't end
|
1808
|
+
up in perpetual crash state for being inconsistent with PostgreSQL.
|
1612
1809
|
|
1613
|
-
*
|
1810
|
+
*wbharding*, *Martin Tepper*
|
1614
1811
|
|
1615
|
-
|
1812
|
+
* Add ability to apply `scoping` to `all_queries`.
|
1616
1813
|
|
1617
|
-
|
1814
|
+
Some applications may want to use the `scoping` method but previously it only
|
1815
|
+
worked on certain types of queries. This change allows the `scoping` method to apply
|
1816
|
+
to all queries for a model in a block.
|
1618
1817
|
|
1619
|
-
|
1818
|
+
```ruby
|
1819
|
+
Post.where(blog_id: post.blog_id).scoping(all_queries: true) do
|
1820
|
+
post.update(title: "a post title") # adds `posts.blog_id = 1` to the query
|
1821
|
+
end
|
1822
|
+
```
|
1620
1823
|
|
1621
|
-
*Eileen M. Uchitelle
|
1824
|
+
*Eileen M. Uchitelle*
|
1622
1825
|
|
1623
|
-
*
|
1826
|
+
* `ActiveRecord::Calculations.calculate` called with `:average`
|
1827
|
+
(aliased as `ActiveRecord::Calculations.average`) will now use column-based
|
1828
|
+
type casting. This means that floating-point number columns will now be
|
1829
|
+
aggregated as `Float` and decimal columns will be aggregated as `BigDecimal`.
|
1624
1830
|
|
1625
|
-
|
1831
|
+
Integers are handled as a special case returning `BigDecimal` always
|
1832
|
+
(this was the case before already).
|
1626
1833
|
|
1627
|
-
|
1834
|
+
```ruby
|
1835
|
+
# With the following schema:
|
1836
|
+
create_table "measurements" do |t|
|
1837
|
+
t.float "temperature"
|
1838
|
+
end
|
1628
1839
|
|
1629
|
-
|
1840
|
+
# Before:
|
1841
|
+
Measurement.average(:temperature).class
|
1842
|
+
# => BigDecimal
|
1630
1843
|
|
1631
|
-
|
1844
|
+
# After:
|
1845
|
+
Measurement.average(:temperature).class
|
1846
|
+
# => Float
|
1847
|
+
```
|
1632
1848
|
|
1633
|
-
|
1849
|
+
Before this change, Rails just called `to_d` on average aggregates from the
|
1850
|
+
database adapter. This is not the case anymore. If you relied on that kind
|
1851
|
+
of magic, you now need to register your own `ActiveRecord::Type`
|
1852
|
+
(see `ActiveRecord::Attributes::ClassMethods` for documentation).
|
1634
1853
|
|
1635
|
-
*
|
1854
|
+
*Josua Schmid*
|
1636
1855
|
|
1637
|
-
|
1856
|
+
* PostgreSQL: introduce `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.datetime_type`.
|
1638
1857
|
|
1639
|
-
|
1858
|
+
This setting controls what native type Active Record should use when you call `datetime` in
|
1859
|
+
a migration or schema. It takes a symbol which must correspond to one of the configured
|
1860
|
+
`NATIVE_DATABASE_TYPES`. The default is `:timestamp`, meaning `t.datetime` in a migration
|
1861
|
+
will create a "timestamp without time zone" column. To use "timestamp with time zone",
|
1862
|
+
change this to `:timestamptz` in an initializer.
|
1640
1863
|
|
1641
|
-
|
1864
|
+
You should run `bin/rails db:migrate` to rebuild your schema.rb if you change this.
|
1642
1865
|
|
1643
|
-
*
|
1866
|
+
*Alex Ghiculescu*
|
1644
1867
|
|
1645
|
-
|
1868
|
+
* PostgreSQL: handle `timestamp with time zone` columns correctly in `schema.rb`.
|
1646
1869
|
|
1647
|
-
|
1870
|
+
Previously they dumped as `t.datetime :column_name`, now they dump as `t.timestamptz :column_name`,
|
1871
|
+
and are created as `timestamptz` columns when the schema is loaded.
|
1648
1872
|
|
1649
|
-
*
|
1873
|
+
*Alex Ghiculescu*
|
1650
1874
|
|
1651
|
-
*
|
1652
|
-
|
1875
|
+
* Removing trailing whitespace when matching columns in
|
1876
|
+
`ActiveRecord::Sanitization.disallow_raw_sql!`.
|
1653
1877
|
|
1654
|
-
|
1878
|
+
*Gannon McGibbon*, *Adrian Hirt*
|
1655
1879
|
|
1656
|
-
|
1657
|
-
has_secure_token :auth_token
|
1658
|
-
```
|
1880
|
+
* Expose a way for applications to set a `primary_abstract_class`.
|
1659
1881
|
|
1660
|
-
|
1882
|
+
Multiple database applications that use a primary abstract class that is not
|
1883
|
+
named `ApplicationRecord` can now set a specific class to be the `primary_abstract_class`.
|
1661
1884
|
|
1662
1885
|
```ruby
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1886
|
+
class PrimaryApplicationRecord
|
1887
|
+
self.primary_abstract_class
|
1888
|
+
end
|
1666
1889
|
```
|
1667
1890
|
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1891
|
+
When an application boots it automatically connects to the primary or first database in the
|
1892
|
+
database configuration file. In a multiple database application that then call `connects_to`
|
1893
|
+
needs to know that the default connection is the same as the `ApplicationRecord` connection.
|
1894
|
+
However, some applications have a differently named `ApplicationRecord`. This prevents Active
|
1895
|
+
Record from opening duplicate connections to the same database.
|
1671
1896
|
|
1672
|
-
*Eileen Uchitelle*, *John Crepezzi*
|
1897
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1673
1898
|
|
1674
|
-
*
|
1899
|
+
* Support hash config for `structure_dump_flags` and `structure_load_flags` flags.
|
1900
|
+
Now that Active Record supports multiple databases configuration,
|
1901
|
+
we need a way to pass specific flags for dump/load databases since
|
1902
|
+
the options are not the same for different adapters.
|
1903
|
+
We can use in the original way:
|
1675
1904
|
|
1676
|
-
|
1905
|
+
```ruby
|
1906
|
+
ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = ['--no-defaults', '--skip-add-drop-table']
|
1907
|
+
# or
|
1908
|
+
ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = '--no-defaults --skip-add-drop-table'
|
1909
|
+
```
|
1677
1910
|
|
1678
|
-
|
1911
|
+
And also use it passing a hash, with one or more keys, where the key
|
1912
|
+
is the adapter
|
1679
1913
|
|
1680
|
-
|
1914
|
+
```ruby
|
1915
|
+
ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = {
|
1916
|
+
mysql2: ['--no-defaults', '--skip-add-drop-table'],
|
1917
|
+
postgres: '--no-tablespaces'
|
1918
|
+
}
|
1919
|
+
```
|
1681
1920
|
|
1682
|
-
|
1921
|
+
*Gustavo Gonzalez*
|
1683
1922
|
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1923
|
+
* Connection specification now passes the "url" key as a configuration for the
|
1924
|
+
adapter if the "url" protocol is "jdbc", "http", or "https". Previously only
|
1925
|
+
urls with the "jdbc" prefix were passed to the Active Record Adapter, others
|
1926
|
+
are assumed to be adapter specification urls.
|
1688
1927
|
|
1689
|
-
|
1928
|
+
Fixes #41137.
|
1690
1929
|
|
1691
|
-
|
1930
|
+
*Jonathan Bracy*
|
1692
1931
|
|
1693
|
-
|
1932
|
+
* Allow to opt-out of `strict_loading` mode on a per-record base.
|
1694
1933
|
|
1695
|
-
|
1934
|
+
This is useful when strict loading is enabled application wide or on a
|
1935
|
+
model level.
|
1696
1936
|
|
1697
|
-
|
1937
|
+
```ruby
|
1938
|
+
class User < ApplicationRecord
|
1939
|
+
has_many :bookmarks
|
1940
|
+
has_many :articles, strict_loading: true
|
1941
|
+
end
|
1698
1942
|
|
1699
|
-
|
1943
|
+
user = User.first
|
1944
|
+
user.articles # => ActiveRecord::StrictLoadingViolationError
|
1945
|
+
user.bookmarks # => #<ActiveRecord::Associations::CollectionProxy>
|
1700
1946
|
|
1701
|
-
|
1947
|
+
user.strict_loading!(true) # => true
|
1948
|
+
user.bookmarks # => ActiveRecord::StrictLoadingViolationError
|
1702
1949
|
|
1703
|
-
|
1950
|
+
user.strict_loading!(false) # => false
|
1951
|
+
user.bookmarks # => #<ActiveRecord::Associations::CollectionProxy>
|
1952
|
+
user.articles.strict_loading!(false) # => #<ActiveRecord::Associations::CollectionProxy>
|
1953
|
+
```
|
1704
1954
|
|
1705
|
-
|
1955
|
+
*Ayrton De Craene*
|
1706
1956
|
|
1707
|
-
|
1957
|
+
* Add `FinderMethods#sole` and `#find_sole_by` to find and assert the
|
1958
|
+
presence of exactly one record.
|
1708
1959
|
|
1709
|
-
|
1960
|
+
Used when you need a single row, but also want to assert that there aren't
|
1961
|
+
multiple rows matching the condition; especially for when database
|
1962
|
+
constraints aren't enough or are impractical.
|
1710
1963
|
|
1711
|
-
|
1964
|
+
```ruby
|
1965
|
+
Product.where(["price = %?", price]).sole
|
1966
|
+
# => ActiveRecord::RecordNotFound (if no Product with given price)
|
1967
|
+
# => #<Product ...> (if one Product with given price)
|
1968
|
+
# => ActiveRecord::SoleRecordExceeded (if more than one Product with given price)
|
1712
1969
|
|
1713
|
-
|
1970
|
+
user.api_keys.find_sole_by(key: key)
|
1971
|
+
# as above
|
1972
|
+
```
|
1714
1973
|
|
1715
|
-
*
|
1974
|
+
*Asherah Connor*
|
1716
1975
|
|
1717
|
-
|
1976
|
+
* Makes `ActiveRecord::AttributeMethods::Query` respect the getter overrides defined in the model.
|
1718
1977
|
|
1719
|
-
|
1978
|
+
Before:
|
1720
1979
|
|
1721
|
-
|
1980
|
+
```ruby
|
1981
|
+
class User
|
1982
|
+
def admin
|
1983
|
+
false # Overriding the getter to always return false
|
1984
|
+
end
|
1985
|
+
end
|
1722
1986
|
|
1723
|
-
|
1987
|
+
user = User.first
|
1988
|
+
user.update(admin: true)
|
1724
1989
|
|
1725
|
-
|
1990
|
+
user.admin # false (as expected, due to the getter overwrite)
|
1991
|
+
user.admin? # true (not expected, returned the DB column value)
|
1992
|
+
```
|
1726
1993
|
|
1727
|
-
|
1994
|
+
After this commit, `user.admin?` above returns false, as expected.
|
1728
1995
|
|
1729
|
-
|
1996
|
+
Fixes #40771.
|
1730
1997
|
|
1731
|
-
*
|
1998
|
+
*Felipe*
|
1732
1999
|
|
1733
|
-
|
2000
|
+
* Allow delegated_type to be specified primary_key and foreign_key.
|
1734
2001
|
|
1735
|
-
|
2002
|
+
Since delegated_type assumes that the foreign_key ends with `_id`,
|
2003
|
+
`singular_id` defined by it does not work when the foreign_key does
|
2004
|
+
not end with `id`. This change fixes it by taking into account
|
2005
|
+
`primary_key` and `foreign_key` in the options.
|
1736
2006
|
|
1737
|
-
*
|
2007
|
+
*Ryota Egusa*
|
1738
2008
|
|
1739
|
-
*
|
2009
|
+
* Expose an `invert_where` method that will invert all scope conditions.
|
1740
2010
|
|
1741
|
-
|
2011
|
+
```ruby
|
2012
|
+
class User
|
2013
|
+
scope :active, -> { where(accepted: true, locked: false) }
|
2014
|
+
end
|
1742
2015
|
|
1743
|
-
|
2016
|
+
User.active
|
2017
|
+
# ... WHERE `accepted` = 1 AND `locked` = 0
|
1744
2018
|
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
2019
|
+
User.active.invert_where
|
2020
|
+
# ... WHERE NOT (`accepted` = 1 AND `locked` = 0)
|
2021
|
+
```
|
1748
2022
|
|
1749
|
-
*
|
2023
|
+
*Kevin Deisz*
|
1750
2024
|
|
1751
|
-
*
|
2025
|
+
* Restore possibility of passing `false` to :polymorphic option of `belongs_to`.
|
1752
2026
|
|
1753
|
-
|
2027
|
+
Previously, passing `false` would trigger the option validation logic
|
2028
|
+
to throw an error saying :polymorphic would not be a valid option.
|
1754
2029
|
|
1755
|
-
*
|
2030
|
+
*glaszig*
|
1756
2031
|
|
1757
|
-
|
2032
|
+
* Remove deprecated `database` kwarg from `connected_to`.
|
1758
2033
|
|
1759
|
-
*
|
2034
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1760
2035
|
|
1761
|
-
|
2036
|
+
* Allow adding nonnamed expression indexes to be revertible.
|
1762
2037
|
|
1763
|
-
|
2038
|
+
Previously, the following code would raise an error, when executed while rolling back,
|
2039
|
+
and the index name should be specified explicitly. Now, the index name is inferred
|
2040
|
+
automatically.
|
1764
2041
|
|
1765
|
-
|
2042
|
+
```ruby
|
2043
|
+
add_index(:items, "to_tsvector('english', description)")
|
2044
|
+
```
|
1766
2045
|
|
1767
|
-
|
2046
|
+
Fixes #40732.
|
1768
2047
|
|
1769
|
-
|
2048
|
+
*fatkodima*
|
1770
2049
|
|
1771
|
-
|
2050
|
+
* Only warn about negative enums if a positive form that would cause conflicts exists.
|
1772
2051
|
|
1773
|
-
|
2052
|
+
Fixes #39065.
|
1774
2053
|
|
1775
|
-
|
2054
|
+
*Alex Ghiculescu*
|
1776
2055
|
|
1777
|
-
|
2056
|
+
* Add option to run `default_scope` on all queries.
|
1778
2057
|
|
1779
|
-
|
2058
|
+
Previously, a `default_scope` would only run on select or insert queries. In some cases, like non-Rails tenant sharding solutions, it may be desirable to run `default_scope` on all queries in order to ensure queries are including a foreign key for the shard (i.e. `blog_id`).
|
1780
2059
|
|
1781
|
-
|
2060
|
+
Now applications can add an option to run on all queries including select, insert, delete, and update by adding an `all_queries` option to the default scope definition.
|
1782
2061
|
|
1783
|
-
|
2062
|
+
```ruby
|
2063
|
+
class Article < ApplicationRecord
|
2064
|
+
default_scope -> { where(blog_id: Current.blog.id) }, all_queries: true
|
2065
|
+
end
|
2066
|
+
```
|
1784
2067
|
|
1785
|
-
*
|
2068
|
+
*Eileen M. Uchitelle*
|
1786
2069
|
|
1787
|
-
*
|
2070
|
+
* Add `where.associated` to check for the presence of an association.
|
1788
2071
|
|
1789
|
-
|
2072
|
+
```ruby
|
2073
|
+
# Before:
|
2074
|
+
account.users.joins(:contact).where.not(contact_id: nil)
|
1790
2075
|
|
1791
|
-
|
2076
|
+
# After:
|
2077
|
+
account.users.where.associated(:contact)
|
2078
|
+
```
|
1792
2079
|
|
1793
|
-
|
2080
|
+
Also mirrors `where.missing`.
|
1794
2081
|
|
1795
|
-
*
|
2082
|
+
*Kasper Timm Hansen*
|
1796
2083
|
|
1797
|
-
* Allow
|
2084
|
+
* Allow constructors (`build_association` and `create_association`) on
|
2085
|
+
`has_one :through` associations.
|
1798
2086
|
|
1799
|
-
*
|
2087
|
+
*Santiago Perez Perret*
|
1800
2088
|
|
1801
2089
|
|
1802
|
-
Please check [6-
|
2090
|
+
Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/activerecord/CHANGELOG.md) for previous changes.
|