activerecord 6.0.1 → 6.1.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1314 -633
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -4
- data/lib/active_record/aggregations.rb +5 -6
- data/lib/active_record/association_relation.rb +26 -15
- data/lib/active_record/associations/alias_tracker.rb +19 -16
- data/lib/active_record/associations/association.rb +55 -37
- data/lib/active_record/associations/association_scope.rb +19 -15
- data/lib/active_record/associations/belongs_to_association.rb +23 -10
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +8 -3
- data/lib/active_record/associations/builder/association.rb +32 -5
- data/lib/active_record/associations/builder/belongs_to.rb +10 -7
- data/lib/active_record/associations/builder/collection_association.rb +5 -4
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +0 -3
- data/lib/active_record/associations/builder/has_many.rb +6 -2
- data/lib/active_record/associations/builder/has_one.rb +11 -14
- data/lib/active_record/associations/builder/singular_association.rb +1 -1
- data/lib/active_record/associations/collection_association.rb +38 -13
- data/lib/active_record/associations/collection_proxy.rb +14 -7
- data/lib/active_record/associations/foreign_association.rb +13 -0
- data/lib/active_record/associations/has_many_association.rb +24 -3
- data/lib/active_record/associations/has_many_through_association.rb +10 -4
- data/lib/active_record/associations/has_one_association.rb +15 -1
- data/lib/active_record/associations/join_dependency/join_association.rb +39 -16
- data/lib/active_record/associations/join_dependency/join_part.rb +3 -3
- data/lib/active_record/associations/join_dependency.rb +73 -42
- data/lib/active_record/associations/preloader/association.rb +49 -25
- data/lib/active_record/associations/preloader/through_association.rb +2 -2
- data/lib/active_record/associations/preloader.rb +12 -7
- data/lib/active_record/associations/singular_association.rb +1 -1
- data/lib/active_record/associations/through_association.rb +1 -1
- data/lib/active_record/associations.rb +119 -12
- data/lib/active_record/attribute_assignment.rb +10 -9
- data/lib/active_record/attribute_methods/before_type_cast.rb +13 -10
- data/lib/active_record/attribute_methods/dirty.rb +3 -13
- data/lib/active_record/attribute_methods/primary_key.rb +6 -4
- data/lib/active_record/attribute_methods/query.rb +3 -6
- data/lib/active_record/attribute_methods/read.rb +8 -12
- data/lib/active_record/attribute_methods/serialization.rb +11 -6
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +12 -15
- data/lib/active_record/attribute_methods/write.rb +12 -21
- data/lib/active_record/attribute_methods.rb +64 -54
- data/lib/active_record/attributes.rb +33 -9
- data/lib/active_record/autosave_association.rb +56 -41
- data/lib/active_record/base.rb +2 -14
- data/lib/active_record/callbacks.rb +153 -24
- data/lib/active_record/coders/yaml_column.rb +24 -3
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +190 -136
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +2 -44
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +83 -38
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +3 -9
- data/lib/active_record/connection_adapters/abstract/quoting.rb +34 -34
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +3 -3
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +152 -116
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +145 -52
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +3 -3
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +267 -105
- data/lib/active_record/connection_adapters/abstract/transaction.rb +94 -36
- data/lib/active_record/connection_adapters/abstract_adapter.rb +63 -77
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +136 -111
- data/lib/active_record/connection_adapters/column.rb +15 -1
- data/lib/active_record/connection_adapters/deduplicable.rb +29 -0
- data/lib/active_record/connection_adapters/legacy_pool_manager.rb +35 -0
- data/lib/active_record/connection_adapters/mysql/column.rb +1 -1
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +30 -36
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +1 -2
- data/lib/active_record/connection_adapters/mysql/quoting.rb +18 -3
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +32 -7
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +8 -0
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +5 -2
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +20 -13
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +10 -1
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +31 -13
- data/lib/active_record/connection_adapters/pool_config.rb +73 -0
- data/lib/active_record/connection_adapters/pool_manager.rb +47 -0
- data/lib/active_record/connection_adapters/postgresql/column.rb +24 -1
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +21 -56
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +3 -5
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +10 -2
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/interval.rb +49 -0
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +2 -3
- data/lib/active_record/connection_adapters/postgresql/oid/macaddr.rb +25 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +2 -3
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +24 -6
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +11 -2
- data/lib/active_record/connection_adapters/postgresql/oid.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +4 -4
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +7 -3
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +72 -54
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +8 -0
- data/lib/active_record/connection_adapters/postgresql/utils.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +80 -66
- data/lib/active_record/connection_adapters/schema_cache.rb +130 -15
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +8 -0
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +38 -12
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +1 -2
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +5 -1
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +38 -5
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +57 -57
- data/lib/active_record/connection_adapters/statement_pool.rb +0 -1
- data/lib/active_record/connection_adapters.rb +52 -0
- data/lib/active_record/connection_handling.rb +218 -87
- data/lib/active_record/core.rb +269 -68
- data/lib/active_record/counter_cache.rb +4 -1
- data/lib/active_record/database_configurations/connection_url_resolver.rb +99 -0
- data/lib/active_record/database_configurations/database_config.rb +52 -9
- data/lib/active_record/database_configurations/hash_config.rb +54 -8
- data/lib/active_record/database_configurations/url_config.rb +15 -41
- data/lib/active_record/database_configurations.rb +125 -85
- data/lib/active_record/delegated_type.rb +209 -0
- data/lib/active_record/destroy_association_async_job.rb +36 -0
- data/lib/active_record/dynamic_matchers.rb +2 -3
- data/lib/active_record/enum.rb +80 -38
- data/lib/active_record/errors.rb +47 -12
- data/lib/active_record/explain.rb +9 -5
- data/lib/active_record/explain_subscriber.rb +1 -1
- data/lib/active_record/fixture_set/file.rb +10 -17
- data/lib/active_record/fixture_set/model_metadata.rb +1 -2
- data/lib/active_record/fixture_set/render_context.rb +1 -1
- data/lib/active_record/fixture_set/table_row.rb +2 -3
- data/lib/active_record/fixture_set/table_rows.rb +0 -1
- data/lib/active_record/fixtures.rb +58 -12
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/inheritance.rb +40 -21
- data/lib/active_record/insert_all.rb +42 -9
- data/lib/active_record/integration.rb +3 -5
- data/lib/active_record/internal_metadata.rb +18 -7
- data/lib/active_record/legacy_yaml_adapter.rb +7 -3
- data/lib/active_record/locking/optimistic.rb +33 -18
- data/lib/active_record/locking/pessimistic.rb +6 -2
- data/lib/active_record/log_subscriber.rb +28 -9
- data/lib/active_record/middleware/database_selector/resolver/session.rb +3 -0
- data/lib/active_record/middleware/database_selector/resolver.rb +6 -2
- data/lib/active_record/middleware/database_selector.rb +4 -2
- data/lib/active_record/migration/command_recorder.rb +53 -45
- data/lib/active_record/migration/compatibility.rb +75 -21
- data/lib/active_record/migration/join_table.rb +0 -1
- data/lib/active_record/migration.rb +115 -85
- data/lib/active_record/model_schema.rb +117 -15
- data/lib/active_record/nested_attributes.rb +2 -5
- data/lib/active_record/no_touching.rb +1 -1
- data/lib/active_record/null_relation.rb +0 -1
- data/lib/active_record/persistence.rb +50 -46
- data/lib/active_record/query_cache.rb +15 -5
- data/lib/active_record/querying.rb +12 -7
- data/lib/active_record/railtie.rb +65 -45
- data/lib/active_record/railties/console_sandbox.rb +2 -4
- data/lib/active_record/railties/databases.rake +280 -99
- data/lib/active_record/readonly_attributes.rb +4 -0
- data/lib/active_record/reflection.rb +77 -63
- data/lib/active_record/relation/batches/batch_enumerator.rb +25 -9
- data/lib/active_record/relation/batches.rb +38 -32
- data/lib/active_record/relation/calculations.rb +106 -45
- data/lib/active_record/relation/delegation.rb +9 -7
- data/lib/active_record/relation/finder_methods.rb +45 -16
- data/lib/active_record/relation/from_clause.rb +5 -1
- data/lib/active_record/relation/merger.rb +27 -26
- data/lib/active_record/relation/predicate_builder/array_handler.rb +8 -9
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +4 -5
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +10 -6
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +1 -1
- data/lib/active_record/relation/predicate_builder.rb +59 -40
- data/lib/active_record/relation/query_methods.rb +339 -188
- data/lib/active_record/relation/record_fetch_warning.rb +3 -3
- data/lib/active_record/relation/spawn_methods.rb +8 -8
- data/lib/active_record/relation/where_clause.rb +111 -62
- data/lib/active_record/relation.rb +116 -83
- data/lib/active_record/result.rb +41 -34
- data/lib/active_record/runtime_registry.rb +2 -2
- data/lib/active_record/sanitization.rb +6 -17
- data/lib/active_record/schema_dumper.rb +34 -4
- data/lib/active_record/schema_migration.rb +2 -8
- data/lib/active_record/scoping/default.rb +1 -4
- data/lib/active_record/scoping/named.rb +7 -18
- data/lib/active_record/scoping.rb +0 -1
- data/lib/active_record/secure_token.rb +16 -8
- data/lib/active_record/serialization.rb +5 -3
- data/lib/active_record/signed_id.rb +116 -0
- data/lib/active_record/statement_cache.rb +20 -4
- data/lib/active_record/store.rb +9 -4
- data/lib/active_record/suppressor.rb +2 -2
- data/lib/active_record/table_metadata.rb +42 -36
- data/lib/active_record/tasks/database_tasks.rb +140 -113
- data/lib/active_record/tasks/mysql_database_tasks.rb +34 -36
- data/lib/active_record/tasks/postgresql_database_tasks.rb +24 -27
- data/lib/active_record/tasks/sqlite_database_tasks.rb +13 -10
- data/lib/active_record/test_databases.rb +5 -4
- data/lib/active_record/test_fixtures.rb +87 -20
- data/lib/active_record/timestamp.rb +4 -7
- data/lib/active_record/touch_later.rb +20 -21
- data/lib/active_record/transactions.rb +25 -72
- data/lib/active_record/type/adapter_specific_registry.rb +2 -5
- data/lib/active_record/type/hash_lookup_type_map.rb +0 -1
- data/lib/active_record/type/serialized.rb +6 -3
- data/lib/active_record/type/time.rb +10 -0
- data/lib/active_record/type/type_map.rb +0 -1
- data/lib/active_record/type/unsigned_integer.rb +0 -1
- data/lib/active_record/type.rb +8 -2
- data/lib/active_record/type_caster/connection.rb +0 -1
- data/lib/active_record/type_caster/map.rb +8 -5
- data/lib/active_record/validations/associated.rb +1 -2
- data/lib/active_record/validations/numericality.rb +35 -0
- data/lib/active_record/validations/uniqueness.rb +24 -4
- data/lib/active_record/validations.rb +3 -3
- data/lib/active_record.rb +7 -13
- data/lib/arel/attributes/attribute.rb +4 -0
- data/lib/arel/collectors/bind.rb +5 -0
- data/lib/arel/collectors/composite.rb +8 -0
- data/lib/arel/collectors/sql_string.rb +7 -0
- data/lib/arel/collectors/substitute_binds.rb +7 -0
- data/lib/arel/nodes/binary.rb +82 -8
- data/lib/arel/nodes/bind_param.rb +8 -0
- data/lib/arel/nodes/casted.rb +21 -9
- data/lib/arel/nodes/equality.rb +6 -9
- data/lib/arel/nodes/grouping.rb +3 -0
- data/lib/arel/nodes/homogeneous_in.rb +76 -0
- data/lib/arel/nodes/in.rb +8 -1
- data/lib/arel/nodes/infix_operation.rb +13 -1
- data/lib/arel/nodes/join_source.rb +1 -1
- data/lib/arel/nodes/node.rb +7 -6
- data/lib/arel/nodes/ordering.rb +27 -0
- data/lib/arel/nodes/sql_literal.rb +3 -0
- data/lib/arel/nodes/table_alias.rb +7 -3
- data/lib/arel/nodes/unary.rb +0 -1
- data/lib/arel/nodes.rb +3 -1
- data/lib/arel/predications.rb +17 -24
- data/lib/arel/select_manager.rb +1 -2
- data/lib/arel/table.rb +13 -5
- data/lib/arel/visitors/dot.rb +14 -3
- data/lib/arel/visitors/mysql.rb +11 -1
- data/lib/arel/visitors/postgresql.rb +15 -5
- data/lib/arel/visitors/sqlite.rb +0 -1
- data/lib/arel/visitors/to_sql.rb +89 -79
- data/lib/arel/visitors/visitor.rb +0 -1
- data/lib/arel/visitors.rb +0 -7
- data/lib/arel.rb +5 -9
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +0 -1
- data/lib/rails/generators/active_record/migration/migration_generator.rb +1 -0
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +2 -0
- data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +4 -4
- data/lib/rails/generators/active_record/migration.rb +6 -2
- data/lib/rails/generators/active_record/model/model_generator.rb +38 -2
- data/lib/rails/generators/active_record/model/templates/abstract_base_class.rb.tt +7 -0
- metadata +30 -29
- data/lib/active_record/attribute_decorators.rb +0 -90
- data/lib/active_record/connection_adapters/connection_specification.rb +0 -297
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +0 -29
- data/lib/active_record/define_callbacks.rb +0 -22
- data/lib/active_record/railties/collection_cache_association_loading.rb +0 -34
- data/lib/active_record/relation/predicate_builder/base_handler.rb +0 -18
- data/lib/active_record/relation/where_clause_factory.rb +0 -33
- data/lib/arel/attributes.rb +0 -22
- data/lib/arel/visitors/depth_first.rb +0 -204
- data/lib/arel/visitors/ibm_db.rb +0 -34
- data/lib/arel/visitors/informix.rb +0 -62
- data/lib/arel/visitors/mssql.rb +0 -157
- data/lib/arel/visitors/oracle.rb +0 -159
- data/lib/arel/visitors/oracle12.rb +0 -66
- data/lib/arel/visitors/where_sql.rb +0 -23
data/CHANGELOG.md
CHANGED
@@ -1,1086 +1,1767 @@
|
|
1
|
-
## Rails 6.
|
1
|
+
## Rails 6.1.7 (September 09, 2022) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Symbol is allowed by default for YAML columns
|
4
4
|
|
5
|
-
|
5
|
+
*Étienne Barrié*
|
6
6
|
|
7
|
-
*
|
7
|
+
* Fix `ActiveRecord::Store` to serialize as a regular Hash
|
8
8
|
|
9
|
-
|
9
|
+
Previously it would serialize as an `ActiveSupport::HashWithIndifferentAccess`
|
10
|
+
which is wasteful and cause problem with YAML safe_load.
|
10
11
|
|
11
|
-
*
|
12
|
+
*Jean Boussier*
|
12
13
|
|
13
|
-
|
14
|
+
* Fix PG.connect keyword arguments deprecation warning on ruby 2.7
|
14
15
|
|
15
|
-
|
16
|
-
context is used.
|
16
|
+
Fixes #44307.
|
17
17
|
|
18
|
-
|
18
|
+
*Nikita Vasilevsky*
|
19
19
|
|
20
|
-
|
21
|
-
their payloads.
|
20
|
+
## Rails 6.1.6.1 (July 12, 2022) ##
|
22
21
|
|
23
|
-
|
22
|
+
* Change ActiveRecord::Coders::YAMLColumn default to safe_load
|
24
23
|
|
25
|
-
|
26
|
-
|
24
|
+
This adds two new configuration options The configuration options are as
|
25
|
+
follows:
|
26
|
+
|
27
|
+
* `config.active_storage.use_yaml_unsafe_load`
|
28
|
+
|
29
|
+
When set to true, this configuration option tells Rails to use the old
|
30
|
+
"unsafe" YAML loading strategy, maintaining the existing behavior but leaving
|
31
|
+
the possible escalation vulnerability in place. Setting this option to true
|
32
|
+
is *not* recommended, but can aid in upgrading.
|
33
|
+
|
34
|
+
* `config.active_record.yaml_column_permitted_classes`
|
35
|
+
|
36
|
+
The "safe YAML" loading method does not allow all classes to be deserialized
|
37
|
+
by default. This option allows you to specify classes deemed "safe" in your
|
38
|
+
application. For example, if your application uses Symbol and Time in
|
39
|
+
serialized data, you can add Symbol and Time to the allowed list as follows:
|
40
|
+
|
41
|
+
```
|
42
|
+
config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time]
|
43
|
+
```
|
27
44
|
|
28
|
-
|
45
|
+
[CVE-2022-32224]
|
29
46
|
|
30
|
-
* Fixed that join order was lost when eager-loading.
|
31
47
|
|
32
|
-
|
48
|
+
## Rails 6.1.6 (May 09, 2022) ##
|
33
49
|
|
34
|
-
*
|
50
|
+
* No changes.
|
35
51
|
|
36
|
-
*Dylan Thacker-Smith*
|
37
52
|
|
38
|
-
|
53
|
+
## Rails 6.1.5.1 (April 26, 2022) ##
|
39
54
|
|
40
|
-
|
55
|
+
* No changes.
|
41
56
|
|
42
|
-
* The connection pool reaper thread is respawned in forked processes. This
|
43
|
-
fixes that idle connections in forked processes wouldn't be reaped.
|
44
57
|
|
45
|
-
|
58
|
+
## Rails 6.1.5 (March 09, 2022) ##
|
46
59
|
|
47
|
-
*
|
48
|
-
when `ActiveRecord::Relation#reset` or `ActiveRecord::Relation#reload`
|
49
|
-
is called.
|
60
|
+
* Fix `ActiveRecord::ConnectionAdapters::SchemaCache#deep_deduplicate` for Ruby 2.6.
|
50
61
|
|
51
|
-
|
62
|
+
Ruby 2.6 and 2.7 have slightly different implementations of the `String#-@` method.
|
63
|
+
In Ruby 2.6, the receiver of the `String#-@` method is modified under certain circumstances.
|
64
|
+
This was later identified as a bug (https://bugs.ruby-lang.org/issues/15926) and only
|
65
|
+
fixed in Ruby 2.7.
|
52
66
|
|
53
|
-
|
67
|
+
Before the changes in this commit, the
|
68
|
+
`ActiveRecord::ConnectionAdapters::SchemaCache#deep_deduplicate` method, which internally
|
69
|
+
calls the `String#-@` method, could also modify an input string argument in Ruby 2.6 --
|
70
|
+
changing a tainted, unfrozen string into a tainted, frozen string.
|
54
71
|
|
55
|
-
|
72
|
+
Fixes #43056
|
56
73
|
|
57
|
-
*
|
74
|
+
*Eric O'Hanlon*
|
58
75
|
|
59
|
-
|
76
|
+
* Fix migration compatibility to create SQLite references/belongs_to column as integer when
|
77
|
+
migration version is 6.0.
|
60
78
|
|
61
|
-
|
79
|
+
`reference`/`belongs_to` in migrations with version 6.0 were creating columns as
|
80
|
+
bigint instead of integer for the SQLite Adapter.
|
62
81
|
|
63
|
-
|
82
|
+
*Marcelo Lauxen*
|
64
83
|
|
65
|
-
|
84
|
+
* Fix dbconsole for 3-tier config.
|
66
85
|
|
67
86
|
*Eileen M. Uchitelle*
|
68
87
|
|
69
|
-
*
|
88
|
+
* Better handle SQL queries with invalid encoding.
|
70
89
|
|
71
|
-
|
90
|
+
```ruby
|
91
|
+
Post.create(name: "broken \xC8 UTF-8")
|
92
|
+
```
|
72
93
|
|
94
|
+
Would cause all adapters to fail in a non controlled way in the code
|
95
|
+
responsible to detect write queries.
|
73
96
|
|
74
|
-
|
97
|
+
The query is now properly passed to the database connection, which might or might
|
98
|
+
not be able to handle it, but will either succeed or failed in a more correct way.
|
75
99
|
|
76
|
-
*
|
100
|
+
*Jean Boussier*
|
77
101
|
|
78
|
-
|
102
|
+
* Ignore persisted in-memory records when merging target lists.
|
79
103
|
|
80
|
-
*
|
104
|
+
*Kevin Sjöberg*
|
81
105
|
|
82
|
-
*
|
106
|
+
* Fix regression bug that caused ignoring additional conditions for preloading
|
107
|
+
`has_many` through relations.
|
83
108
|
|
84
|
-
|
109
|
+
Fixes #43132
|
85
110
|
|
86
|
-
*
|
111
|
+
*Alexander Pauly*
|
87
112
|
|
88
|
-
|
89
|
-
|
90
|
-
end
|
113
|
+
* Fix `ActiveRecord::InternalMetadata` to not be broken by
|
114
|
+
`config.active_record.record_timestamps = false`
|
91
115
|
|
92
|
-
|
116
|
+
Since the model always create the timestamp columns, it has to set them, otherwise it breaks
|
117
|
+
various DB management tasks.
|
93
118
|
|
94
|
-
|
119
|
+
Fixes #42983
|
95
120
|
|
96
|
-
*
|
121
|
+
*Jean Boussier*
|
97
122
|
|
123
|
+
* Fix duplicate active record objects on `inverse_of`.
|
98
124
|
|
99
|
-
|
125
|
+
*Justin Carvalho*
|
100
126
|
|
101
|
-
*
|
127
|
+
* Fix duplicate objects stored in has many association after save.
|
102
128
|
|
103
|
-
|
129
|
+
Fixes #42549.
|
104
130
|
|
105
|
-
*
|
131
|
+
*Alex Ghiculescu*
|
106
132
|
|
107
|
-
|
133
|
+
* Fix performance regression in `CollectionAssocation#build`.
|
108
134
|
|
109
|
-
*
|
135
|
+
*Alex Ghiculescu*
|
110
136
|
|
111
|
-
*
|
137
|
+
* Fix retrieving default value for text column for MariaDB.
|
112
138
|
|
113
|
-
|
139
|
+
*fatkodima*
|
114
140
|
|
115
|
-
*Jeff Doering*
|
116
141
|
|
117
|
-
|
142
|
+
## Rails 6.1.4.7 (March 08, 2022) ##
|
118
143
|
|
119
|
-
|
144
|
+
* No changes.
|
120
145
|
|
121
|
-
* Fix invalid schema when primary key column has a comment.
|
122
146
|
|
123
|
-
|
147
|
+
## Rails 6.1.4.6 (February 11, 2022) ##
|
124
148
|
|
125
|
-
|
149
|
+
* No changes.
|
126
150
|
|
127
|
-
* Fix table comment also being applied to the primary key column.
|
128
151
|
|
129
|
-
|
152
|
+
## Rails 6.1.4.5 (February 11, 2022) ##
|
130
153
|
|
131
|
-
*
|
154
|
+
* No changes.
|
132
155
|
|
133
|
-
Fixes #36103.
|
134
156
|
|
135
|
-
|
157
|
+
## Rails 6.1.4.4 (December 15, 2021) ##
|
136
158
|
|
159
|
+
* No changes.
|
137
160
|
|
138
|
-
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
139
161
|
|
140
|
-
|
162
|
+
## Rails 6.1.4.3 (December 14, 2021) ##
|
141
163
|
|
142
|
-
|
164
|
+
* No changes.
|
143
165
|
|
144
|
-
* Deprecate `where.not` working as NOR and will be changed to NAND in Rails 6.1.
|
145
166
|
|
146
|
-
|
147
|
-
all = [treasures(:diamond), treasures(:sapphire), cars(:honda), treasures(:sapphire)]
|
148
|
-
assert_equal all, PriceEstimate.all.map(&:estimate_of)
|
149
|
-
```
|
167
|
+
## Rails 6.1.4.2 (December 14, 2021) ##
|
150
168
|
|
151
|
-
|
169
|
+
* No changes.
|
152
170
|
|
153
|
-
```ruby
|
154
|
-
sapphire = treasures(:sapphire)
|
155
|
-
|
156
|
-
nor = all.reject { |e|
|
157
|
-
e.estimate_of_type == sapphire.class.polymorphic_name
|
158
|
-
}.reject { |e|
|
159
|
-
e.estimate_of_id == sapphire.id
|
160
|
-
}
|
161
|
-
assert_equal [cars(:honda)], nor
|
162
|
-
|
163
|
-
without_sapphire = PriceEstimate.where.not(
|
164
|
-
estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
|
165
|
-
)
|
166
|
-
assert_equal nor, without_sapphire.map(&:estimate_of)
|
167
|
-
```
|
168
171
|
|
169
|
-
|
172
|
+
## Rails 6.1.4.1 (August 19, 2021) ##
|
170
173
|
|
171
|
-
|
172
|
-
sapphire = treasures(:sapphire)
|
174
|
+
* No changes.
|
173
175
|
|
174
|
-
nand = all - [sapphire]
|
175
|
-
assert_equal [treasures(:diamond), cars(:honda)], nand
|
176
176
|
|
177
|
-
|
178
|
-
estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
|
179
|
-
)
|
180
|
-
assert_equal nand, without_sapphire.map(&:estimate_of)
|
181
|
-
```
|
177
|
+
## Rails 6.1.4 (June 24, 2021) ##
|
182
178
|
|
183
|
-
|
179
|
+
* Do not try to rollback transactions that failed due to a `ActiveRecord::TransactionRollbackError`.
|
184
180
|
|
185
|
-
*
|
181
|
+
*Jamie McCarthy*
|
186
182
|
|
187
|
-
|
183
|
+
* Raise an error if `pool_config` is `nil` in `set_pool_config`.
|
188
184
|
|
189
|
-
*
|
185
|
+
*Eileen M. Uchitelle*
|
190
186
|
|
191
|
-
*
|
192
|
-
the versioned entries in `ActiveSupport::Cache`. This also means that
|
193
|
-
`ActiveRecord::Relation#cache_key` will now return a stable key that does not
|
194
|
-
include the max timestamp or count any more.
|
187
|
+
* Fix compatibility with `psych >= 4`.
|
195
188
|
|
196
|
-
|
197
|
-
cache
|
198
|
-
That's the setting for all new apps on Rails 6.0+
|
189
|
+
Starting in Psych 4.0.0 `YAML.load` behaves like `YAML.safe_load`. To preserve compatibility
|
190
|
+
Active Record's schema cache loader and `YAMLColumn` now uses `YAML.unsafe_load` if available.
|
199
191
|
|
200
|
-
*
|
192
|
+
*Jean Boussier*
|
201
193
|
|
202
|
-
*
|
194
|
+
* Support using replicas when using `rails dbconsole`.
|
203
195
|
|
204
|
-
|
196
|
+
*Christopher Thornton*
|
205
197
|
|
206
|
-
|
198
|
+
* Restore connection pools after transactional tests.
|
207
199
|
|
208
|
-
*
|
209
|
-
`to` and `from` options are specified.
|
200
|
+
*Eugene Kenny*
|
210
201
|
|
211
|
-
|
202
|
+
* Change `upsert_all` to fails cleanly for MySQL when `:unique_by` is used.
|
212
203
|
|
213
|
-
*
|
204
|
+
*Bastian Bartmann*
|
214
205
|
|
215
|
-
|
206
|
+
* Fix user-defined `self.default_scope` to respect table alias.
|
216
207
|
|
217
208
|
*Ryuta Kamizono*
|
218
209
|
|
219
|
-
*
|
210
|
+
* Clear `@cache_keys` cache after `update_all`, `delete_all`, `destroy_all`.
|
220
211
|
|
221
|
-
|
222
|
-
associations, the callback for a `has_many` association was run while
|
223
|
-
another instance of the same callback on the same association hadn't
|
224
|
-
finished running. When control returned to the first instance of the
|
225
|
-
callback, the instance variable had changed, and subsequent associated
|
226
|
-
records weren't saved correctly. Specifically, the ID field for the
|
227
|
-
`belongs_to` corresponding to the `has_many` was `nil`.
|
212
|
+
*Ryuta Kamizono*
|
228
213
|
|
229
|
-
|
214
|
+
* Changed Arel predications `contains` and `overlaps` to use
|
215
|
+
`quoted_node` so that PostgreSQL arrays are quoted properly.
|
230
216
|
|
231
|
-
*
|
217
|
+
*Bradley Priest*
|
232
218
|
|
233
|
-
*
|
219
|
+
* Fix `merge` when the `where` clauses have string contents.
|
234
220
|
|
235
|
-
|
221
|
+
*Ryuta Kamizono*
|
236
222
|
|
237
|
-
|
238
|
-
add_column :items, :attr1, :binary, size: 10 # => ArgumentError
|
239
|
-
add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
|
240
|
-
add_column :items, :attr3, :integer, limit: 10 # => ActiveRecordError
|
241
|
-
add_column :items, :attr4, :datetime, precision: 10 # => ActiveRecordError
|
242
|
-
```
|
223
|
+
* Fix rollback of parent destruction with nested `dependent: :destroy`.
|
243
224
|
|
244
|
-
|
225
|
+
*Jacopo Beschi*
|
245
226
|
|
246
|
-
|
247
|
-
add_column :items, :attr1, :binary, size: 10 # => ArgumentError
|
248
|
-
add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
|
249
|
-
add_column :items, :attr3, :integer, limit: 10 # => ArgumentError
|
250
|
-
add_column :items, :attr4, :datetime, precision: 10 # => ArgumentError
|
251
|
-
```
|
227
|
+
* Fix binds logging for `"WHERE ... IN ..."` statements.
|
252
228
|
|
253
|
-
*
|
229
|
+
*Ricardo Díaz*
|
254
230
|
|
255
|
-
*
|
256
|
-
whether preloaded / eager loaded or not, with the exception of `unscoped`.
|
231
|
+
* Handle `false` in relation strict loading checks.
|
257
232
|
|
258
|
-
|
233
|
+
Previously when a model had strict loading set to true and then had a
|
234
|
+
relation set `strict_loading` to false the false wasn't considered when
|
235
|
+
deciding whether to raise/warn about strict loading.
|
259
236
|
|
260
|
-
```ruby
|
261
|
-
Post.where("1=0").scoping do
|
262
|
-
Comment.find(1).post # => nil
|
263
|
-
Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
|
264
|
-
Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
|
265
|
-
end
|
266
237
|
```
|
238
|
+
class Dog < ActiveRecord::Base
|
239
|
+
self.strict_loading_by_default = true
|
267
240
|
|
268
|
-
|
269
|
-
|
270
|
-
```ruby
|
271
|
-
Post.where("1=0").scoping do
|
272
|
-
Comment.find(1).post # => #<Post id: 1, ...>
|
273
|
-
Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
|
274
|
-
Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
|
241
|
+
has_many :treats, strict_loading: false
|
275
242
|
end
|
276
243
|
```
|
277
244
|
|
278
|
-
|
279
|
-
|
280
|
-
|
245
|
+
In the example, `dog.treats` would still raise even though
|
246
|
+
`strict_loading` was set to false. This is a bug affecting more than
|
247
|
+
Active Storage which is why I made this PR superseding #41461. We need
|
248
|
+
to fix this for all applications since the behavior is a little
|
249
|
+
surprising. I took the test from #41461 and the code suggestion from #41453
|
250
|
+
with some additions.
|
281
251
|
|
282
|
-
*
|
252
|
+
*Eileen M. Uchitelle*, *Radamés Roriz*
|
283
253
|
|
284
|
-
|
254
|
+
* Fix numericality validator without precision.
|
285
255
|
|
286
|
-
*
|
256
|
+
*Ryuta Kamizono*
|
287
257
|
|
288
|
-
*
|
258
|
+
* Fix aggregate attribute on Enum types.
|
289
259
|
|
290
|
-
*
|
260
|
+
*Ryuta Kamizono*
|
291
261
|
|
292
|
-
*
|
293
|
-
`before_add` and `after_add` callbacks for `has_many :through` associations.
|
262
|
+
* Fix `CREATE INDEX` statement generation for PostgreSQL.
|
294
263
|
|
295
|
-
|
264
|
+
*eltongo*
|
296
265
|
|
297
|
-
|
266
|
+
* Fix where clause on enum attribute when providing array of strings.
|
298
267
|
|
299
|
-
*
|
268
|
+
*Ryuta Kamizono*
|
300
269
|
|
301
|
-
|
302
|
-
account.memberships.extract_associated(:user)
|
303
|
-
# => Returns collection of User records
|
304
|
-
```
|
270
|
+
* Fix `unprepared_statement` to work it when nesting.
|
305
271
|
|
306
|
-
*
|
272
|
+
*Ryuta Kamizono*
|
307
273
|
|
308
|
-
* Add `ActiveRecord::Relation#annotate` for adding SQL comments to its queries.
|
309
274
|
|
310
|
-
|
275
|
+
## Rails 6.1.3.2 (May 05, 2021) ##
|
311
276
|
|
312
|
-
|
313
|
-
Post.where(id: 123).annotate("this is a comment").to_sql
|
314
|
-
# SELECT "posts".* FROM "posts" WHERE "posts"."id" = 123 /* this is a comment */
|
315
|
-
```
|
277
|
+
* No changes.
|
316
278
|
|
317
|
-
This can be useful in instrumentation or other analysis of issued queries.
|
318
279
|
|
319
|
-
|
280
|
+
## Rails 6.1.3.1 (March 26, 2021) ##
|
320
281
|
|
321
|
-
*
|
282
|
+
* No changes.
|
322
283
|
|
323
|
-
In most databases, a way to control the optimizer is by using optimizer hints,
|
324
|
-
which can be specified within individual statements.
|
325
284
|
|
326
|
-
|
285
|
+
## Rails 6.1.3 (February 17, 2021) ##
|
327
286
|
|
328
|
-
|
329
|
-
|
287
|
+
* Fix the MySQL adapter to always set the right collation and charset
|
288
|
+
to the connection session.
|
330
289
|
|
331
|
-
|
290
|
+
*Rafael Mendonça França*
|
332
291
|
|
333
|
-
|
334
|
-
|
292
|
+
* Fix MySQL adapter handling of time objects when prepared statements
|
293
|
+
are enabled.
|
335
294
|
|
336
|
-
|
295
|
+
*Rafael Mendonça França*
|
337
296
|
|
338
|
-
|
339
|
-
|
340
|
-
* https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgsql/influencing-the-optimizer.html
|
341
|
-
* https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017
|
342
|
-
* https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.perf.doc/doc/c0070117.html
|
297
|
+
* Fix scoping in enum fields using conditions that would generate
|
298
|
+
an `IN` clause.
|
343
299
|
|
344
300
|
*Ryuta Kamizono*
|
345
301
|
|
346
|
-
*
|
302
|
+
* Skip optimised #exist? query when #include? is called on a relation
|
303
|
+
with a having clause
|
347
304
|
|
348
|
-
|
305
|
+
Relations that have aliased select values AND a having clause that
|
306
|
+
references an aliased select value would generate an error when
|
307
|
+
#include? was called, due to an optimisation that would generate
|
308
|
+
call #exists? on the relation instead, which effectively alters
|
309
|
+
the select values of the query (and thus removes the aliased select
|
310
|
+
values), but leaves the having clause intact. Because the having
|
311
|
+
clause is then referencing an aliased column that is no longer
|
312
|
+
present in the simplified query, an ActiveRecord::InvalidStatement
|
313
|
+
error was raised.
|
349
314
|
|
350
|
-
|
351
|
-
class Post < ActiveRecord::Base
|
352
|
-
attribute :user_defined_text, :text
|
353
|
-
end
|
315
|
+
An sample query affected by this problem:
|
354
316
|
|
355
|
-
|
317
|
+
```ruby
|
318
|
+
Author.select('COUNT(*) as total_posts', 'authors.*')
|
319
|
+
.joins(:posts)
|
320
|
+
.group(:id)
|
321
|
+
.having('total_posts > 2')
|
322
|
+
.include?(Author.first)
|
356
323
|
```
|
357
324
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
*Patrick Rebsch*
|
325
|
+
This change adds an addition check to the condition that skips the
|
326
|
+
simplified #exists? query, which simply checks for the presence of
|
327
|
+
a having clause.
|
363
328
|
|
364
|
-
|
365
|
-
allowing bulk inserts akin to the bulk updates provided by `update_all` and
|
366
|
-
bulk deletes by `delete_all`.
|
329
|
+
Fixes #41417
|
367
330
|
|
368
|
-
|
369
|
-
for PostgreSQL (9.5+) and SQLite (3.24+) and `ON DUPLICATE KEY UPDATE` syntax
|
370
|
-
for MySQL.
|
331
|
+
*Michael Smart*
|
371
332
|
|
372
|
-
|
333
|
+
* Increment postgres prepared statement counter before making a prepared statement, so if the statement is aborted
|
334
|
+
without Rails knowledge (e.g., if app gets kill -9d during long-running query or due to Rack::Timeout), app won't end
|
335
|
+
up in perpetual crash state for being inconsistent with Postgres.
|
373
336
|
|
374
|
-
*
|
375
|
-
for current environment and loads the seeds.
|
337
|
+
*wbharding*, *Martin Tepper*
|
376
338
|
|
377
|
-
*bogdanvlviv*, *DHH*
|
378
339
|
|
379
|
-
|
340
|
+
## Rails 6.1.2.1 (February 10, 2021) ##
|
380
341
|
|
381
|
-
|
342
|
+
* Fix possible DoS vector in PostgreSQL money type
|
382
343
|
|
383
|
-
|
344
|
+
Carefully crafted input can cause a DoS via the regular expressions used
|
345
|
+
for validating the money format in the PostgreSQL adapter. This patch
|
346
|
+
fixes the regexp.
|
384
347
|
|
385
|
-
|
386
|
-
To continue case sensitive comparison on the case insensitive column,
|
387
|
-
pass `case_sensitive: true` option explicitly to the uniqueness validator.
|
348
|
+
Thanks to @dee-see from Hackerone for this patch!
|
388
349
|
|
389
|
-
|
350
|
+
[CVE-2021-22880]
|
390
351
|
|
391
|
-
*
|
352
|
+
*Aaron Patterson*
|
392
353
|
|
393
|
-
Fixes #27340.
|
394
354
|
|
395
|
-
|
355
|
+
## Rails 6.1.2 (February 09, 2021) ##
|
396
356
|
|
397
|
-
*
|
357
|
+
* Fix timestamp type for sqlite3.
|
398
358
|
|
399
|
-
|
359
|
+
*Eileen M. Uchitelle*
|
400
360
|
|
401
|
-
|
402
|
-
enum status: %i[ drafted active trashed ]
|
403
|
-
end
|
361
|
+
* Make destroy async transactional.
|
404
362
|
|
405
|
-
|
406
|
-
|
407
|
-
|
363
|
+
An active record rollback could occur while enqueuing a job. In this
|
364
|
+
case the job would enqueue even though the database deletion
|
365
|
+
rolledback putting things in a funky state.
|
408
366
|
|
409
|
-
|
367
|
+
Now the jobs are only enqueued until after the db transaction has been committed.
|
410
368
|
|
411
|
-
*
|
369
|
+
*Cory Gwin*
|
412
370
|
|
413
|
-
|
371
|
+
* Fix malformed packet error in MySQL statement for connection configuration.
|
414
372
|
|
415
|
-
*
|
373
|
+
*robinroestenburg*
|
416
374
|
|
375
|
+
* Connection specification now passes the "url" key as a configuration for the
|
376
|
+
adapter if the "url" protocol is "jdbc", "http", or "https". Previously only
|
377
|
+
urls with the "jdbc" prefix were passed to the Active Record Adapter, others
|
378
|
+
are assumed to be adapter specification urls.
|
417
379
|
|
418
|
-
|
380
|
+
Fixes #41137.
|
419
381
|
|
420
|
-
*
|
382
|
+
*Jonathan Bracy*
|
421
383
|
|
384
|
+
* Fix granular connection swapping when there are multiple abstract classes.
|
422
385
|
|
423
|
-
|
386
|
+
*Eileen M. Uchitelle*
|
424
387
|
|
425
|
-
* Fix
|
388
|
+
* Fix `find_by` with custom primary key for belongs_to association.
|
426
389
|
|
427
390
|
*Ryuta Kamizono*
|
428
391
|
|
429
|
-
*
|
392
|
+
* Add support for `rails console --sandbox` for multiple database applications.
|
430
393
|
|
431
|
-
*
|
394
|
+
*alpaca-tc*
|
432
395
|
|
433
|
-
*
|
396
|
+
* Fix `where` on polymorphic association with empty array.
|
434
397
|
|
435
398
|
*Ryuta Kamizono*
|
436
399
|
|
437
|
-
*
|
400
|
+
* Fix preventing writes for `ApplicationRecord`.
|
438
401
|
|
439
|
-
|
440
|
-
`destroy_all` on the matched records.
|
441
|
-
|
442
|
-
Example:
|
402
|
+
*Eileen M. Uchitelle*
|
443
403
|
|
444
|
-
Person.destroy_by(name: 'David')
|
445
|
-
Person.destroy_by(name: 'David', rating: 4)
|
446
404
|
|
447
|
-
|
448
|
-
david.posts.destroy_by(id: [1, 2, 3])
|
405
|
+
## Rails 6.1.1 (January 07, 2021) ##
|
449
406
|
|
450
|
-
|
451
|
-
`delete_all` on the matched records.
|
407
|
+
* Fix fixtures loading when strict loading is enabled for the association.
|
452
408
|
|
453
|
-
|
409
|
+
*Alex Ghiculescu*
|
454
410
|
|
455
|
-
|
456
|
-
Person.delete_by(name: 'David', rating: 4)
|
411
|
+
* Fix `where` with custom primary key for belongs_to association.
|
457
412
|
|
458
|
-
|
459
|
-
david.posts.delete_by(id: [1, 2, 3])
|
413
|
+
*Ryuta Kamizono*
|
460
414
|
|
461
|
-
|
415
|
+
* Fix `where` with aliased associations.
|
462
416
|
|
463
|
-
*
|
417
|
+
*Ryuta Kamizono*
|
464
418
|
|
465
|
-
|
419
|
+
* Fix `composed_of` with symbol mapping.
|
466
420
|
|
467
421
|
*Ryuta Kamizono*
|
468
422
|
|
469
|
-
*
|
423
|
+
* Don't skip money's type cast for pluck and calculations.
|
470
424
|
|
471
425
|
*Ryuta Kamizono*
|
472
426
|
|
473
|
-
*
|
474
|
-
regarded as leaked. Use `klass.unscoped` to avoid the leaking scope.
|
427
|
+
* Fix `where` on polymorphic association with non Active Record object.
|
475
428
|
|
476
429
|
*Ryuta Kamizono*
|
477
430
|
|
478
|
-
*
|
431
|
+
* Make sure `db:prepare` works even the schema file doesn't exist.
|
479
432
|
|
480
|
-
|
481
|
-
application to automatically switch between the writing and reading
|
482
|
-
database connections.
|
433
|
+
*Rafael Mendonça França*
|
483
434
|
|
484
|
-
|
485
|
-
a write in the last 2 seconds, otherwise they will read from the primary.
|
486
|
-
Non-get requests will always write to the primary. The middleware accepts
|
487
|
-
an argument for a Resolver class and an Operations class where you are able
|
488
|
-
to change how the auto-switcher works to be most beneficial for your
|
489
|
-
application.
|
435
|
+
* Fix complicated `has_many :through` with nested where condition.
|
490
436
|
|
491
|
-
|
492
|
-
configuration options:
|
437
|
+
*Ryuta Kamizono*
|
493
438
|
|
494
|
-
|
495
|
-
config.active_record.database_selector = { delay: 2.seconds }
|
496
|
-
config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
|
497
|
-
config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
|
498
|
-
```
|
439
|
+
* Handle STI models for `has_many dependent: :destroy_async`.
|
499
440
|
|
500
|
-
|
501
|
-
configuration options:
|
441
|
+
*Muhammad Usman*
|
502
442
|
|
503
|
-
|
504
|
-
config.active_record.database_selector = { delay: 10.seconds }
|
505
|
-
config.active_record.database_resolver = MyResolver
|
506
|
-
config.active_record.database_resolver_context = MyResolver::MyCookies
|
507
|
-
```
|
443
|
+
* Restore possibility of passing `false` to :polymorphic option of `belongs_to`.
|
508
444
|
|
509
|
-
|
445
|
+
Previously, passing `false` would trigger the option validation logic
|
446
|
+
to throw an error saying :polymorphic would not be a valid option.
|
510
447
|
|
511
|
-
*
|
448
|
+
*glaszig*
|
512
449
|
|
513
|
-
|
450
|
+
* Allow adding nonnamed expression indexes to be revertible.
|
514
451
|
|
515
|
-
|
452
|
+
Fixes #40732.
|
516
453
|
|
517
|
-
|
454
|
+
Previously, the following code would raise an error, when executed while rolling back,
|
455
|
+
and the index name should be specified explicitly. Now, the index name is inferred
|
456
|
+
automatically.
|
518
457
|
|
458
|
+
```ruby
|
459
|
+
add_index(:items, "to_tsvector('english', description)")
|
460
|
+
```
|
519
461
|
|
520
|
-
|
462
|
+
*fatkodima*
|
521
463
|
|
522
|
-
* Remove deprecated `#set_state` from the transaction object.
|
523
464
|
|
524
|
-
|
465
|
+
## Rails 6.1.0 (December 09, 2020) ##
|
525
466
|
|
526
|
-
*
|
467
|
+
* Only warn about negative enums if a positive form that would cause conflicts exists.
|
527
468
|
|
528
|
-
|
469
|
+
Fixes #39065.
|
470
|
+
|
471
|
+
*Alex Ghiculescu*
|
529
472
|
|
530
|
-
*
|
473
|
+
* Change `attribute_for_inspect` to take `filter_attributes` in consideration.
|
531
474
|
|
532
475
|
*Rafael Mendonça França*
|
533
476
|
|
534
|
-
*
|
477
|
+
* Fix odd behavior of inverse_of with multiple belongs_to to same class.
|
535
478
|
|
536
|
-
|
479
|
+
Fixes #35204.
|
537
480
|
|
538
|
-
*
|
481
|
+
*Tomoyuki Kai*
|
539
482
|
|
540
|
-
|
483
|
+
* Build predicate conditions with objects that delegate `#id` and primary key:
|
541
484
|
|
542
|
-
|
485
|
+
```ruby
|
486
|
+
class AdminAuthor
|
487
|
+
delegate_missing_to :@author
|
543
488
|
|
544
|
-
|
489
|
+
def initialize(author)
|
490
|
+
@author = author
|
491
|
+
end
|
492
|
+
end
|
545
493
|
|
546
|
-
|
494
|
+
Post.where(author: AdminAuthor.new(author))
|
495
|
+
```
|
547
496
|
|
548
|
-
*
|
497
|
+
*Sean Doyle*
|
549
498
|
|
550
|
-
*
|
499
|
+
* Add `connected_to_many` API.
|
551
500
|
|
552
|
-
|
501
|
+
This API allows applications to connect to multiple databases at once without switching all of them or implementing a deeply nested stack.
|
553
502
|
|
554
|
-
|
503
|
+
Before:
|
555
504
|
|
556
|
-
|
505
|
+
AnimalsRecord.connected_to(role: :reading) do
|
506
|
+
MealsRecord.connected_to(role: :reading) do
|
507
|
+
Dog.first # read from animals replica
|
508
|
+
Dinner.first # read from meals replica
|
509
|
+
Person.first # read from primary writer
|
510
|
+
end
|
511
|
+
end
|
557
512
|
|
558
|
-
|
513
|
+
After:
|
559
514
|
|
560
|
-
|
515
|
+
ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do
|
516
|
+
Dog.first # read from animals replica
|
517
|
+
Dinner.first # read from meals replica
|
518
|
+
Person.first # read from primary writer
|
519
|
+
end
|
561
520
|
|
562
|
-
*
|
521
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
563
522
|
|
564
|
-
|
523
|
+
* Add option to raise or log for `ActiveRecord::StrictLoadingViolationError`.
|
565
524
|
|
566
|
-
|
525
|
+
Some applications may not want to raise an error in production if using `strict_loading`. This would allow an application to set strict loading to log for the production environment while still raising in development and test environments.
|
567
526
|
|
568
|
-
|
527
|
+
Set `config.active_record.action_on_strict_loading_violation` to `:log` errors instead of raising.
|
569
528
|
|
570
|
-
*
|
529
|
+
*Eileen M. Uchitelle*
|
571
530
|
|
572
|
-
|
531
|
+
* Allow the inverse of a `has_one` association that was previously autosaved to be loaded.
|
573
532
|
|
574
|
-
|
533
|
+
Fixes #34255.
|
575
534
|
|
576
|
-
|
535
|
+
*Steven Weber*
|
577
536
|
|
578
|
-
|
537
|
+
* Optimise the length of index names for polymorphic references by using the reference name rather than the type and id column names.
|
579
538
|
|
580
|
-
|
539
|
+
Because the default behaviour when adding an index with multiple columns is to use all column names in the index name, this could frequently lead to overly long index names for polymorphic references which would fail the migration if it exceeded the database limit.
|
581
540
|
|
582
|
-
|
541
|
+
This change reduces the chance of that happening by using the reference name, e.g. `index_my_table_on_my_reference`.
|
583
542
|
|
584
|
-
|
543
|
+
Fixes #38655.
|
585
544
|
|
586
|
-
*
|
545
|
+
*Luke Redpath*
|
587
546
|
|
588
|
-
*
|
547
|
+
* MySQL: Uniqueness validator now respects default database collation,
|
548
|
+
no longer enforce case sensitive comparison by default.
|
589
549
|
|
590
550
|
*Ryuta Kamizono*
|
591
551
|
|
592
|
-
*
|
552
|
+
* Remove deprecated methods from `ActiveRecord::ConnectionAdapters::DatabaseLimits`.
|
593
553
|
|
594
|
-
|
595
|
-
|
596
|
-
|
554
|
+
`column_name_length`
|
555
|
+
`table_name_length`
|
556
|
+
`columns_per_table`
|
557
|
+
`indexes_per_table`
|
558
|
+
`columns_per_multicolumn_index`
|
559
|
+
`sql_query_length`
|
560
|
+
`joins_per_query`
|
597
561
|
|
598
|
-
*
|
562
|
+
*Rafael Mendonça França*
|
599
563
|
|
600
|
-
*
|
564
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_multi_insert?`.
|
601
565
|
|
602
|
-
*
|
566
|
+
*Rafael Mendonça França*
|
603
567
|
|
604
|
-
*
|
568
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_foreign_keys_in_create?`.
|
605
569
|
|
606
|
-
*
|
570
|
+
*Rafael Mendonça França*
|
607
571
|
|
608
|
-
*
|
572
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#supports_ranges?`.
|
609
573
|
|
610
|
-
*
|
574
|
+
*Rafael Mendonça França*
|
611
575
|
|
612
|
-
*
|
576
|
+
* Remove deprecated `ActiveRecord::Base#update_attributes` and `ActiveRecord::Base#update_attributes!`.
|
613
577
|
|
614
|
-
*
|
578
|
+
*Rafael Mendonça França*
|
615
579
|
|
616
|
-
*
|
580
|
+
* Remove deprecated `migrations_path` argument in `ActiveRecord::ConnectionAdapter::SchemaStatements#assume_migrated_upto_version`.
|
617
581
|
|
618
|
-
|
619
|
-
you're building out multiple databases and want to make sure you're not sending
|
620
|
-
writes when you want a read.
|
582
|
+
*Rafael Mendonça França*
|
621
583
|
|
622
|
-
|
623
|
-
query the database will raise an exception regardless of whether the database
|
624
|
-
user is able to write.
|
584
|
+
* Remove deprecated `config.active_record.sqlite3.represent_boolean_as_integer`.
|
625
585
|
|
626
|
-
|
627
|
-
read-only queries without opening a second connection. One purpose of this is to
|
628
|
-
catch accidental writes, not all writes.
|
586
|
+
*Rafael Mendonça França*
|
629
587
|
|
630
|
-
|
588
|
+
* `relation.create` does no longer leak scope to class level querying methods
|
589
|
+
in initialization block and callbacks.
|
631
590
|
|
632
|
-
|
591
|
+
Before:
|
633
592
|
|
634
|
-
|
593
|
+
User.where(name: "John").create do |john|
|
594
|
+
User.find_by(name: "David") # => nil
|
595
|
+
end
|
635
596
|
|
636
|
-
|
597
|
+
After:
|
637
598
|
|
638
|
-
|
599
|
+
User.where(name: "John").create do |john|
|
600
|
+
User.find_by(name: "David") # => #<User name: "David", ...>
|
601
|
+
end
|
639
602
|
|
640
|
-
*
|
603
|
+
*Ryuta Kamizono*
|
641
604
|
|
642
|
-
*
|
605
|
+
* Named scope chain does no longer leak scope to class level querying methods.
|
643
606
|
|
644
|
-
|
645
|
-
|
607
|
+
class User < ActiveRecord::Base
|
608
|
+
scope :david, -> { User.where(name: "David") }
|
609
|
+
end
|
646
610
|
|
647
|
-
|
648
|
-
class DeveloperName < ActiveRecord::Type::String
|
649
|
-
def deserialize(value)
|
650
|
-
"Developer: #{value}"
|
651
|
-
end
|
652
|
-
end
|
611
|
+
Before:
|
653
612
|
|
654
|
-
|
655
|
-
|
613
|
+
User.where(name: "John").david
|
614
|
+
# SELECT * FROM users WHERE name = 'John' AND name = 'David'
|
656
615
|
|
657
|
-
|
616
|
+
After:
|
658
617
|
|
659
|
-
|
660
|
-
|
618
|
+
User.where(name: "John").david
|
619
|
+
# SELECT * FROM users WHERE name = 'David'
|
661
620
|
|
662
|
-
|
663
|
-
developer.update_column :name, "name"
|
621
|
+
*Ryuta Kamizono*
|
664
622
|
|
665
|
-
|
666
|
-
puts loaded_developer.name # should be "Developer: name" but it's just "name"
|
667
|
-
```
|
623
|
+
* Remove deprecated methods from `ActiveRecord::DatabaseConfigurations`.
|
668
624
|
|
669
|
-
|
625
|
+
`fetch`
|
626
|
+
`each`
|
627
|
+
`first`
|
628
|
+
`values`
|
629
|
+
`[]=`
|
670
630
|
|
671
|
-
*
|
631
|
+
*Rafael Mendonça França*
|
672
632
|
|
673
|
-
|
674
|
-
explicit order clause, ActiveRecord sorts records by primary key. This can
|
675
|
-
result in unpredictable and surprising behaviour when the primary key is
|
676
|
-
not an auto-incrementing integer, for example when it's a UUID. This change
|
677
|
-
makes it possible to override the column used for implicit ordering such
|
678
|
-
that `first` and `last` will return more predictable results.
|
633
|
+
* `where.not` now generates NAND predicates instead of NOR.
|
679
634
|
|
680
|
-
|
635
|
+
Before:
|
681
636
|
|
682
|
-
|
683
|
-
|
684
|
-
end
|
637
|
+
User.where.not(name: "Jon", role: "admin")
|
638
|
+
# SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
|
685
639
|
|
686
|
-
|
640
|
+
After:
|
687
641
|
|
688
|
-
|
642
|
+
User.where.not(name: "Jon", role: "admin")
|
643
|
+
# SELECT * FROM users WHERE NOT (name == 'Jon' AND role == 'admin')
|
689
644
|
|
690
|
-
*
|
645
|
+
*Rafael Mendonça França*
|
691
646
|
|
692
|
-
*
|
647
|
+
* Remove deprecated `ActiveRecord::Result#to_hash` method.
|
693
648
|
|
694
|
-
*
|
649
|
+
*Rafael Mendonça França*
|
695
650
|
|
696
|
-
*
|
651
|
+
* Deprecate `ActiveRecord::Base.allow_unsafe_raw_sql`.
|
697
652
|
|
698
|
-
|
653
|
+
*Rafael Mendonça França*
|
699
654
|
|
700
|
-
|
655
|
+
* Remove deprecated support for using unsafe raw SQL in `ActiveRecord::Relation` methods.
|
701
656
|
|
702
|
-
|
657
|
+
*Rafael Mendonça França*
|
703
658
|
|
704
|
-
|
659
|
+
* Allow users to silence the "Rails couldn't infer whether you are using multiple databases..."
|
660
|
+
message using `config.active_record.suppress_multiple_database_warning`.
|
705
661
|
|
706
|
-
|
707
|
-
class MySubclassedError < ActiveRecord::StatementInvalid
|
708
|
-
def initialize(message, sql:, binds:)
|
709
|
-
super(message, sql: sql, binds: binds)
|
710
|
-
end
|
711
|
-
end
|
712
|
-
```
|
662
|
+
*Omri Gabay*
|
713
663
|
|
714
|
-
|
664
|
+
* Connections can be granularly switched for abstract classes when `connected_to` is called.
|
715
665
|
|
716
|
-
|
666
|
+
This change allows `connected_to` to switch a `role` and/or `shard` for a single abstract class instead of all classes globally. Applications that want to use the new feature need to set `config.active_record.legacy_connection_handling` to `false` in their application configuration.
|
717
667
|
|
718
|
-
Example:
|
668
|
+
Example usage:
|
719
669
|
|
720
|
-
|
721
|
-
t.string :title
|
722
|
-
end
|
670
|
+
Given an application we have a `User` model that inherits from `ApplicationRecord` and a `Dog` model that inherits from `AnimalsRecord`. `AnimalsRecord` and `ApplicationRecord` have writing and reading connections as well as shard `default`, `one`, and `two`.
|
723
671
|
|
724
|
-
|
672
|
+
```ruby
|
673
|
+
ActiveRecord::Base.connected_to(role: :reading) do
|
674
|
+
User.first # reads from default replica
|
675
|
+
Dog.first # reads from default replica
|
725
676
|
|
726
|
-
|
727
|
-
|
728
|
-
|
677
|
+
AnimalsRecord.connected_to(role: :writing, shard: :one) do
|
678
|
+
User.first # reads from default replica
|
679
|
+
Dog.first # reads from shard one primary
|
680
|
+
end
|
729
681
|
|
730
|
-
|
731
|
-
|
682
|
+
User.first # reads from default replica
|
683
|
+
Dog.first # reads from default replica
|
732
684
|
|
733
|
-
|
685
|
+
ApplicationRecord.connected_to(role: :writing, shard: :two) do
|
686
|
+
User.first # reads from shard two primary
|
687
|
+
Dog.first # reads from default replica
|
688
|
+
end
|
689
|
+
end
|
690
|
+
```
|
734
691
|
|
735
|
-
*
|
692
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
736
693
|
|
737
|
-
|
694
|
+
* Allow double-dash comment syntax when querying read-only databases
|
738
695
|
|
739
|
-
*
|
696
|
+
*James Adam*
|
740
697
|
|
741
|
-
|
698
|
+
* Add `values_at` method.
|
742
699
|
|
743
|
-
|
744
|
-
if the attribute does not exist.
|
700
|
+
Returns an array containing the values associated with the given methods.
|
745
701
|
|
746
|
-
|
702
|
+
```ruby
|
703
|
+
topic = Topic.first
|
704
|
+
topic.values_at(:title, :author_name)
|
705
|
+
# => ["Budget", "Jason"]
|
706
|
+
```
|
747
707
|
|
748
|
-
|
708
|
+
Similar to `Hash#values_at` but on an Active Record instance.
|
749
709
|
|
750
|
-
|
751
|
-
User.connected_to(database: { writing: "postgres://foo" }) do
|
752
|
-
User.create!(name: "Gannon")
|
753
|
-
end
|
710
|
+
*Guillaume Briday*
|
754
711
|
|
755
|
-
|
756
|
-
User.connected_to(database: { reading: config }) do
|
757
|
-
User.count
|
758
|
-
end
|
759
|
-
````
|
712
|
+
* Fix `read_attribute_before_type_cast` to consider attribute aliases.
|
760
713
|
|
761
|
-
*
|
714
|
+
*Marcelo Lauxen*
|
762
715
|
|
763
|
-
* Support
|
716
|
+
* Support passing record to uniqueness validator `:conditions` callable:
|
764
717
|
|
765
|
-
|
718
|
+
```ruby
|
719
|
+
class Article < ApplicationRecord
|
720
|
+
validates_uniqueness_of :title, conditions: ->(article) {
|
721
|
+
published_at = article.published_at
|
722
|
+
where(published_at: published_at.beginning_of_year..published_at.end_of_year)
|
723
|
+
}
|
724
|
+
end
|
725
|
+
```
|
766
726
|
|
767
|
-
|
727
|
+
*Eliot Sykes*
|
768
728
|
|
769
|
-
|
729
|
+
* `BatchEnumerator#update_all` and `BatchEnumerator#delete_all` now return the
|
730
|
+
total number of rows affected, just like their non-batched counterparts.
|
770
731
|
|
771
|
-
|
732
|
+
```ruby
|
733
|
+
Person.in_batches.update_all("first_name = 'Eugene'") # => 42
|
734
|
+
Person.in_batches.delete_all # => 42
|
735
|
+
```
|
772
736
|
|
773
|
-
|
774
|
-
expression values rather than column or column prefix values.
|
737
|
+
Fixes #40287.
|
775
738
|
|
776
|
-
|
739
|
+
*Eugene Kenny*
|
777
740
|
|
778
|
-
|
741
|
+
* Add support for PostgreSQL `interval` data type with conversion to
|
742
|
+
`ActiveSupport::Duration` when loading records from database and
|
743
|
+
serialization to ISO 8601 formatted duration string on save.
|
744
|
+
Add support to define a column in migrations and get it in a schema dump.
|
745
|
+
Optional column precision is supported.
|
779
746
|
|
780
|
-
|
747
|
+
To use this in 6.1, you need to place the next string to your model file:
|
781
748
|
|
782
|
-
|
749
|
+
attribute :duration, :interval
|
783
750
|
|
784
|
-
|
751
|
+
To keep old behavior until 7.0 is released:
|
785
752
|
|
786
|
-
|
753
|
+
attribute :duration, :string
|
787
754
|
|
788
|
-
|
755
|
+
Example:
|
789
756
|
|
790
|
-
|
791
|
-
|
792
|
-
|
757
|
+
create_table :events do |t|
|
758
|
+
t.string :name
|
759
|
+
t.interval :duration
|
760
|
+
end
|
793
761
|
|
794
|
-
|
795
|
-
|
762
|
+
class Event < ApplicationRecord
|
763
|
+
attribute :duration, :interval
|
764
|
+
end
|
796
765
|
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
766
|
+
Event.create!(name: 'Rock Fest', duration: 2.days)
|
767
|
+
Event.last.duration # => 2 days
|
768
|
+
Event.last.duration.iso8601 # => "P2D"
|
769
|
+
Event.new(duration: 'P1DT12H3S').duration # => 1 day, 12 hours, and 3 seconds
|
770
|
+
Event.new(duration: '1 day') # Unknown value will be ignored and NULL will be written to database
|
801
771
|
|
802
|
-
|
803
|
-
a database that the model didn't connect to. Connecting to the database in this block is
|
804
|
-
useful when you have another defined connection, for example `slow_replica` that you don't
|
805
|
-
want to connect to by default but need in the console, or a specific code block.
|
772
|
+
*Andrey Novikov*
|
806
773
|
|
807
|
-
|
808
|
-
ActiveRecord::Base.connected_to(role: :reading) do
|
809
|
-
Dog.first # finds dog from replica connected to AnimalsBase
|
810
|
-
Book.first # doesn't have a reading connection, will raise an error
|
811
|
-
end
|
812
|
-
```
|
774
|
+
* Allow associations supporting the `dependent:` key to take `dependent: :destroy_async`.
|
813
775
|
|
814
|
-
```
|
815
|
-
ActiveRecord::Base
|
816
|
-
|
776
|
+
```ruby
|
777
|
+
class Account < ActiveRecord::Base
|
778
|
+
belongs_to :supplier, dependent: :destroy_async
|
817
779
|
end
|
818
780
|
```
|
819
781
|
|
820
|
-
|
782
|
+
`:destroy_async` will enqueue a job to destroy associated records in the background.
|
821
783
|
|
822
|
-
*
|
784
|
+
*DHH*, *George Claghorn*, *Cory Gwin*, *Rafael Mendonça França*, *Adrianna Chang*
|
823
785
|
|
824
|
-
|
825
|
-
commit checks that only valid definition values are provided, those can
|
826
|
-
be a Hash, an array of Symbols or an array of Strings. Otherwise it
|
827
|
-
raises an `ArgumentError`.
|
786
|
+
* Add `SKIP_TEST_DATABASE` environment variable to disable modifying the test database when `rails db:create` and `rails db:drop` are called.
|
828
787
|
|
829
|
-
|
788
|
+
*Jason Schweier*
|
830
789
|
|
831
|
-
|
790
|
+
* `connects_to` can only be called on `ActiveRecord::Base` or abstract classes.
|
832
791
|
|
833
|
-
|
792
|
+
Ensure that `connects_to` can only be called from `ActiveRecord::Base` or abstract classes. This protects the application from opening duplicate or too many connections.
|
834
793
|
|
835
|
-
|
836
|
-
class Post < ActiveRecord::Base
|
837
|
-
has_one :category
|
838
|
-
belongs_to :author
|
839
|
-
has_many :comments
|
840
|
-
end
|
794
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
841
795
|
|
842
|
-
|
843
|
-
|
844
|
-
post.reload_author
|
845
|
-
post.comments.reload
|
846
|
-
```
|
796
|
+
* All connection adapters `execute` now raises `ActiveRecord::ConnectionNotEstablished` rather than
|
797
|
+
`ActiveRecord::StatementInvalid` when they encounter a connection error.
|
847
798
|
|
848
|
-
*
|
799
|
+
*Jean Boussier*
|
849
800
|
|
850
|
-
*
|
851
|
-
|
852
|
-
columns into the existing tables.
|
801
|
+
* `Mysql2Adapter#quote_string` now raises `ActiveRecord::ConnectionNotEstablished` rather than
|
802
|
+
`ActiveRecord::StatementInvalid` when it can't connect to the MySQL server.
|
853
803
|
|
854
|
-
|
804
|
+
*Jean Boussier*
|
855
805
|
|
856
|
-
|
857
|
-
t.string :country_code, index: true
|
858
|
-
end
|
806
|
+
* Add support for check constraints that are `NOT VALID` via `validate: false` (PostgreSQL-only).
|
859
807
|
|
860
|
-
*
|
808
|
+
*Alex Robbin*
|
861
809
|
|
862
|
-
*
|
810
|
+
* Ensure the default configuration is considered primary or first for an environment
|
863
811
|
|
864
|
-
|
865
|
-
Now: This change fixes that by reverting commands inside `transaction` block.
|
812
|
+
If a multiple database application provides a configuration named primary, that will be treated as default. In applications that do not have a primary entry, the default database configuration will be the first configuration for an environment.
|
866
813
|
|
867
|
-
*
|
814
|
+
*Eileen M. Uchitelle*
|
868
815
|
|
869
|
-
*
|
816
|
+
* Allow `where` references association names as joined table name aliases.
|
870
817
|
|
871
|
-
|
818
|
+
```ruby
|
819
|
+
class Comment < ActiveRecord::Base
|
820
|
+
enum label: [:default, :child]
|
821
|
+
has_many :children, class_name: "Comment", foreign_key: :parent_id
|
822
|
+
end
|
872
823
|
|
873
|
-
|
824
|
+
# ... FROM comments LEFT OUTER JOIN comments children ON ... WHERE children.label = 1
|
825
|
+
Comment.includes(:children).where("children.label": "child")
|
826
|
+
```
|
874
827
|
|
875
|
-
*
|
828
|
+
*Ryuta Kamizono*
|
876
829
|
|
877
|
-
*
|
830
|
+
* Support storing demodulized class name for polymorphic type.
|
878
831
|
|
879
|
-
|
832
|
+
Before Rails 6.1, storing demodulized class name is supported only for STI type
|
833
|
+
by `store_full_sti_class` class attribute.
|
834
|
+
|
835
|
+
Now `store_full_class_name` class attribute can handle both STI and polymorphic types.
|
880
836
|
|
881
837
|
*Ryuta Kamizono*
|
882
838
|
|
883
|
-
* Deprecate `
|
839
|
+
* Deprecate `rails db:structure:{load, dump}` tasks and extend
|
840
|
+
`rails db:schema:{load, dump}` tasks to work with either `:ruby` or `:sql` format,
|
841
|
+
depending on `config.active_record.schema_format` configuration value.
|
884
842
|
|
885
|
-
*
|
843
|
+
*fatkodima*
|
886
844
|
|
887
|
-
*
|
845
|
+
* Respect the `select` values for eager loading.
|
888
846
|
|
847
|
+
```ruby
|
848
|
+
post = Post.select("UPPER(title) AS title").first
|
849
|
+
post.title # => "WELCOME TO THE WEBLOG"
|
850
|
+
post.body # => ActiveModel::MissingAttributeError
|
851
|
+
|
852
|
+
# Rails 6.0 (ignore the `select` values)
|
853
|
+
post = Post.select("UPPER(title) AS title").eager_load(:comments).first
|
854
|
+
post.title # => "Welcome to the weblog"
|
855
|
+
post.body # => "Such a lovely day"
|
856
|
+
|
857
|
+
# Rails 6.1 (respect the `select` values)
|
858
|
+
post = Post.select("UPPER(title) AS title").eager_load(:comments).first
|
859
|
+
post.title # => "WELCOME TO THE WEBLOG"
|
860
|
+
post.body # => ActiveModel::MissingAttributeError
|
889
861
|
```
|
890
|
-
|
891
|
-
|
862
|
+
|
863
|
+
*Ryuta Kamizono*
|
864
|
+
|
865
|
+
* Allow attribute's default to be configured but keeping its own type.
|
866
|
+
|
867
|
+
```ruby
|
868
|
+
class Post < ActiveRecord::Base
|
869
|
+
attribute :written_at, default: -> { Time.now.utc }
|
892
870
|
end
|
893
871
|
|
894
|
-
|
872
|
+
# Rails 6.0
|
873
|
+
Post.type_for_attribute(:written_at) # => #<Type::Value ... precision: nil, ...>
|
874
|
+
|
875
|
+
# Rails 6.1
|
876
|
+
Post.type_for_attribute(:written_at) # => #<Type::DateTime ... precision: 6, ...>
|
895
877
|
```
|
896
878
|
|
897
|
-
*
|
879
|
+
*Ryuta Kamizono*
|
898
880
|
|
899
|
-
* Allow
|
881
|
+
* Allow default to be configured for Enum.
|
900
882
|
|
901
|
-
|
883
|
+
```ruby
|
884
|
+
class Book < ActiveRecord::Base
|
885
|
+
enum status: [:proposed, :written, :published], _default: :published
|
886
|
+
end
|
902
887
|
|
903
|
-
|
888
|
+
Book.new.status # => "published"
|
889
|
+
```
|
904
890
|
|
905
|
-
*
|
891
|
+
*Ryuta Kamizono*
|
906
892
|
|
907
|
-
|
893
|
+
* Deprecate YAML loading from legacy format older than Rails 5.0.
|
908
894
|
|
909
|
-
*
|
895
|
+
*Ryuta Kamizono*
|
910
896
|
|
911
|
-
|
912
|
-
|
897
|
+
* Added the setting `ActiveRecord::Base.immutable_strings_by_default`, which
|
898
|
+
allows you to specify that all string columns should be frozen unless
|
899
|
+
otherwise specified. This will reduce memory pressure for applications which
|
900
|
+
do not generally mutate string properties of Active Record objects.
|
913
901
|
|
914
|
-
*
|
902
|
+
*Sean Griffin*, *Ryuta Kamizono*
|
915
903
|
|
916
|
-
*
|
904
|
+
* Deprecate `map!` and `collect!` on `ActiveRecord::Result`.
|
917
905
|
|
918
|
-
*
|
906
|
+
*Ryuta Kamizono*
|
919
907
|
|
920
|
-
*
|
921
|
-
sensitive values of database columns when calling `#inspect`.
|
922
|
-
We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
|
923
|
-
specify sensitive attributes to specific model.
|
908
|
+
* Support `relation.and` for intersection as Set theory.
|
924
909
|
|
910
|
+
```ruby
|
911
|
+
david_and_mary = Author.where(id: [david, mary])
|
912
|
+
mary_and_bob = Author.where(id: [mary, bob])
|
913
|
+
|
914
|
+
david_and_mary.merge(mary_and_bob) # => [mary, bob]
|
915
|
+
|
916
|
+
david_and_mary.and(mary_and_bob) # => [mary]
|
917
|
+
david_and_mary.or(mary_and_bob) # => [david, mary, bob]
|
918
|
+
```
|
919
|
+
|
920
|
+
*Ryuta Kamizono*
|
921
|
+
|
922
|
+
* Merging conditions on the same column no longer maintain both conditions,
|
923
|
+
and will be consistently replaced by the latter condition in Rails 7.0.
|
924
|
+
To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`.
|
925
|
+
|
926
|
+
```ruby
|
927
|
+
# Rails 6.1 (IN clause is replaced by merger side equality condition)
|
928
|
+
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
|
929
|
+
|
930
|
+
# Rails 6.1 (both conflict conditions exists, deprecated)
|
931
|
+
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
|
932
|
+
|
933
|
+
# Rails 6.1 with rewhere to migrate to Rails 7.0's behavior
|
934
|
+
Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob]
|
935
|
+
|
936
|
+
# Rails 7.0 (same behavior with IN clause, mergee side condition is consistently replaced)
|
937
|
+
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
|
938
|
+
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]
|
939
|
+
```
|
940
|
+
|
941
|
+
*Ryuta Kamizono*
|
942
|
+
|
943
|
+
* Do not mark Postgresql MAC address and UUID attributes as changed when the assigned value only varies by case.
|
944
|
+
|
945
|
+
*Peter Fry*
|
946
|
+
|
947
|
+
* Resolve issue with insert_all unique_by option when used with expression index.
|
948
|
+
|
949
|
+
When the `:unique_by` option of `ActiveRecord::Persistence.insert_all` and
|
950
|
+
`ActiveRecord::Persistence.upsert_all` was used with the name of an expression index, an error
|
951
|
+
was raised. Adding a guard around the formatting behavior for the `:unique_by` corrects this.
|
952
|
+
|
953
|
+
Usage:
|
954
|
+
|
955
|
+
```ruby
|
956
|
+
create_table :books, id: :integer, force: true do |t|
|
957
|
+
t.column :name, :string
|
958
|
+
t.index "lower(name)", unique: true
|
959
|
+
end
|
960
|
+
|
961
|
+
Book.insert_all [{ name: "MyTest" }], unique_by: :index_books_on_lower_name
|
962
|
+
```
|
963
|
+
|
964
|
+
Fixes #39516.
|
965
|
+
|
966
|
+
*Austen Madden*
|
967
|
+
|
968
|
+
* Add basic support for CHECK constraints to database migrations.
|
969
|
+
|
970
|
+
Usage:
|
971
|
+
|
972
|
+
```ruby
|
973
|
+
add_check_constraint :products, "price > 0", name: "price_check"
|
974
|
+
remove_check_constraint :products, name: "price_check"
|
925
975
|
```
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
976
|
+
|
977
|
+
*fatkodima*
|
978
|
+
|
979
|
+
* Add `ActiveRecord::Base.strict_loading_by_default` and `ActiveRecord::Base.strict_loading_by_default=`
|
980
|
+
to enable/disable strict_loading mode by default for a model. The configuration's value is
|
981
|
+
inheritable by subclasses, but they can override that value and it will not impact parent class.
|
982
|
+
|
983
|
+
Usage:
|
984
|
+
|
985
|
+
```ruby
|
986
|
+
class Developer < ApplicationRecord
|
987
|
+
self.strict_loading_by_default = true
|
988
|
+
|
989
|
+
has_many :projects
|
990
|
+
end
|
991
|
+
|
992
|
+
dev = Developer.first
|
993
|
+
dev.projects.first
|
994
|
+
# => ActiveRecord::StrictLoadingViolationError Exception: Developer is marked as strict_loading and Project cannot be lazily loaded.
|
930
995
|
```
|
931
996
|
|
932
|
-
*
|
997
|
+
*bogdanvlviv*
|
933
998
|
|
934
|
-
* Deprecate
|
935
|
-
`indexes_per_table`, `columns_per_multicolumn_index`, `sql_query_length`,
|
936
|
-
and `joins_per_query` methods in `DatabaseLimits`.
|
999
|
+
* Deprecate passing an Active Record object to `quote`/`type_cast` directly.
|
937
1000
|
|
938
1001
|
*Ryuta Kamizono*
|
939
1002
|
|
940
|
-
* `
|
1003
|
+
* Default engine `ENGINE=InnoDB` is no longer dumped to make schema more agnostic.
|
941
1004
|
|
942
|
-
|
943
|
-
is an inflexible data model. In order to improve multiple-database
|
944
|
-
handling in Rails, we've changed this to return an object. Some methods
|
945
|
-
are provided to make the object behave hash-like in order to ease the
|
946
|
-
transition process. Since most applications don't manipulate the hash
|
947
|
-
we've decided to add backwards-compatible functionality that will throw
|
948
|
-
a deprecation warning if used, however calling `ActiveRecord::Base.configurations`
|
949
|
-
will use the new version internally and externally.
|
1005
|
+
Before:
|
950
1006
|
|
951
|
-
|
1007
|
+
```ruby
|
1008
|
+
create_table "accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
|
1009
|
+
end
|
1010
|
+
```
|
1011
|
+
|
1012
|
+
After:
|
952
1013
|
|
1014
|
+
```ruby
|
1015
|
+
create_table "accounts", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
1016
|
+
end
|
953
1017
|
```
|
954
|
-
|
955
|
-
|
956
|
-
|
1018
|
+
|
1019
|
+
*Ryuta Kamizono*
|
1020
|
+
|
1021
|
+
* Added delegated type as an alternative to single-table inheritance for representing class hierarchies.
|
1022
|
+
See ActiveRecord::DelegatedType for the full description.
|
1023
|
+
|
1024
|
+
*DHH*
|
1025
|
+
|
1026
|
+
* Deprecate aggregations with group by duplicated fields.
|
1027
|
+
|
1028
|
+
To migrate to Rails 7.0's behavior, use `uniq!(:group)` to deduplicate group fields.
|
1029
|
+
|
1030
|
+
```ruby
|
1031
|
+
accounts = Account.group(:firm_id)
|
1032
|
+
|
1033
|
+
# duplicated group fields, deprecated.
|
1034
|
+
accounts.merge(accounts.where.not(credit_limit: nil)).sum(:credit_limit)
|
1035
|
+
# => {
|
1036
|
+
# [1, 1] => 50,
|
1037
|
+
# [2, 2] => 60
|
1038
|
+
# }
|
1039
|
+
|
1040
|
+
# use `uniq!(:group)` to deduplicate group fields.
|
1041
|
+
accounts.merge(accounts.where.not(credit_limit: nil)).uniq!(:group).sum(:credit_limit)
|
1042
|
+
# => {
|
1043
|
+
# 1 => 50,
|
1044
|
+
# 2 => 60
|
1045
|
+
# }
|
1046
|
+
```
|
1047
|
+
|
1048
|
+
*Ryuta Kamizono*
|
1049
|
+
|
1050
|
+
* Deprecate duplicated query annotations.
|
1051
|
+
|
1052
|
+
To migrate to Rails 7.0's behavior, use `uniq!(:annotate)` to deduplicate query annotations.
|
1053
|
+
|
1054
|
+
```ruby
|
1055
|
+
accounts = Account.where(id: [1, 2]).annotate("david and mary")
|
1056
|
+
|
1057
|
+
# duplicated annotations, deprecated.
|
1058
|
+
accounts.merge(accounts.rewhere(id: 3))
|
1059
|
+
# SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */ /* david and mary */
|
1060
|
+
|
1061
|
+
# use `uniq!(:annotate)` to deduplicate annotations.
|
1062
|
+
accounts.merge(accounts.rewhere(id: 3)).uniq!(:annotate)
|
1063
|
+
# SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */
|
957
1064
|
```
|
958
1065
|
|
959
|
-
|
1066
|
+
*Ryuta Kamizono*
|
1067
|
+
|
1068
|
+
* Resolve conflict between counter cache and optimistic locking.
|
1069
|
+
|
1070
|
+
Bump an Active Record instance's lock version after updating its counter
|
1071
|
+
cache. This avoids raising an unnecessary `ActiveRecord::StaleObjectError`
|
1072
|
+
upon subsequent transactions by maintaining parity with the corresponding
|
1073
|
+
database record's `lock_version` column.
|
1074
|
+
|
1075
|
+
Fixes #16449.
|
1076
|
+
|
1077
|
+
*Aaron Lipman*
|
960
1078
|
|
1079
|
+
* Support merging option `:rewhere` to allow mergee side condition to be replaced exactly.
|
1080
|
+
|
1081
|
+
```ruby
|
1082
|
+
david_and_mary = Author.where(id: david.id..mary.id)
|
1083
|
+
|
1084
|
+
# both conflict conditions exists
|
1085
|
+
david_and_mary.merge(Author.where(id: bob)) # => []
|
1086
|
+
|
1087
|
+
# mergee side condition is replaced by rewhere
|
1088
|
+
david_and_mary.merge(Author.rewhere(id: bob)) # => [bob]
|
1089
|
+
|
1090
|
+
# mergee side condition is replaced by rewhere option
|
1091
|
+
david_and_mary.merge(Author.where(id: bob), rewhere: true) # => [bob]
|
961
1092
|
```
|
962
|
-
|
1093
|
+
|
1094
|
+
*Ryuta Kamizono*
|
1095
|
+
|
1096
|
+
* Add support for finding records based on signed ids, which are tamper-proof, verified ids that can be
|
1097
|
+
set to expire and scoped with a purpose. This is particularly useful for things like password reset
|
1098
|
+
or email verification, where you want the bearer of the signed id to be able to interact with the
|
1099
|
+
underlying record, but usually only within a certain time period.
|
1100
|
+
|
1101
|
+
```ruby
|
1102
|
+
signed_id = User.first.signed_id expires_in: 15.minutes, purpose: :password_reset
|
1103
|
+
|
1104
|
+
User.find_signed signed_id # => nil, since the purpose does not match
|
1105
|
+
|
1106
|
+
travel 16.minutes
|
1107
|
+
User.find_signed signed_id, purpose: :password_reset # => nil, since the signed id has expired
|
1108
|
+
|
1109
|
+
travel_back
|
1110
|
+
User.find_signed signed_id, purpose: :password_reset # => User.first
|
1111
|
+
|
1112
|
+
User.find_signed! "bad data" # => ActiveSupport::MessageVerifier::InvalidSignature
|
963
1113
|
```
|
964
1114
|
|
965
|
-
|
1115
|
+
*DHH*
|
1116
|
+
|
1117
|
+
* Support `ALGORITHM = INSTANT` DDL option for index operations on MySQL.
|
1118
|
+
|
1119
|
+
*Ryuta Kamizono*
|
1120
|
+
|
1121
|
+
* Fix index creation to preserve index comment in bulk change table on MySQL.
|
966
1122
|
|
1123
|
+
*Ryuta Kamizono*
|
1124
|
+
|
1125
|
+
* Allow `unscope` to be aware of table name qualified values.
|
1126
|
+
|
1127
|
+
It is possible to unscope only the column in the specified table.
|
1128
|
+
|
1129
|
+
```ruby
|
1130
|
+
posts = Post.joins(:comments).group(:"posts.hidden")
|
1131
|
+
posts = posts.where("posts.hidden": false, "comments.hidden": false)
|
1132
|
+
|
1133
|
+
posts.count
|
1134
|
+
# => { false => 10 }
|
1135
|
+
|
1136
|
+
# unscope both hidden columns
|
1137
|
+
posts.unscope(where: :hidden).count
|
1138
|
+
# => { false => 11, true => 1 }
|
1139
|
+
|
1140
|
+
# unscope only comments.hidden column
|
1141
|
+
posts.unscope(where: :"comments.hidden").count
|
1142
|
+
# => { false => 11 }
|
967
1143
|
```
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
1144
|
+
|
1145
|
+
*Ryuta Kamizono*, *Slava Korolev*
|
1146
|
+
|
1147
|
+
* Fix `rewhere` to truly overwrite collided where clause by new where clause.
|
1148
|
+
|
1149
|
+
```ruby
|
1150
|
+
steve = Person.find_by(name: "Steve")
|
1151
|
+
david = Author.find_by(name: "David")
|
1152
|
+
|
1153
|
+
relation = Essay.where(writer: steve)
|
1154
|
+
|
1155
|
+
# Before
|
1156
|
+
relation.rewhere(writer: david).to_a # => []
|
1157
|
+
|
1158
|
+
# After
|
1159
|
+
relation.rewhere(writer: david).to_a # => [david]
|
972
1160
|
```
|
973
1161
|
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
`spec_name` arguments are optional. For example, these return an array of
|
978
|
-
database config objects for the requested environment and a single database config object
|
979
|
-
will be returned for the requested environment and specification name respectively.
|
1162
|
+
*Ryuta Kamizono*
|
1163
|
+
|
1164
|
+
* Inspect time attributes with subsec and time zone offset.
|
980
1165
|
|
1166
|
+
```ruby
|
1167
|
+
p Knot.create
|
1168
|
+
=> #<Knot id: 1, created_at: "2016-05-05 01:29:47.116928000 +0000">
|
981
1169
|
```
|
982
|
-
|
983
|
-
|
1170
|
+
|
1171
|
+
*akinomaeni*, *Jonathan Hefner*
|
1172
|
+
|
1173
|
+
* Deprecate passing a column to `type_cast`.
|
1174
|
+
|
1175
|
+
*Ryuta Kamizono*
|
1176
|
+
|
1177
|
+
* Deprecate `in_clause_length` and `allowed_index_name_length` in `DatabaseLimits`.
|
1178
|
+
|
1179
|
+
*Ryuta Kamizono*
|
1180
|
+
|
1181
|
+
* Support bulk insert/upsert on relation to preserve scope values.
|
1182
|
+
|
1183
|
+
*Josef Šimánek*, *Ryuta Kamizono*
|
1184
|
+
|
1185
|
+
* Preserve column comment value on changing column name on MySQL.
|
1186
|
+
|
1187
|
+
*Islam Taha*
|
1188
|
+
|
1189
|
+
* Add support for `if_exists` option for removing an index.
|
1190
|
+
|
1191
|
+
The `remove_index` method can take an `if_exists` option. If this is set to true an error won't be raised if the index doesn't exist.
|
1192
|
+
|
1193
|
+
*Eileen M. Uchitelle*
|
1194
|
+
|
1195
|
+
* Remove ibm_db, informix, mssql, oracle, and oracle12 Arel visitors which are not used in the code base.
|
1196
|
+
|
1197
|
+
*Ryuta Kamizono*
|
1198
|
+
|
1199
|
+
* Prevent `build_association` from `touching` a parent record if the record isn't persisted for `has_one` associations.
|
1200
|
+
|
1201
|
+
Fixes #38219.
|
1202
|
+
|
1203
|
+
*Josh Brody*
|
1204
|
+
|
1205
|
+
* Add support for `if_not_exists` option for adding index.
|
1206
|
+
|
1207
|
+
The `add_index` method respects `if_not_exists` option. If it is set to true
|
1208
|
+
index won't be added.
|
1209
|
+
|
1210
|
+
Usage:
|
1211
|
+
|
1212
|
+
```ruby
|
1213
|
+
add_index :users, :account_id, if_not_exists: true
|
984
1214
|
```
|
985
1215
|
|
986
|
-
|
1216
|
+
The `if_not_exists` option passed to `create_table` also gets propagated to indexes
|
1217
|
+
created within that migration so that if table and its indexes exist then there is no
|
1218
|
+
attempt to create them again.
|
1219
|
+
|
1220
|
+
*Prathamesh Sonpatki*
|
987
1221
|
|
988
|
-
* Add
|
1222
|
+
* Add `ActiveRecord::Base#previously_new_record?` to show if a record was new before the last save.
|
989
1223
|
|
1224
|
+
*Tom Ward*
|
1225
|
+
|
1226
|
+
* Support descending order for `find_each`, `find_in_batches`, and `in_batches`.
|
1227
|
+
|
1228
|
+
Batch processing methods allow you to work with the records in batches, greatly reducing memory consumption, but records are always batched from oldest id to newest.
|
1229
|
+
|
1230
|
+
This change allows reversing the order, batching from newest to oldest. This is useful when you need to process newer batches of records first.
|
1231
|
+
|
1232
|
+
Pass `order: :desc` to yield batches in descending order. The default remains `order: :asc`.
|
1233
|
+
|
1234
|
+
```ruby
|
1235
|
+
Person.find_each(order: :desc) do |person|
|
1236
|
+
person.party_all_night!
|
1237
|
+
end
|
990
1238
|
```
|
1239
|
+
|
1240
|
+
*Alexey Vasiliev*
|
1241
|
+
|
1242
|
+
* Fix `insert_all` with enum values.
|
1243
|
+
|
1244
|
+
Fixes #38716.
|
1245
|
+
|
1246
|
+
*Joel Blum*
|
1247
|
+
|
1248
|
+
* Add support for `db:rollback:name` for multiple database applications.
|
1249
|
+
|
1250
|
+
Multiple database applications will now raise if `db:rollback` is call and recommend using the `db:rollback:[NAME]` to rollback migrations.
|
1251
|
+
|
1252
|
+
*Eileen M. Uchitelle*
|
1253
|
+
|
1254
|
+
* `Relation#pick` now uses already loaded results instead of making another query.
|
1255
|
+
|
1256
|
+
*Eugene Kenny*
|
1257
|
+
|
1258
|
+
* Deprecate using `return`, `break` or `throw` to exit a transaction block after writes.
|
1259
|
+
|
1260
|
+
*Dylan Thacker-Smith*
|
1261
|
+
|
1262
|
+
* Dump the schema or structure of a database when calling `db:migrate:name`.
|
1263
|
+
|
1264
|
+
In previous versions of Rails, `rails db:migrate` would dump the schema of the database. In Rails 6, that holds true (`rails db:migrate` dumps all databases' schemas), but `rails db:migrate:name` does not share that behavior.
|
1265
|
+
|
1266
|
+
Going forward, calls to `rails db:migrate:name` will dump the schema (or structure) of the database being migrated.
|
1267
|
+
|
1268
|
+
*Kyle Thompson*
|
1269
|
+
|
1270
|
+
* Reset the `ActiveRecord::Base` connection after `rails db:migrate:name`.
|
1271
|
+
|
1272
|
+
When `rails db:migrate` has finished, it ensures the `ActiveRecord::Base` connection is reset to its original configuration. Going forward, `rails db:migrate:name` will have the same behavior.
|
1273
|
+
|
1274
|
+
*Kyle Thompson*
|
1275
|
+
|
1276
|
+
* Disallow calling `connected_to` on subclasses of `ActiveRecord::Base`.
|
1277
|
+
|
1278
|
+
Behavior has not changed here but the previous API could be misleading to people who thought it would switch connections for only that class. `connected_to` switches the context from which we are getting connections, not the connections themselves.
|
1279
|
+
|
1280
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1281
|
+
|
1282
|
+
* Add support for horizontal sharding to `connects_to` and `connected_to`.
|
1283
|
+
|
1284
|
+
Applications can now connect to multiple shards and switch between their shards in an application. Note that the shard swapping is still a manual process as this change does not include an API for automatic shard swapping.
|
1285
|
+
|
1286
|
+
Usage:
|
1287
|
+
|
1288
|
+
Given the following configuration:
|
1289
|
+
|
1290
|
+
```yaml
|
1291
|
+
# config/database.yml
|
991
1292
|
production:
|
1293
|
+
primary:
|
1294
|
+
database: my_database
|
1295
|
+
primary_shard_one:
|
1296
|
+
database: my_database_shard_one
|
1297
|
+
```
|
1298
|
+
|
1299
|
+
Connect to multiple shards:
|
1300
|
+
|
1301
|
+
```ruby
|
1302
|
+
class ApplicationRecord < ActiveRecord::Base
|
1303
|
+
self.abstract_class = true
|
1304
|
+
|
1305
|
+
connects_to shards: {
|
1306
|
+
default: { writing: :primary },
|
1307
|
+
shard_one: { writing: :primary_shard_one }
|
1308
|
+
}
|
1309
|
+
```
|
1310
|
+
|
1311
|
+
Swap between shards in your controller / model code:
|
1312
|
+
|
1313
|
+
```ruby
|
1314
|
+
ActiveRecord::Base.connected_to(shard: :shard_one) do
|
1315
|
+
# Read from shard one
|
1316
|
+
end
|
1317
|
+
```
|
1318
|
+
|
1319
|
+
The horizontal sharding API also supports read replicas. See guides for more details.
|
1320
|
+
|
1321
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1322
|
+
|
1323
|
+
* Deprecate `spec_name` in favor of `name` on database configurations.
|
1324
|
+
|
1325
|
+
The accessors for `spec_name` on `configs_for` and `DatabaseConfig` are deprecated. Please use `name` instead.
|
1326
|
+
|
1327
|
+
Deprecated behavior:
|
1328
|
+
|
1329
|
+
```ruby
|
1330
|
+
db_config = ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
|
1331
|
+
db_config.spec_name
|
1332
|
+
```
|
1333
|
+
|
1334
|
+
New behavior:
|
1335
|
+
|
1336
|
+
```ruby
|
1337
|
+
db_config = ActiveRecord::Base.configurations.configs_for(env_name: "development", name: "primary")
|
1338
|
+
db_config.name
|
1339
|
+
```
|
1340
|
+
|
1341
|
+
*Eileen M. Uchitelle*
|
1342
|
+
|
1343
|
+
* Add additional database-specific rake tasks for multi-database users.
|
1344
|
+
|
1345
|
+
Previously, `rails db:create`, `rails db:drop`, and `rails db:migrate` were the only rails tasks that could operate on a single
|
1346
|
+
database. For example:
|
1347
|
+
|
1348
|
+
```
|
1349
|
+
rails db:create
|
1350
|
+
rails db:create:primary
|
1351
|
+
rails db:create:animals
|
1352
|
+
rails db:drop
|
1353
|
+
rails db:drop:primary
|
1354
|
+
rails db:drop:animals
|
1355
|
+
rails db:migrate
|
1356
|
+
rails db:migrate:primary
|
1357
|
+
rails db:migrate:animals
|
1358
|
+
```
|
1359
|
+
|
1360
|
+
With these changes, `rails db:schema:dump`, `rails db:schema:load`, `rails db:structure:dump`, `rails db:structure:load` and
|
1361
|
+
`rails db:test:prepare` can additionally operate on a single database. For example:
|
1362
|
+
|
1363
|
+
```
|
1364
|
+
rails db:schema:dump
|
1365
|
+
rails db:schema:dump:primary
|
1366
|
+
rails db:schema:dump:animals
|
1367
|
+
rails db:schema:load
|
1368
|
+
rails db:schema:load:primary
|
1369
|
+
rails db:schema:load:animals
|
1370
|
+
rails db:structure:dump
|
1371
|
+
rails db:structure:dump:primary
|
1372
|
+
rails db:structure:dump:animals
|
1373
|
+
rails db:structure:load
|
1374
|
+
rails db:structure:load:primary
|
1375
|
+
rails db:structure:load:animals
|
1376
|
+
rails db:test:prepare
|
1377
|
+
rails db:test:prepare:primary
|
1378
|
+
rails db:test:prepare:animals
|
1379
|
+
```
|
1380
|
+
|
1381
|
+
*Kyle Thompson*
|
1382
|
+
|
1383
|
+
* Add support for `strict_loading` mode on association declarations.
|
1384
|
+
|
1385
|
+
Raise an error if attempting to load a record from an association that has been marked as `strict_loading` unless it was explicitly eager loaded.
|
1386
|
+
|
1387
|
+
Usage:
|
1388
|
+
|
1389
|
+
```ruby
|
1390
|
+
class Developer < ApplicationRecord
|
1391
|
+
has_many :projects, strict_loading: true
|
1392
|
+
end
|
1393
|
+
|
1394
|
+
dev = Developer.first
|
1395
|
+
dev.projects.first
|
1396
|
+
# => ActiveRecord::StrictLoadingViolationError: The projects association is marked as strict_loading and cannot be lazily loaded.
|
1397
|
+
```
|
1398
|
+
|
1399
|
+
*Kevin Deisz*
|
1400
|
+
|
1401
|
+
* Add support for `strict_loading` mode to prevent lazy loading of records.
|
1402
|
+
|
1403
|
+
Raise an error if a parent record is marked as `strict_loading` and attempts to lazily load its associations. This is useful for finding places you may want to preload an association and avoid additional queries.
|
1404
|
+
|
1405
|
+
Usage:
|
1406
|
+
|
1407
|
+
```ruby
|
1408
|
+
dev = Developer.strict_loading.first
|
1409
|
+
dev.audit_logs.to_a
|
1410
|
+
# => ActiveRecord::StrictLoadingViolationError: Developer is marked as strict_loading and AuditLog cannot be lazily loaded.
|
1411
|
+
```
|
1412
|
+
|
1413
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
1414
|
+
|
1415
|
+
* Add support for PostgreSQL 11+ partitioned indexes when using `upsert_all`.
|
1416
|
+
|
1417
|
+
*Sebastián Palma*
|
1418
|
+
|
1419
|
+
* Adds support for `if_not_exists` to `add_column` and `if_exists` to `remove_column`.
|
1420
|
+
|
1421
|
+
Applications can set their migrations to ignore exceptions raised when adding a column that already exists or when removing a column that does not exist.
|
1422
|
+
|
1423
|
+
Example Usage:
|
1424
|
+
|
1425
|
+
```ruby
|
1426
|
+
class AddColumnTitle < ActiveRecord::Migration[6.1]
|
1427
|
+
def change
|
1428
|
+
add_column :posts, :title, :string, if_not_exists: true
|
1429
|
+
end
|
1430
|
+
end
|
1431
|
+
```
|
1432
|
+
|
1433
|
+
```ruby
|
1434
|
+
class RemoveColumnTitle < ActiveRecord::Migration[6.1]
|
1435
|
+
def change
|
1436
|
+
remove_column :posts, :title, if_exists: true
|
1437
|
+
end
|
1438
|
+
end
|
1439
|
+
```
|
1440
|
+
|
1441
|
+
*Eileen M. Uchitelle*
|
1442
|
+
|
1443
|
+
* Regexp-escape table name for MS SQL Server.
|
1444
|
+
|
1445
|
+
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.
|
1446
|
+
|
1447
|
+
*Larry Reid*
|
1448
|
+
|
1449
|
+
* Store advisory locks on their own named connection.
|
1450
|
+
|
1451
|
+
Previously advisory locks were taken out against a connection when a migration started. This works fine in single database applications but doesn't work well when migrations need to open new connections which results in the lock getting dropped.
|
1452
|
+
|
1453
|
+
In order to fix this we are storing the advisory lock on a new connection with the connection specification name `AdvisoryLockBase`. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.
|
1454
|
+
|
1455
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1456
|
+
|
1457
|
+
* Allow schema cache path to be defined in the database configuration file.
|
1458
|
+
|
1459
|
+
For example:
|
1460
|
+
|
1461
|
+
```yaml
|
1462
|
+
development:
|
992
1463
|
adapter: postgresql
|
993
|
-
|
1464
|
+
database: blog_development
|
1465
|
+
pool: 5
|
1466
|
+
schema_cache_path: tmp/schema/main.yml
|
994
1467
|
```
|
995
1468
|
|
996
|
-
*
|
1469
|
+
*Katrina Owen*
|
997
1470
|
|
998
|
-
*
|
1471
|
+
* Deprecate `#remove_connection` in favor of `#remove_connection_pool` when called on the handler.
|
999
1472
|
|
1000
|
-
|
1473
|
+
`#remove_connection` is deprecated in order to support returning a `DatabaseConfig` object instead of a `Hash`. Use `#remove_connection_pool`, `#remove_connection` will be removed in Rails 7.0.
|
1001
1474
|
|
1002
|
-
*
|
1475
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1003
1476
|
|
1004
|
-
|
1477
|
+
* Deprecate `#default_hash` and it's alias `#[]` on database configurations.
|
1478
|
+
|
1479
|
+
Applications should use `configs_for`. `#default_hash` and `#[]` will be removed in Rails 7.0.
|
1480
|
+
|
1481
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1482
|
+
|
1483
|
+
* Add scale support to `ActiveRecord::Validations::NumericalityValidator`.
|
1005
1484
|
|
1006
|
-
|
1485
|
+
*Gannon McGibbon*
|
1486
|
+
|
1487
|
+
* Find orphans by looking for missing relations through chaining `where.missing`:
|
1488
|
+
|
1489
|
+
Before:
|
1490
|
+
|
1491
|
+
```ruby
|
1492
|
+
Post.left_joins(:author).where(authors: { id: nil })
|
1493
|
+
```
|
1494
|
+
|
1495
|
+
After:
|
1496
|
+
|
1497
|
+
```ruby
|
1498
|
+
Post.where.missing(:author)
|
1499
|
+
```
|
1500
|
+
|
1501
|
+
*Tom Rossi*
|
1502
|
+
|
1503
|
+
* Ensure `:reading` connections always raise if a write is attempted.
|
1504
|
+
|
1505
|
+
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`.
|
1506
|
+
|
1507
|
+
*Eileen M. Uchitelle*
|
1508
|
+
|
1509
|
+
* Deprecate `"primary"` as the `connection_specification_name` for `ActiveRecord::Base`.
|
1510
|
+
|
1511
|
+
`"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"`.
|
1512
|
+
|
1513
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1514
|
+
|
1515
|
+
* Add `ActiveRecord::Validations::NumericalityValidator` with
|
1516
|
+
support for casting floats using a database columns' precision value.
|
1517
|
+
|
1518
|
+
*Gannon McGibbon*
|
1519
|
+
|
1520
|
+
* Enforce fresh ETag header after a collection's contents change by adding
|
1521
|
+
ActiveRecord::Relation#cache_key_with_version. This method will be used by
|
1522
|
+
ActionController::ConditionalGet to ensure that when collection cache versioning
|
1523
|
+
is enabled, requests using ConditionalGet don't return the same ETag header
|
1524
|
+
after a collection is modified.
|
1525
|
+
|
1526
|
+
Fixes #38078.
|
1527
|
+
|
1528
|
+
*Aaron Lipman*
|
1007
1529
|
|
1008
|
-
|
1530
|
+
* Skip test database when running `db:create` or `db:drop` in development
|
1531
|
+
with `DATABASE_URL` set.
|
1009
1532
|
|
1010
|
-
*
|
1011
|
-
seed load in environments without Rails and custom DB configuration
|
1533
|
+
*Brian Buchalter*
|
1012
1534
|
|
1013
|
-
|
1535
|
+
* Don't allow mutations on the database configurations hash.
|
1536
|
+
|
1537
|
+
Freeze the configurations hash to disallow directly changing it. If applications need to change the hash, for example to create databases for parallelization, they should use the `DatabaseConfig` object directly.
|
1538
|
+
|
1539
|
+
Before:
|
1540
|
+
|
1541
|
+
```ruby
|
1542
|
+
@db_config = ActiveRecord::Base.configurations.configs_for(env_name: "test", spec_name: "primary")
|
1543
|
+
@db_config.configuration_hash.merge!(idle_timeout: "0.02")
|
1544
|
+
```
|
1545
|
+
|
1546
|
+
After:
|
1547
|
+
|
1548
|
+
```ruby
|
1549
|
+
@db_config = ActiveRecord::Base.configurations.configs_for(env_name: "test", spec_name: "primary")
|
1550
|
+
config = @db_config.configuration_hash.merge(idle_timeout: "0.02")
|
1551
|
+
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(@db_config.env_name, @db_config.spec_name, config)
|
1552
|
+
```
|
1553
|
+
|
1554
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1555
|
+
|
1556
|
+
* Remove `:connection_id` from the `sql.active_record` notification.
|
1557
|
+
|
1558
|
+
*Aaron Patterson*, *Rafael Mendonça França*
|
1559
|
+
|
1560
|
+
* The `:name` key will no longer be returned as part of `DatabaseConfig#configuration_hash`. Please use `DatabaseConfig#owner_name` instead.
|
1561
|
+
|
1562
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1563
|
+
|
1564
|
+
* ActiveRecord's `belongs_to_required_by_default` flag can now be set per model.
|
1565
|
+
|
1566
|
+
You can now opt-out/opt-in specific models from having their associations required
|
1567
|
+
by default.
|
1568
|
+
|
1569
|
+
This change is meant to ease the process of migrating all your models to have
|
1570
|
+
their association required.
|
1571
|
+
|
1572
|
+
*Edouard Chin*
|
1573
|
+
|
1574
|
+
* The `connection_config` method has been deprecated, please use `connection_db_config` instead which will return a `DatabaseConfigurations::DatabaseConfig` instead of a `Hash`.
|
1575
|
+
|
1576
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1577
|
+
|
1578
|
+
* Retain explicit selections on the base model after applying `includes` and `joins`.
|
1579
|
+
|
1580
|
+
Resolves #34889.
|
1581
|
+
|
1582
|
+
*Patrick Rebsch*
|
1014
1583
|
|
1015
|
-
*
|
1584
|
+
* The `database` kwarg is deprecated without replacement because it can't be used for sharding and creates an issue if it's used during a request. Applications that need to create new connections should use `connects_to` instead.
|
1016
1585
|
|
1017
|
-
*
|
1586
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1018
1587
|
|
1019
|
-
*
|
1588
|
+
* Allow attributes to be fetched from Arel node groupings.
|
1589
|
+
|
1590
|
+
*Jeff Emminger*, *Gannon McGibbon*
|
1591
|
+
|
1592
|
+
* A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgreSQL `options`.
|
1593
|
+
|
1594
|
+
*Joshua Flanagan*
|
1595
|
+
|
1596
|
+
* Calling methods like `establish_connection` with a `Hash` which is invalid (eg: no `adapter`) will now raise an error the same way as connections defined in `config/database.yml`.
|
1597
|
+
|
1598
|
+
*John Crepezzi*
|
1599
|
+
|
1600
|
+
* Specifying `implicit_order_column` now subsorts the records by primary key if available to ensure deterministic results.
|
1601
|
+
|
1602
|
+
*Paweł Urbanek*
|
1603
|
+
|
1604
|
+
* `where(attr => [])` now loads an empty result without making a query.
|
1605
|
+
|
1606
|
+
*John Hawthorn*
|
1607
|
+
|
1608
|
+
* Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
|
1609
|
+
|
1610
|
+
*Hiroyuki Ishii*
|
1611
|
+
|
1612
|
+
* Add support for `belongs_to` to `has_many` inversing.
|
1613
|
+
|
1614
|
+
*Gannon McGibbon*
|
1615
|
+
|
1616
|
+
* Allow length configuration for `has_secure_token` method. The minimum length
|
1617
|
+
is set at 24 characters.
|
1618
|
+
|
1619
|
+
Before:
|
1620
|
+
|
1621
|
+
```ruby
|
1622
|
+
has_secure_token :auth_token
|
1623
|
+
```
|
1624
|
+
|
1625
|
+
After:
|
1626
|
+
|
1627
|
+
```ruby
|
1628
|
+
has_secure_token :default_token # 24 characters
|
1629
|
+
has_secure_token :auth_token, length: 36 # 36 characters
|
1630
|
+
has_secure_token :invalid_token, length: 12 # => ActiveRecord::SecureToken::MinimumLengthError
|
1631
|
+
```
|
1632
|
+
|
1633
|
+
*Bernardo de Araujo*
|
1634
|
+
|
1635
|
+
* Deprecate `DatabaseConfigurations#to_h`. These connection hashes are still available via `ActiveRecord::Base.configurations.configs_for`.
|
1636
|
+
|
1637
|
+
*Eileen Uchitelle*, *John Crepezzi*
|
1638
|
+
|
1639
|
+
* Add `DatabaseConfig#configuration_hash` to return database configuration hashes with symbol keys, and use all symbol-key configuration hashes internally. Deprecate `DatabaseConfig#config` which returns a String-keyed `Hash` with the same values.
|
1640
|
+
|
1641
|
+
*John Crepezzi*, *Eileen Uchitelle*
|
1642
|
+
|
1643
|
+
* Allow column names to be passed to `remove_index` positionally along with other options.
|
1644
|
+
|
1645
|
+
Passing other options can be necessary to make `remove_index` correctly reversible.
|
1646
|
+
|
1647
|
+
Before:
|
1648
|
+
|
1649
|
+
add_index :reports, :report_id # => works
|
1650
|
+
add_index :reports, :report_id, unique: true # => works
|
1651
|
+
remove_index :reports, :report_id # => works
|
1652
|
+
remove_index :reports, :report_id, unique: true # => ArgumentError
|
1653
|
+
|
1654
|
+
After:
|
1655
|
+
|
1656
|
+
remove_index :reports, :report_id, unique: true # => works
|
1657
|
+
|
1658
|
+
*Eugene Kenny*
|
1659
|
+
|
1660
|
+
* Allow bulk `ALTER` statements to drop and recreate indexes with the same name.
|
1661
|
+
|
1662
|
+
*Eugene Kenny*
|
1663
|
+
|
1664
|
+
* `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
|
1665
|
+
|
1666
|
+
*Eugene Kenny*
|
1667
|
+
|
1668
|
+
* Call `while_preventing_writes` directly from `connected_to`.
|
1669
|
+
|
1670
|
+
In some cases application authors want to use the database switching middleware and make explicit calls with `connected_to`. It's possible for an app to turn off writes and not turn them back on by the time we call `connected_to(role: :writing)`.
|
1671
|
+
|
1672
|
+
This change allows apps to fix this by assuming if a role is writing we want to allow writes, except in the case it's explicitly turned off.
|
1673
|
+
|
1674
|
+
*Eileen M. Uchitelle*
|
1675
|
+
|
1676
|
+
* Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
|
1677
|
+
|
1678
|
+
*Kir Shatrov*
|
1679
|
+
|
1680
|
+
* Stop trying to read yaml file fixtures when loading Active Record fixtures.
|
1681
|
+
|
1682
|
+
*Gannon McGibbon*
|
1683
|
+
|
1684
|
+
* Deprecate `.reorder(nil)` with `.first` / `.first!` taking non-deterministic result.
|
1685
|
+
|
1686
|
+
To continue taking non-deterministic result, use `.take` / `.take!` instead.
|
1020
1687
|
|
1021
1688
|
*Ryuta Kamizono*
|
1022
1689
|
|
1023
|
-
*
|
1690
|
+
* Preserve user supplied joins order as much as possible.
|
1024
1691
|
|
1025
|
-
Fixes #
|
1692
|
+
Fixes #36761, #34328, #24281, #12953.
|
1026
1693
|
|
1027
|
-
*
|
1694
|
+
*Ryuta Kamizono*
|
1028
1695
|
|
1029
|
-
*
|
1696
|
+
* Allow `matches_regex` and `does_not_match_regexp` on the MySQL Arel visitor.
|
1030
1697
|
|
1031
|
-
*
|
1698
|
+
*James Pearson*
|
1032
1699
|
|
1033
|
-
*
|
1700
|
+
* Allow specifying fixtures to be ignored by setting `ignore` in YAML file's '_fixture' section.
|
1034
1701
|
|
1035
|
-
|
1702
|
+
*Tongfei Gao*
|
1036
1703
|
|
1037
|
-
|
1704
|
+
* Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
|
1038
1705
|
|
1039
|
-
*
|
1706
|
+
*John Crepezzi*, *Eileen Uchitelle*
|
1040
1707
|
|
1041
|
-
|
1708
|
+
* Add a warning for enum elements with 'not_' prefix.
|
1042
1709
|
|
1043
|
-
|
1044
|
-
|
1710
|
+
class Foo
|
1711
|
+
enum status: [:sent, :not_sent]
|
1712
|
+
end
|
1045
1713
|
|
1046
|
-
*
|
1714
|
+
*Edu Depetris*
|
1047
1715
|
|
1048
|
-
*
|
1716
|
+
* Make currency symbols optional for money column type in PostgreSQL.
|
1049
1717
|
|
1050
|
-
*
|
1718
|
+
*Joel Schneider*
|
1051
1719
|
|
1052
|
-
* Add
|
1720
|
+
* Add support for beginless ranges, introduced in Ruby 2.7.
|
1053
1721
|
|
1054
|
-
|
1722
|
+
*Josh Goodall*
|
1055
1723
|
|
1056
|
-
|
1724
|
+
* Add `database_exists?` method to connection adapters to check if a database exists.
|
1057
1725
|
|
1058
|
-
*
|
1726
|
+
*Guilherme Mansur*
|
1059
1727
|
|
1060
|
-
*
|
1728
|
+
* Loading the schema for a model that has no `table_name` raises a `TableNotSpecified` error.
|
1061
1729
|
|
1062
|
-
*
|
1730
|
+
*Guilherme Mansur*, *Eugene Kenny*
|
1063
1731
|
|
1064
|
-
*
|
1732
|
+
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
1065
1733
|
|
1066
|
-
|
1734
|
+
Fixes #36022.
|
1067
1735
|
|
1068
|
-
*
|
1736
|
+
*Ryuta Kamizono*
|
1069
1737
|
|
1070
|
-
|
1738
|
+
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
1071
1739
|
|
1072
|
-
|
1740
|
+
Fixes #36465.
|
1073
1741
|
|
1074
|
-
*
|
1742
|
+
*Jeff Doering*
|
1075
1743
|
|
1076
|
-
* Add
|
1077
|
-
`ActiveRecord::Base.find_or_create_by`/`!` by leaning on unique constraints in the database.
|
1744
|
+
* Add support for multiple databases to `rails db:abort_if_pending_migrations`.
|
1078
1745
|
|
1079
|
-
*
|
1746
|
+
*Mark Lee*
|
1080
1747
|
|
1081
|
-
*
|
1748
|
+
* Fix sqlite3 collation parsing when using decimal columns.
|
1082
1749
|
|
1083
|
-
*
|
1750
|
+
*Martin R. Schuster*
|
1751
|
+
|
1752
|
+
* Fix invalid schema when primary key column has a comment.
|
1753
|
+
|
1754
|
+
Fixes #29966.
|
1755
|
+
|
1756
|
+
*Guilherme Goettems Schneider*
|
1757
|
+
|
1758
|
+
* Fix table comment also being applied to the primary key column.
|
1759
|
+
|
1760
|
+
*Guilherme Goettems Schneider*
|
1761
|
+
|
1762
|
+
* Allow generated `create_table` migrations to include or skip timestamps.
|
1763
|
+
|
1764
|
+
*Michael Duchemin*
|
1084
1765
|
|
1085
1766
|
|
1086
|
-
Please check [
|
1767
|
+
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activerecord/CHANGELOG.md) for previous changes.
|