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