activerecord 6.1.7 → 7.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +616 -1290
- data/MIT-LICENSE +1 -1
- data/README.rdoc +31 -31
- data/examples/performance.rb +2 -2
- data/lib/active_record/aggregations.rb +17 -14
- data/lib/active_record/association_relation.rb +2 -12
- data/lib/active_record/associations/alias_tracker.rb +25 -19
- data/lib/active_record/associations/association.rb +60 -21
- data/lib/active_record/associations/association_scope.rb +17 -12
- data/lib/active_record/associations/belongs_to_association.rb +37 -11
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +13 -4
- data/lib/active_record/associations/builder/association.rb +11 -5
- data/lib/active_record/associations/builder/belongs_to.rb +41 -14
- data/lib/active_record/associations/builder/collection_association.rb +10 -3
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +3 -7
- data/lib/active_record/associations/builder/has_many.rb +4 -4
- data/lib/active_record/associations/builder/has_one.rb +4 -4
- data/lib/active_record/associations/builder/singular_association.rb +6 -2
- data/lib/active_record/associations/collection_association.rb +46 -36
- data/lib/active_record/associations/collection_proxy.rb +44 -16
- data/lib/active_record/associations/disable_joins_association_scope.rb +59 -0
- data/lib/active_record/associations/errors.rb +265 -0
- data/lib/active_record/associations/foreign_association.rb +10 -3
- data/lib/active_record/associations/has_many_association.rb +29 -19
- data/lib/active_record/associations/has_many_through_association.rb +19 -8
- data/lib/active_record/associations/has_one_association.rb +20 -10
- data/lib/active_record/associations/has_one_through_association.rb +1 -1
- data/lib/active_record/associations/join_dependency/join_association.rb +30 -27
- data/lib/active_record/associations/join_dependency.rb +28 -20
- data/lib/active_record/associations/nested_error.rb +47 -0
- data/lib/active_record/associations/preloader/association.rb +212 -53
- data/lib/active_record/associations/preloader/batch.rb +48 -0
- data/lib/active_record/associations/preloader/branch.rb +153 -0
- data/lib/active_record/associations/preloader/through_association.rb +50 -16
- data/lib/active_record/associations/preloader.rb +50 -121
- data/lib/active_record/associations/singular_association.rb +15 -3
- data/lib/active_record/associations/through_association.rb +25 -14
- data/lib/active_record/associations.rb +429 -522
- data/lib/active_record/asynchronous_queries_tracker.rb +60 -0
- data/lib/active_record/attribute_assignment.rb +1 -5
- data/lib/active_record/attribute_methods/before_type_cast.rb +24 -2
- data/lib/active_record/attribute_methods/composite_primary_key.rb +84 -0
- data/lib/active_record/attribute_methods/dirty.rb +73 -22
- data/lib/active_record/attribute_methods/primary_key.rb +47 -27
- data/lib/active_record/attribute_methods/query.rb +31 -19
- data/lib/active_record/attribute_methods/read.rb +14 -11
- data/lib/active_record/attribute_methods/serialization.rb +174 -37
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +15 -9
- data/lib/active_record/attribute_methods/write.rb +12 -15
- data/lib/active_record/attribute_methods.rb +164 -52
- data/lib/active_record/attributes.rb +57 -54
- data/lib/active_record/autosave_association.rb +74 -57
- data/lib/active_record/base.rb +27 -5
- data/lib/active_record/callbacks.rb +19 -35
- data/lib/active_record/coders/column_serializer.rb +61 -0
- data/lib/active_record/coders/json.rb +1 -1
- data/lib/active_record/coders/yaml_column.rb +70 -46
- data/lib/active_record/connection_adapters/abstract/connection_handler.rb +284 -0
- data/lib/active_record/connection_adapters/abstract/connection_pool/queue.rb +211 -0
- data/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb +79 -0
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +325 -604
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +5 -17
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +199 -60
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +230 -64
- data/lib/active_record/connection_adapters/abstract/quoting.rb +119 -131
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +4 -3
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +21 -20
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +186 -31
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +14 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +378 -143
- data/lib/active_record/connection_adapters/abstract/transaction.rb +361 -76
- data/lib/active_record/connection_adapters/abstract_adapter.rb +624 -163
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +348 -165
- data/lib/active_record/connection_adapters/column.rb +13 -0
- data/lib/active_record/connection_adapters/mysql/column.rb +1 -0
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +29 -130
- data/lib/active_record/connection_adapters/mysql/quoting.rb +81 -55
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +9 -0
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +10 -1
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +8 -2
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +45 -14
- data/lib/active_record/connection_adapters/mysql2/database_statements.rb +152 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +107 -68
- data/lib/active_record/connection_adapters/pool_config.rb +26 -16
- data/lib/active_record/connection_adapters/pool_manager.rb +19 -9
- data/lib/active_record/connection_adapters/postgresql/column.rb +30 -1
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +114 -54
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +6 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +8 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +5 -0
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +53 -14
- data/lib/active_record/connection_adapters/postgresql/oid/interval.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +3 -2
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +12 -3
- data/lib/active_record/connection_adapters/postgresql/oid/timestamp.rb +15 -0
- data/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb +30 -0
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +18 -6
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +14 -4
- data/lib/active_record/connection_adapters/postgresql/oid.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +137 -104
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +28 -0
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +92 -2
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +173 -3
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +78 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +403 -77
- data/lib/active_record/connection_adapters/postgresql/utils.rb +9 -10
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +520 -253
- data/lib/active_record/connection_adapters/schema_cache.rb +326 -102
- data/lib/active_record/connection_adapters/sqlite3/column.rb +62 -0
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +78 -55
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +68 -54
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +22 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +20 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +16 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +66 -22
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +372 -130
- data/lib/active_record/connection_adapters/statement_pool.rb +7 -0
- data/lib/active_record/connection_adapters/trilogy/database_statements.rb +99 -0
- data/lib/active_record/connection_adapters/trilogy_adapter.rb +229 -0
- data/lib/active_record/connection_adapters.rb +130 -6
- data/lib/active_record/connection_handling.rb +132 -146
- data/lib/active_record/core.rb +310 -253
- data/lib/active_record/counter_cache.rb +68 -34
- data/lib/active_record/database_configurations/connection_url_resolver.rb +10 -4
- data/lib/active_record/database_configurations/database_config.rb +34 -10
- data/lib/active_record/database_configurations/hash_config.rb +107 -31
- data/lib/active_record/database_configurations/url_config.rb +38 -13
- data/lib/active_record/database_configurations.rb +96 -60
- data/lib/active_record/delegated_type.rb +90 -20
- data/lib/active_record/deprecator.rb +7 -0
- data/lib/active_record/destroy_association_async_job.rb +4 -2
- data/lib/active_record/disable_joins_association_relation.rb +39 -0
- data/lib/active_record/dynamic_matchers.rb +3 -3
- data/lib/active_record/encryption/auto_filtered_parameters.rb +66 -0
- data/lib/active_record/encryption/cipher/aes256_gcm.rb +101 -0
- data/lib/active_record/encryption/cipher.rb +53 -0
- data/lib/active_record/encryption/config.rb +68 -0
- data/lib/active_record/encryption/configurable.rb +60 -0
- data/lib/active_record/encryption/context.rb +42 -0
- data/lib/active_record/encryption/contexts.rb +76 -0
- data/lib/active_record/encryption/derived_secret_key_provider.rb +18 -0
- data/lib/active_record/encryption/deterministic_key_provider.rb +14 -0
- data/lib/active_record/encryption/encryptable_record.rb +230 -0
- data/lib/active_record/encryption/encrypted_attribute_type.rb +175 -0
- data/lib/active_record/encryption/encrypted_fixtures.rb +38 -0
- data/lib/active_record/encryption/encrypting_only_encryptor.rb +12 -0
- data/lib/active_record/encryption/encryptor.rb +170 -0
- data/lib/active_record/encryption/envelope_encryption_key_provider.rb +55 -0
- data/lib/active_record/encryption/errors.rb +15 -0
- data/lib/active_record/encryption/extended_deterministic_queries.rb +157 -0
- data/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb +28 -0
- data/lib/active_record/encryption/key.rb +28 -0
- data/lib/active_record/encryption/key_generator.rb +53 -0
- data/lib/active_record/encryption/key_provider.rb +46 -0
- data/lib/active_record/encryption/message.rb +33 -0
- data/lib/active_record/encryption/message_pack_message_serializer.rb +76 -0
- data/lib/active_record/encryption/message_serializer.rb +96 -0
- data/lib/active_record/encryption/null_encryptor.rb +25 -0
- data/lib/active_record/encryption/properties.rb +76 -0
- data/lib/active_record/encryption/read_only_null_encryptor.rb +28 -0
- data/lib/active_record/encryption/scheme.rb +100 -0
- data/lib/active_record/encryption.rb +58 -0
- data/lib/active_record/enum.rb +170 -62
- data/lib/active_record/errors.rb +210 -27
- data/lib/active_record/explain.rb +21 -12
- data/lib/active_record/explain_registry.rb +11 -6
- data/lib/active_record/explain_subscriber.rb +1 -1
- data/lib/active_record/fixture_set/file.rb +15 -1
- data/lib/active_record/fixture_set/model_metadata.rb +14 -4
- data/lib/active_record/fixture_set/render_context.rb +2 -0
- data/lib/active_record/fixture_set/table_row.rb +70 -14
- data/lib/active_record/fixture_set/table_rows.rb +4 -4
- data/lib/active_record/fixtures.rb +179 -112
- data/lib/active_record/future_result.rb +178 -0
- data/lib/active_record/gem_version.rb +4 -4
- data/lib/active_record/inheritance.rb +85 -31
- data/lib/active_record/insert_all.rb +148 -32
- data/lib/active_record/integration.rb +14 -10
- data/lib/active_record/internal_metadata.rb +123 -23
- data/lib/active_record/legacy_yaml_adapter.rb +2 -39
- data/lib/active_record/locking/optimistic.rb +43 -27
- data/lib/active_record/locking/pessimistic.rb +15 -6
- data/lib/active_record/log_subscriber.rb +41 -29
- data/lib/active_record/marshalling.rb +59 -0
- data/lib/active_record/message_pack.rb +124 -0
- data/lib/active_record/middleware/database_selector/resolver.rb +10 -10
- data/lib/active_record/middleware/database_selector.rb +23 -13
- data/lib/active_record/middleware/shard_selector.rb +62 -0
- data/lib/active_record/migration/command_recorder.rb +113 -16
- data/lib/active_record/migration/compatibility.rb +235 -46
- data/lib/active_record/migration/default_strategy.rb +22 -0
- data/lib/active_record/migration/execution_strategy.rb +19 -0
- data/lib/active_record/migration/join_table.rb +1 -1
- data/lib/active_record/migration/pending_migration_connection.rb +21 -0
- data/lib/active_record/migration.rb +374 -177
- data/lib/active_record/model_schema.rb +145 -158
- data/lib/active_record/nested_attributes.rb +61 -23
- data/lib/active_record/no_touching.rb +3 -3
- data/lib/active_record/normalization.rb +163 -0
- data/lib/active_record/persistence.rb +282 -283
- data/lib/active_record/promise.rb +84 -0
- data/lib/active_record/query_cache.rb +18 -25
- data/lib/active_record/query_logs.rb +189 -0
- data/lib/active_record/query_logs_formatter.rb +41 -0
- data/lib/active_record/querying.rb +44 -9
- data/lib/active_record/railtie.rb +229 -71
- data/lib/active_record/railties/controller_runtime.rb +25 -11
- data/lib/active_record/railties/databases.rake +189 -256
- data/lib/active_record/railties/job_runtime.rb +23 -0
- data/lib/active_record/readonly_attributes.rb +41 -3
- data/lib/active_record/reflection.rb +332 -103
- data/lib/active_record/relation/batches/batch_enumerator.rb +38 -9
- data/lib/active_record/relation/batches.rb +200 -65
- data/lib/active_record/relation/calculations.rb +301 -112
- data/lib/active_record/relation/delegation.rb +33 -22
- data/lib/active_record/relation/finder_methods.rb +123 -52
- data/lib/active_record/relation/merger.rb +26 -19
- data/lib/active_record/relation/predicate_builder/array_handler.rb +2 -2
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +38 -4
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +10 -7
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +5 -1
- data/lib/active_record/relation/predicate_builder.rb +29 -22
- data/lib/active_record/relation/query_attribute.rb +30 -12
- data/lib/active_record/relation/query_methods.rb +870 -163
- data/lib/active_record/relation/record_fetch_warning.rb +10 -9
- data/lib/active_record/relation/spawn_methods.rb +7 -6
- data/lib/active_record/relation/where_clause.rb +15 -36
- data/lib/active_record/relation.rb +736 -145
- data/lib/active_record/result.rb +67 -54
- data/lib/active_record/runtime_registry.rb +71 -13
- data/lib/active_record/sanitization.rb +84 -34
- data/lib/active_record/schema.rb +39 -23
- data/lib/active_record/schema_dumper.rb +90 -31
- data/lib/active_record/schema_migration.rb +74 -23
- data/lib/active_record/scoping/default.rb +72 -15
- data/lib/active_record/scoping/named.rb +6 -13
- data/lib/active_record/scoping.rb +65 -34
- data/lib/active_record/secure_password.rb +60 -0
- data/lib/active_record/secure_token.rb +21 -3
- data/lib/active_record/serialization.rb +6 -1
- data/lib/active_record/signed_id.rb +30 -9
- data/lib/active_record/statement_cache.rb +7 -7
- data/lib/active_record/store.rb +10 -10
- data/lib/active_record/suppressor.rb +13 -15
- data/lib/active_record/table_metadata.rb +7 -3
- data/lib/active_record/tasks/database_tasks.rb +288 -149
- data/lib/active_record/tasks/mysql_database_tasks.rb +16 -7
- data/lib/active_record/tasks/postgresql_database_tasks.rb +35 -26
- data/lib/active_record/tasks/sqlite_database_tasks.rb +16 -7
- data/lib/active_record/test_databases.rb +1 -1
- data/lib/active_record/test_fixtures.rb +173 -155
- data/lib/active_record/testing/query_assertions.rb +121 -0
- data/lib/active_record/timestamp.rb +32 -19
- data/lib/active_record/token_for.rb +123 -0
- data/lib/active_record/touch_later.rb +12 -7
- data/lib/active_record/transaction.rb +132 -0
- data/lib/active_record/transactions.rb +118 -41
- data/lib/active_record/translation.rb +3 -5
- data/lib/active_record/type/adapter_specific_registry.rb +32 -14
- data/lib/active_record/type/hash_lookup_type_map.rb +34 -1
- data/lib/active_record/type/internal/timezone.rb +7 -2
- data/lib/active_record/type/serialized.rb +9 -7
- data/lib/active_record/type/time.rb +4 -0
- data/lib/active_record/type/type_map.rb +17 -20
- data/lib/active_record/type.rb +1 -2
- data/lib/active_record/type_caster/connection.rb +4 -4
- data/lib/active_record/validations/absence.rb +1 -1
- data/lib/active_record/validations/associated.rb +13 -7
- data/lib/active_record/validations/numericality.rb +5 -4
- data/lib/active_record/validations/presence.rb +5 -28
- data/lib/active_record/validations/uniqueness.rb +65 -15
- data/lib/active_record/validations.rb +12 -5
- data/lib/active_record/version.rb +1 -1
- data/lib/active_record.rb +444 -32
- data/lib/arel/alias_predication.rb +1 -1
- data/lib/arel/attributes/attribute.rb +0 -8
- data/lib/arel/collectors/bind.rb +2 -0
- data/lib/arel/collectors/composite.rb +7 -0
- data/lib/arel/collectors/sql_string.rb +1 -1
- data/lib/arel/collectors/substitute_binds.rb +1 -1
- data/lib/arel/crud.rb +28 -22
- data/lib/arel/delete_manager.rb +18 -4
- data/lib/arel/errors.rb +10 -0
- data/lib/arel/factory_methods.rb +4 -0
- data/lib/arel/filter_predications.rb +9 -0
- data/lib/arel/insert_manager.rb +2 -3
- data/lib/arel/nodes/binary.rb +6 -7
- data/lib/arel/nodes/bound_sql_literal.rb +65 -0
- data/lib/arel/nodes/casted.rb +1 -1
- data/lib/arel/nodes/cte.rb +36 -0
- data/lib/arel/nodes/delete_statement.rb +12 -13
- data/lib/arel/nodes/filter.rb +10 -0
- data/lib/arel/nodes/fragments.rb +35 -0
- data/lib/arel/nodes/function.rb +1 -0
- data/lib/arel/nodes/homogeneous_in.rb +1 -9
- data/lib/arel/nodes/insert_statement.rb +2 -2
- data/lib/arel/nodes/leading_join.rb +8 -0
- data/lib/arel/nodes/{and.rb → nary.rb} +9 -2
- data/lib/arel/nodes/node.rb +115 -5
- data/lib/arel/nodes/select_core.rb +2 -2
- data/lib/arel/nodes/select_statement.rb +2 -2
- data/lib/arel/nodes/sql_literal.rb +13 -0
- data/lib/arel/nodes/table_alias.rb +4 -0
- data/lib/arel/nodes/update_statement.rb +8 -3
- data/lib/arel/nodes.rb +7 -2
- data/lib/arel/predications.rb +14 -4
- data/lib/arel/select_manager.rb +11 -5
- data/lib/arel/table.rb +9 -6
- data/lib/arel/tree_manager.rb +8 -15
- data/lib/arel/update_manager.rb +20 -5
- data/lib/arel/visitors/dot.rb +81 -90
- data/lib/arel/visitors/mysql.rb +23 -5
- data/lib/arel/visitors/postgresql.rb +1 -22
- data/lib/arel/visitors/sqlite.rb +25 -0
- data/lib/arel/visitors/to_sql.rb +170 -36
- data/lib/arel/visitors/visitor.rb +2 -2
- data/lib/arel.rb +23 -4
- data/lib/rails/generators/active_record/application_record/USAGE +8 -0
- data/lib/rails/generators/active_record/application_record/templates/application_record.rb.tt +1 -1
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +4 -1
- data/lib/rails/generators/active_record/migration.rb +3 -1
- data/lib/rails/generators/active_record/model/USAGE +113 -0
- data/lib/rails/generators/active_record/model/model_generator.rb +15 -6
- data/lib/rails/generators/active_record/model/templates/abstract_base_class.rb.tt +1 -1
- data/lib/rails/generators/active_record/model/templates/model.rb.tt +1 -1
- data/lib/rails/generators/active_record/model/templates/module.rb.tt +2 -2
- data/lib/rails/generators/active_record/multi_db/multi_db_generator.rb +16 -0
- data/lib/rails/generators/active_record/multi_db/templates/multi_db.rb.tt +44 -0
- metadata +103 -17
- data/lib/active_record/connection_adapters/legacy_pool_manager.rb +0 -35
- data/lib/active_record/null_relation.rb +0 -67
data/CHANGELOG.md
CHANGED
@@ -1,1767 +1,1093 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 7.2.2 (October 30, 2024) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Fix support for `query_cache: false` in `database.yml`.
|
4
4
|
|
5
|
-
|
5
|
+
`query_cache: false` would no longer entirely disable the Active Record query cache.
|
6
6
|
|
7
|
-
*
|
7
|
+
*zzak*
|
8
8
|
|
9
|
-
|
10
|
-
which is wasteful and cause problem with YAML safe_load.
|
9
|
+
* Set `.attributes_for_inspect` to `:all` by default.
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
* Fix PG.connect keyword arguments deprecation warning on ruby 2.7
|
15
|
-
|
16
|
-
Fixes #44307.
|
17
|
-
|
18
|
-
*Nikita Vasilevsky*
|
19
|
-
|
20
|
-
## Rails 6.1.6.1 (July 12, 2022) ##
|
21
|
-
|
22
|
-
* Change ActiveRecord::Coders::YAMLColumn default to safe_load
|
23
|
-
|
24
|
-
This adds two new configuration options The configuration options are as
|
25
|
-
follows:
|
26
|
-
|
27
|
-
* `config.active_storage.use_yaml_unsafe_load`
|
28
|
-
|
29
|
-
When set to true, this configuration option tells Rails to use the old
|
30
|
-
"unsafe" YAML loading strategy, maintaining the existing behavior but leaving
|
31
|
-
the possible escalation vulnerability in place. Setting this option to true
|
32
|
-
is *not* recommended, but can aid in upgrading.
|
33
|
-
|
34
|
-
* `config.active_record.yaml_column_permitted_classes`
|
35
|
-
|
36
|
-
The "safe YAML" loading method does not allow all classes to be deserialized
|
37
|
-
by default. This option allows you to specify classes deemed "safe" in your
|
38
|
-
application. For example, if your application uses Symbol and Time in
|
39
|
-
serialized data, you can add Symbol and Time to the allowed list as follows:
|
40
|
-
|
41
|
-
```
|
42
|
-
config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time]
|
43
|
-
```
|
11
|
+
For new applications it is set to `[:id]` in config/environment/production.rb.
|
44
12
|
|
45
|
-
|
13
|
+
In the console all the attributes are always shown.
|
46
14
|
|
15
|
+
*Andrew Novoselac*
|
47
16
|
|
48
|
-
|
49
|
-
|
50
|
-
* No changes.
|
51
|
-
|
52
|
-
|
53
|
-
## Rails 6.1.5.1 (April 26, 2022) ##
|
54
|
-
|
55
|
-
* No changes.
|
17
|
+
* `PG::UnableToSend: no connection to the server` is now retryable as a connection-related exception
|
56
18
|
|
19
|
+
*Kazuma Watanabe*
|
57
20
|
|
58
|
-
|
21
|
+
* Fix marshalling of unsaved associated records in 7.1 format.
|
59
22
|
|
60
|
-
|
23
|
+
The 7.1 format would only marshal associated records if the association was loaded.
|
24
|
+
But associations that would only contain unsaved records would be skipped.
|
61
25
|
|
62
|
-
|
63
|
-
In Ruby 2.6, the receiver of the `String#-@` method is modified under certain circumstances.
|
64
|
-
This was later identified as a bug (https://bugs.ruby-lang.org/issues/15926) and only
|
65
|
-
fixed in Ruby 2.7.
|
66
|
-
|
67
|
-
Before the changes in this commit, the
|
68
|
-
`ActiveRecord::ConnectionAdapters::SchemaCache#deep_deduplicate` method, which internally
|
69
|
-
calls the `String#-@` method, could also modify an input string argument in Ruby 2.6 --
|
70
|
-
changing a tainted, unfrozen string into a tainted, frozen string.
|
26
|
+
*Jean Boussier*
|
71
27
|
|
72
|
-
|
28
|
+
* Fix incorrect SQL query when passing an empty hash to `ActiveRecord::Base.insert`.
|
73
29
|
|
74
|
-
*
|
30
|
+
*David Stosik*
|
75
31
|
|
76
|
-
*
|
77
|
-
|
32
|
+
* Allow to save records with polymorphic join tables that have `inverse_of`
|
33
|
+
specified.
|
78
34
|
|
79
|
-
|
80
|
-
bigint instead of integer for the SQLite Adapter.
|
35
|
+
*Markus Doits*
|
81
36
|
|
82
|
-
|
37
|
+
* Fix association scopes applying on the incorrect join when using a polymorphic `has_many through:`.
|
83
38
|
|
84
|
-
*
|
39
|
+
*Joshua Young*
|
85
40
|
|
86
|
-
|
41
|
+
* Fix `dependent: :destroy` for bi-directional has one through association.
|
87
42
|
|
88
|
-
|
43
|
+
Fixes #50948.
|
89
44
|
|
90
45
|
```ruby
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
responsible to detect write queries.
|
96
|
-
|
97
|
-
The query is now properly passed to the database connection, which might or might
|
98
|
-
not be able to handle it, but will either succeed or failed in a more correct way.
|
99
|
-
|
100
|
-
*Jean Boussier*
|
101
|
-
|
102
|
-
* Ignore persisted in-memory records when merging target lists.
|
103
|
-
|
104
|
-
*Kevin Sjöberg*
|
46
|
+
class Left < ActiveRecord::Base
|
47
|
+
has_one :middle, dependent: :destroy
|
48
|
+
has_one :right, through: :middle
|
49
|
+
end
|
105
50
|
|
106
|
-
|
107
|
-
|
51
|
+
class Middle < ActiveRecord::Base
|
52
|
+
belongs_to :left, dependent: :destroy
|
53
|
+
belongs_to :right, dependent: :destroy
|
54
|
+
end
|
108
55
|
|
109
|
-
|
56
|
+
class Right < ActiveRecord::Base
|
57
|
+
has_one :middle, dependent: :destroy
|
58
|
+
has_one :left, through: :middle
|
59
|
+
end
|
60
|
+
```
|
61
|
+
In the above example `left.destroy` wouldn't destroy its associated `Right`
|
62
|
+
record.
|
110
63
|
|
111
|
-
*
|
64
|
+
*Andy Stewart*
|
112
65
|
|
113
|
-
*
|
114
|
-
`config.active_record.record_timestamps = false`
|
66
|
+
* Properly handle lazily pinned connection pools.
|
115
67
|
|
116
|
-
|
117
|
-
various DB management tasks.
|
68
|
+
Fixes #53147.
|
118
69
|
|
119
|
-
|
70
|
+
When using transactional fixtures with system tests to similar tools
|
71
|
+
such as capybara, it could happen that a connection end up pinned by the
|
72
|
+
server thread rather than the test thread, causing
|
73
|
+
`"Cannot expire connection, it is owned by a different thread"` errors.
|
120
74
|
|
121
75
|
*Jean Boussier*
|
122
76
|
|
123
|
-
* Fix
|
124
|
-
|
125
|
-
*Justin Carvalho*
|
126
|
-
|
127
|
-
* Fix duplicate objects stored in has many association after save.
|
128
|
-
|
129
|
-
Fixes #42549.
|
130
|
-
|
131
|
-
*Alex Ghiculescu*
|
77
|
+
* Fix `ActiveRecord::Base.with` to accept more than two sub queries.
|
132
78
|
|
133
|
-
|
79
|
+
Fixes #53110.
|
134
80
|
|
135
|
-
|
81
|
+
```ruby
|
82
|
+
User.with(foo: [User.select(:id), User.select(:id), User.select(:id)]).to_sql
|
83
|
+
undefined method `union' for an instance of Arel::Nodes::UnionAll (NoMethodError)
|
84
|
+
```
|
136
85
|
|
137
|
-
|
86
|
+
The above now works as expected.
|
138
87
|
|
139
88
|
*fatkodima*
|
140
89
|
|
90
|
+
* Properly release pinned connections with non joinable connections.
|
141
91
|
|
142
|
-
|
143
|
-
|
144
|
-
* No changes.
|
145
|
-
|
146
|
-
|
147
|
-
## Rails 6.1.4.6 (February 11, 2022) ##
|
148
|
-
|
149
|
-
* No changes.
|
150
|
-
|
151
|
-
|
152
|
-
## Rails 6.1.4.5 (February 11, 2022) ##
|
153
|
-
|
154
|
-
* No changes.
|
155
|
-
|
156
|
-
|
157
|
-
## Rails 6.1.4.4 (December 15, 2021) ##
|
158
|
-
|
159
|
-
* No changes.
|
160
|
-
|
161
|
-
|
162
|
-
## Rails 6.1.4.3 (December 14, 2021) ##
|
163
|
-
|
164
|
-
* No changes.
|
165
|
-
|
166
|
-
|
167
|
-
## Rails 6.1.4.2 (December 14, 2021) ##
|
168
|
-
|
169
|
-
* No changes.
|
170
|
-
|
171
|
-
|
172
|
-
## Rails 6.1.4.1 (August 19, 2021) ##
|
173
|
-
|
174
|
-
* No changes.
|
175
|
-
|
176
|
-
|
177
|
-
## Rails 6.1.4 (June 24, 2021) ##
|
178
|
-
|
179
|
-
* Do not try to rollback transactions that failed due to a `ActiveRecord::TransactionRollbackError`.
|
92
|
+
Fixes #52973
|
180
93
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
*Eileen M. Uchitelle*
|
186
|
-
|
187
|
-
* Fix compatibility with `psych >= 4`.
|
188
|
-
|
189
|
-
Starting in Psych 4.0.0 `YAML.load` behaves like `YAML.safe_load`. To preserve compatibility
|
190
|
-
Active Record's schema cache loader and `YAMLColumn` now uses `YAML.unsafe_load` if available.
|
94
|
+
When running system tests with transactional fixtures on, it could happen that
|
95
|
+
the connection leased by the Puma thread wouldn't be properly released back to the pool,
|
96
|
+
causing "Cannot expire connection, it is owned by a different thread" errors in later tests.
|
191
97
|
|
192
98
|
*Jean Boussier*
|
193
99
|
|
194
|
-
*
|
195
|
-
|
196
|
-
*Christopher Thornton*
|
197
|
-
|
198
|
-
* Restore connection pools after transactional tests.
|
199
|
-
|
200
|
-
*Eugene Kenny*
|
201
|
-
|
202
|
-
* Change `upsert_all` to fails cleanly for MySQL when `:unique_by` is used.
|
100
|
+
* Make Float distinguish between `float4` and `float8` in PostgreSQL.
|
203
101
|
|
204
|
-
|
102
|
+
Fixes #52742
|
205
103
|
|
206
|
-
*
|
104
|
+
*Ryota Kitazawa*, *Takayuki Nagatomi*
|
207
105
|
|
208
|
-
|
106
|
+
* Fix an issue where `.left_outer_joins` used with multiple associations that have
|
107
|
+
the same child association but different parents does not join all parents.
|
209
108
|
|
210
|
-
|
109
|
+
Previously, using `.left_outer_joins` with the same child association would only join one of the parents.
|
211
110
|
|
212
|
-
|
111
|
+
Now it will correctly join both parents.
|
213
112
|
|
214
|
-
|
215
|
-
`quoted_node` so that PostgreSQL arrays are quoted properly.
|
113
|
+
Fixes #41498.
|
216
114
|
|
217
|
-
*
|
115
|
+
*Garrett Blehm*
|
218
116
|
|
219
|
-
*
|
117
|
+
* Ensure `ActiveRecord::Encryption.config` is always ready before access.
|
220
118
|
|
221
|
-
|
119
|
+
Previously, `ActiveRecord::Encryption` configuration was deferred until `ActiveRecord::Base`
|
120
|
+
was loaded. Therefore, accessing `ActiveRecord::Encryption.config` properties before
|
121
|
+
`ActiveRecord::Base` was loaded would give incorrect results.
|
222
122
|
|
223
|
-
|
123
|
+
`ActiveRecord::Encryption` now has its own loading hook so that its configuration is set as
|
124
|
+
soon as needed.
|
224
125
|
|
225
|
-
|
126
|
+
When `ActiveRecord::Base` is loaded, even lazily, it in turn triggers the loading of
|
127
|
+
`ActiveRecord::Encryption`, thus preserving the original behavior of having its config ready
|
128
|
+
before any use of `ActiveRecord::Base`.
|
226
129
|
|
227
|
-
*
|
228
|
-
|
229
|
-
*Ricardo Díaz*
|
230
|
-
|
231
|
-
* Handle `false` in relation strict loading checks.
|
232
|
-
|
233
|
-
Previously when a model had strict loading set to true and then had a
|
234
|
-
relation set `strict_loading` to false the false wasn't considered when
|
235
|
-
deciding whether to raise/warn about strict loading.
|
236
|
-
|
237
|
-
```
|
238
|
-
class Dog < ActiveRecord::Base
|
239
|
-
self.strict_loading_by_default = true
|
240
|
-
|
241
|
-
has_many :treats, strict_loading: false
|
242
|
-
end
|
243
|
-
```
|
130
|
+
*Maxime Réty*
|
244
131
|
|
245
|
-
|
246
|
-
|
247
|
-
Active Storage which is why I made this PR superseding #41461. We need
|
248
|
-
to fix this for all applications since the behavior is a little
|
249
|
-
surprising. I took the test from #41461 and the code suggestion from #41453
|
250
|
-
with some additions.
|
132
|
+
* Add `TimeZoneConverter#==` method, so objects will be properly compared by
|
133
|
+
their type, scale, limit & precision.
|
251
134
|
|
252
|
-
|
135
|
+
Address #52699.
|
253
136
|
|
254
|
-
*
|
137
|
+
*Ruy Rocha*
|
255
138
|
|
256
|
-
*Ryuta Kamizono*
|
257
139
|
|
258
|
-
|
259
|
-
|
260
|
-
*Ryuta Kamizono*
|
261
|
-
|
262
|
-
* Fix `CREATE INDEX` statement generation for PostgreSQL.
|
263
|
-
|
264
|
-
*eltongo*
|
265
|
-
|
266
|
-
* Fix where clause on enum attribute when providing array of strings.
|
267
|
-
|
268
|
-
*Ryuta Kamizono*
|
269
|
-
|
270
|
-
* Fix `unprepared_statement` to work it when nesting.
|
271
|
-
|
272
|
-
*Ryuta Kamizono*
|
273
|
-
|
274
|
-
|
275
|
-
## Rails 6.1.3.2 (May 05, 2021) ##
|
140
|
+
## Rails 7.2.1.2 (October 23, 2024) ##
|
276
141
|
|
277
142
|
* No changes.
|
278
143
|
|
279
144
|
|
280
|
-
## Rails
|
145
|
+
## Rails 7.2.1.1 (October 15, 2024) ##
|
281
146
|
|
282
147
|
* No changes.
|
283
148
|
|
284
149
|
|
285
|
-
## Rails
|
150
|
+
## Rails 7.2.1 (August 22, 2024) ##
|
286
151
|
|
287
|
-
* Fix
|
288
|
-
to the connection session.
|
152
|
+
* Fix detection for `enum` columns with parallelized tests and PostgreSQL.
|
289
153
|
|
290
154
|
*Rafael Mendonça França*
|
291
155
|
|
292
|
-
*
|
293
|
-
are enabled.
|
156
|
+
* Allow to eager load nested nil associations.
|
294
157
|
|
295
|
-
*
|
158
|
+
*fatkodima*
|
296
159
|
|
297
|
-
* Fix
|
298
|
-
an `IN` clause.
|
160
|
+
* Fix swallowing ignore order warning when batching using `BatchEnumerator`.
|
299
161
|
|
300
|
-
*
|
162
|
+
*fatkodima*
|
301
163
|
|
302
|
-
*
|
303
|
-
with a having clause
|
164
|
+
* Fix memory bloat on the connection pool when using the Fiber `IsolatedExecutionState`.
|
304
165
|
|
305
|
-
|
306
|
-
references an aliased select value would generate an error when
|
307
|
-
#include? was called, due to an optimisation that would generate
|
308
|
-
call #exists? on the relation instead, which effectively alters
|
309
|
-
the select values of the query (and thus removes the aliased select
|
310
|
-
values), but leaves the having clause intact. Because the having
|
311
|
-
clause is then referencing an aliased column that is no longer
|
312
|
-
present in the simplified query, an ActiveRecord::InvalidStatement
|
313
|
-
error was raised.
|
166
|
+
*Jean Boussier*
|
314
167
|
|
315
|
-
|
168
|
+
* Restore inferred association class with the same modularized name.
|
316
169
|
|
317
|
-
|
318
|
-
Author.select('COUNT(*) as total_posts', 'authors.*')
|
319
|
-
.joins(:posts)
|
320
|
-
.group(:id)
|
321
|
-
.having('total_posts > 2')
|
322
|
-
.include?(Author.first)
|
323
|
-
```
|
170
|
+
*Justin Ko*
|
324
171
|
|
325
|
-
|
326
|
-
simplified #exists? query, which simply checks for the presence of
|
327
|
-
a having clause.
|
172
|
+
* Fix `ActiveRecord::Base.inspect` to properly explain how to load schema information.
|
328
173
|
|
329
|
-
|
174
|
+
*Jean Boussier*
|
330
175
|
|
331
|
-
|
176
|
+
* Check invalid `enum` options for the new syntax.
|
332
177
|
|
333
|
-
|
334
|
-
without Rails knowledge (e.g., if app gets kill -9d during long-running query or due to Rack::Timeout), app won't end
|
335
|
-
up in perpetual crash state for being inconsistent with Postgres.
|
178
|
+
The options using `_` prefix in the old syntax are invalid in the new syntax.
|
336
179
|
|
337
|
-
*
|
180
|
+
*Rafael Mendonça França*
|
338
181
|
|
182
|
+
* Fix `ActiveRecord::Encryption::EncryptedAttributeType#type` to return
|
183
|
+
actual cast type.
|
339
184
|
|
340
|
-
|
185
|
+
*Vasiliy Ermolovich*
|
341
186
|
|
342
|
-
* Fix
|
187
|
+
* Fix `create_table` with `:auto_increment` option for MySQL adapter.
|
343
188
|
|
344
|
-
|
345
|
-
for validating the money format in the PostgreSQL adapter. This patch
|
346
|
-
fixes the regexp.
|
189
|
+
*fatkodima*
|
347
190
|
|
348
|
-
Thanks to @dee-see from Hackerone for this patch!
|
349
191
|
|
350
|
-
|
192
|
+
## Rails 7.2.0 (August 09, 2024) ##
|
351
193
|
|
352
|
-
|
194
|
+
* Handle commas in Sqlite3 default function definitions.
|
353
195
|
|
196
|
+
*Stephen Margheim*
|
354
197
|
|
355
|
-
|
198
|
+
* Fixes `validates_associated` raising an exception when configured with a
|
199
|
+
singular association and having `index_nested_attribute_errors` enabled.
|
356
200
|
|
357
|
-
*
|
201
|
+
*Martin Spickermann*
|
358
202
|
|
359
|
-
|
203
|
+
* The constant `ActiveRecord::ImmutableRelation` has been deprecated because
|
204
|
+
we want to reserve that name for a stronger sense of "immutable relation".
|
205
|
+
Please use `ActiveRecord::UnmodifiableRelation` instead.
|
360
206
|
|
361
|
-
*
|
207
|
+
*Xavier Noria*
|
362
208
|
|
363
|
-
|
364
|
-
|
365
|
-
rolledback putting things in a funky state.
|
209
|
+
* Add condensed `#inspect` for `ConnectionPool`, `AbstractAdapter`, and
|
210
|
+
`DatabaseConfig`.
|
366
211
|
|
367
|
-
|
212
|
+
*Hartley McGuire*
|
368
213
|
|
369
|
-
|
214
|
+
* Fixed a memory performance issue in Active Record attribute methods definition.
|
370
215
|
|
371
|
-
*
|
216
|
+
*Jean Boussier*
|
372
217
|
|
373
|
-
|
218
|
+
* Define the new Active Support notification event `start_transaction.active_record`.
|
374
219
|
|
375
|
-
|
376
|
-
|
377
|
-
urls with the "jdbc" prefix were passed to the Active Record Adapter, others
|
378
|
-
are assumed to be adapter specification urls.
|
220
|
+
This event is fired when database transactions or savepoints start, and
|
221
|
+
complements `transaction.active_record`, which is emitted when they finish.
|
379
222
|
|
380
|
-
|
223
|
+
The payload has the transaction (`:transaction`) and the connection (`:connection`).
|
381
224
|
|
382
|
-
*
|
225
|
+
*Xavier Noria*
|
383
226
|
|
384
|
-
* Fix
|
227
|
+
* Fix an issue where the IDs reader method did not return expected results
|
228
|
+
for preloaded associations in models using composite primary keys.
|
385
229
|
|
386
|
-
*
|
230
|
+
*Jay Ang*
|
387
231
|
|
388
|
-
*
|
232
|
+
* The payload of `sql.active_record` Active Support notifications now has the current transaction in the `:transaction` key.
|
389
233
|
|
390
|
-
*
|
234
|
+
*Xavier Noria*
|
391
235
|
|
392
|
-
*
|
236
|
+
* The payload of `transaction.active_record` Active Support notifications now has the transaction the event is related to in the `:transaction` key.
|
393
237
|
|
394
|
-
*
|
238
|
+
*Xavier Noria*
|
395
239
|
|
396
|
-
*
|
240
|
+
* Define `ActiveRecord::Transaction#uuid`, which returns a UUID for the database transaction. This may be helpful when tracing database activity. These UUIDs are generated only on demand.
|
397
241
|
|
398
|
-
*
|
242
|
+
*Xavier Noria*
|
399
243
|
|
400
|
-
* Fix
|
244
|
+
* Fix inference of association model on nested models with the same demodularized name.
|
401
245
|
|
402
|
-
|
246
|
+
E.g. with the following setup:
|
403
247
|
|
248
|
+
```ruby
|
249
|
+
class Nested::Post < ApplicationRecord
|
250
|
+
has_one :post, through: :other
|
251
|
+
end
|
252
|
+
```
|
404
253
|
|
405
|
-
|
254
|
+
Before, `#post` would infer the model as `Nested::Post`, but now it correctly infers `Post`.
|
406
255
|
|
407
|
-
*
|
256
|
+
*Joshua Young*
|
408
257
|
|
409
|
-
|
258
|
+
* PostgreSQL `Cidr#change?` detects the address prefix change.
|
410
259
|
|
411
|
-
*
|
260
|
+
*Taketo Takashima*
|
412
261
|
|
413
|
-
|
262
|
+
* Change `BatchEnumerator#destroy_all` to return the total number of affected rows.
|
414
263
|
|
415
|
-
|
264
|
+
Previously, it always returned `nil`.
|
416
265
|
|
417
|
-
*
|
266
|
+
*fatkodima*
|
418
267
|
|
419
|
-
*
|
268
|
+
* Support `touch_all` in batches.
|
420
269
|
|
421
|
-
|
270
|
+
```ruby
|
271
|
+
Post.in_batches.touch_all
|
272
|
+
```
|
422
273
|
|
423
|
-
*
|
274
|
+
*fatkodima*
|
424
275
|
|
425
|
-
|
276
|
+
* Add support for `:if_not_exists` and `:force` options to `create_schema`.
|
426
277
|
|
427
|
-
*
|
278
|
+
*fatkodima*
|
428
279
|
|
429
|
-
|
280
|
+
* Fix `index_errors` having incorrect index in association validation errors.
|
430
281
|
|
431
|
-
*
|
282
|
+
*lulalala*
|
432
283
|
|
433
|
-
|
284
|
+
* Add `index_errors: :nested_attributes_order` mode.
|
434
285
|
|
435
|
-
|
286
|
+
This indexes the association validation errors based on the order received by nested attributes setter, and respects the `reject_if` configuration. This enables API to provide enough information to the frontend to map the validation errors back to their respective form fields.
|
436
287
|
|
437
|
-
*
|
288
|
+
*lulalala*
|
438
289
|
|
439
|
-
*
|
290
|
+
* Add `Rails.application.config.active_record.postgresql_adapter_decode_dates` to opt out of decoding dates automatically with the postgresql adapter. Defaults to true.
|
440
291
|
|
441
|
-
*
|
292
|
+
*Joé Dupuis*
|
442
293
|
|
443
|
-
*
|
294
|
+
* Association option `query_constraints` is deprecated in favor of `foreign_key`.
|
444
295
|
|
445
|
-
|
446
|
-
to throw an error saying :polymorphic would not be a valid option.
|
296
|
+
*Nikita Vasilevsky*
|
447
297
|
|
448
|
-
|
298
|
+
* Add `ENV["SKIP_TEST_DATABASE_TRUNCATE"]` flag to speed up multi-process test runs on large DBs when all tests run within default transaction.
|
449
299
|
|
450
|
-
|
300
|
+
This cuts ~10s from the test run of HEY when run by 24 processes against the 178 tables, since ~4,000 table truncates can then be skipped.
|
451
301
|
|
452
|
-
|
302
|
+
*DHH*
|
453
303
|
|
454
|
-
|
455
|
-
and the index name should be specified explicitly. Now, the index name is inferred
|
456
|
-
automatically.
|
304
|
+
* Added support for recursive common table expressions.
|
457
305
|
|
458
306
|
```ruby
|
459
|
-
|
307
|
+
Post.with_recursive(
|
308
|
+
post_and_replies: [
|
309
|
+
Post.where(id: 42),
|
310
|
+
Post.joins('JOIN post_and_replies ON posts.in_reply_to_id = post_and_replies.id'),
|
311
|
+
]
|
312
|
+
)
|
460
313
|
```
|
461
314
|
|
462
|
-
|
315
|
+
Generates the following SQL:
|
463
316
|
|
317
|
+
```sql
|
318
|
+
WITH RECURSIVE "post_and_replies" AS (
|
319
|
+
(SELECT "posts".* FROM "posts" WHERE "posts"."id" = 42)
|
320
|
+
UNION ALL
|
321
|
+
(SELECT "posts".* FROM "posts" JOIN post_and_replies ON posts.in_reply_to_id = post_and_replies.id)
|
322
|
+
)
|
323
|
+
SELECT "posts".* FROM "posts"
|
324
|
+
```
|
464
325
|
|
465
|
-
|
466
|
-
|
467
|
-
* Only warn about negative enums if a positive form that would cause conflicts exists.
|
468
|
-
|
469
|
-
Fixes #39065.
|
470
|
-
|
471
|
-
*Alex Ghiculescu*
|
472
|
-
|
473
|
-
* Change `attribute_for_inspect` to take `filter_attributes` in consideration.
|
474
|
-
|
475
|
-
*Rafael Mendonça França*
|
476
|
-
|
477
|
-
* Fix odd behavior of inverse_of with multiple belongs_to to same class.
|
478
|
-
|
479
|
-
Fixes #35204.
|
480
|
-
|
481
|
-
*Tomoyuki Kai*
|
326
|
+
*ClearlyClaire*
|
482
327
|
|
483
|
-
*
|
328
|
+
* `validate_constraint` can be called in a `change_table` block.
|
484
329
|
|
330
|
+
ex:
|
485
331
|
```ruby
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
def initialize(author)
|
490
|
-
@author = author
|
491
|
-
end
|
332
|
+
change_table :products do |t|
|
333
|
+
t.check_constraint "price > discounted_price", name: "price_check", validate: false
|
334
|
+
t.validate_check_constraint "price_check"
|
492
335
|
end
|
493
|
-
|
494
|
-
Post.where(author: AdminAuthor.new(author))
|
495
336
|
```
|
496
337
|
|
497
|
-
*
|
498
|
-
|
499
|
-
* Add `connected_to_many` API.
|
338
|
+
*Cody Cutrer*
|
500
339
|
|
501
|
-
|
340
|
+
* `PostgreSQLAdapter` now decodes columns of type date to `Date` instead of string.
|
502
341
|
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
Dinner.first # read from meals replica
|
509
|
-
Person.first # read from primary writer
|
510
|
-
end
|
511
|
-
end
|
512
|
-
|
513
|
-
After:
|
514
|
-
|
515
|
-
ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do
|
516
|
-
Dog.first # read from animals replica
|
517
|
-
Dinner.first # read from meals replica
|
518
|
-
Person.first # read from primary writer
|
519
|
-
end
|
520
|
-
|
521
|
-
*Eileen M. Uchitelle*, *John Crepezzi*
|
522
|
-
|
523
|
-
* Add option to raise or log for `ActiveRecord::StrictLoadingViolationError`.
|
524
|
-
|
525
|
-
Some applications may not want to raise an error in production if using `strict_loading`. This would allow an application to set strict loading to log for the production environment while still raising in development and test environments.
|
526
|
-
|
527
|
-
Set `config.active_record.action_on_strict_loading_violation` to `:log` errors instead of raising.
|
528
|
-
|
529
|
-
*Eileen M. Uchitelle*
|
530
|
-
|
531
|
-
* Allow the inverse of a `has_one` association that was previously autosaved to be loaded.
|
532
|
-
|
533
|
-
Fixes #34255.
|
534
|
-
|
535
|
-
*Steven Weber*
|
536
|
-
|
537
|
-
* Optimise the length of index names for polymorphic references by using the reference name rather than the type and id column names.
|
538
|
-
|
539
|
-
Because the default behaviour when adding an index with multiple columns is to use all column names in the index name, this could frequently lead to overly long index names for polymorphic references which would fail the migration if it exceeded the database limit.
|
540
|
-
|
541
|
-
This change reduces the chance of that happening by using the reference name, e.g. `index_my_table_on_my_reference`.
|
542
|
-
|
543
|
-
Fixes #38655.
|
544
|
-
|
545
|
-
*Luke Redpath*
|
546
|
-
|
547
|
-
* MySQL: Uniqueness validator now respects default database collation,
|
548
|
-
no longer enforce case sensitive comparison by default.
|
549
|
-
|
550
|
-
*Ryuta Kamizono*
|
551
|
-
|
552
|
-
* Remove deprecated methods from `ActiveRecord::ConnectionAdapters::DatabaseLimits`.
|
553
|
-
|
554
|
-
`column_name_length`
|
555
|
-
`table_name_length`
|
556
|
-
`columns_per_table`
|
557
|
-
`indexes_per_table`
|
558
|
-
`columns_per_multicolumn_index`
|
559
|
-
`sql_query_length`
|
560
|
-
`joins_per_query`
|
561
|
-
|
562
|
-
*Rafael Mendonça França*
|
563
|
-
|
564
|
-
* Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_multi_insert?`.
|
565
|
-
|
566
|
-
*Rafael Mendonça França*
|
567
|
-
|
568
|
-
* Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_foreign_keys_in_create?`.
|
569
|
-
|
570
|
-
*Rafael Mendonça França*
|
571
|
-
|
572
|
-
* Remove deprecated `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#supports_ranges?`.
|
573
|
-
|
574
|
-
*Rafael Mendonça França*
|
575
|
-
|
576
|
-
* Remove deprecated `ActiveRecord::Base#update_attributes` and `ActiveRecord::Base#update_attributes!`.
|
577
|
-
|
578
|
-
*Rafael Mendonça França*
|
579
|
-
|
580
|
-
* Remove deprecated `migrations_path` argument in `ActiveRecord::ConnectionAdapter::SchemaStatements#assume_migrated_upto_version`.
|
581
|
-
|
582
|
-
*Rafael Mendonça França*
|
583
|
-
|
584
|
-
* Remove deprecated `config.active_record.sqlite3.represent_boolean_as_integer`.
|
585
|
-
|
586
|
-
*Rafael Mendonça França*
|
587
|
-
|
588
|
-
* `relation.create` does no longer leak scope to class level querying methods
|
589
|
-
in initialization block and callbacks.
|
590
|
-
|
591
|
-
Before:
|
592
|
-
|
593
|
-
User.where(name: "John").create do |john|
|
594
|
-
User.find_by(name: "David") # => nil
|
595
|
-
end
|
596
|
-
|
597
|
-
After:
|
342
|
+
Ex:
|
343
|
+
```ruby
|
344
|
+
ActiveRecord::Base.connection
|
345
|
+
.select_value("select '2024-01-01'::date").class #=> Date
|
346
|
+
```
|
598
347
|
|
599
|
-
|
600
|
-
User.find_by(name: "David") # => #<User name: "David", ...>
|
601
|
-
end
|
348
|
+
*Joé Dupuis*
|
602
349
|
|
603
|
-
|
350
|
+
* Strict loading using `:n_plus_one_only` does not eagerly load child associations.
|
604
351
|
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
352
|
+
With this change, child associations are no longer eagerly loaded, to
|
353
|
+
match intended behavior and to prevent non-deterministic order issues caused
|
354
|
+
by calling methods like `first` or `last`. As `first` and `last` don't cause
|
355
|
+
an N+1 by themselves, calling child associations will no longer raise.
|
356
|
+
Fixes #49473.
|
610
357
|
|
611
358
|
Before:
|
612
359
|
|
613
|
-
|
614
|
-
|
360
|
+
```ruby
|
361
|
+
person = Person.find(1)
|
362
|
+
person.strict_loading!(mode: :n_plus_one_only)
|
363
|
+
person.posts.first
|
364
|
+
# SELECT * FROM posts WHERE person_id = 1; -- non-deterministic order
|
365
|
+
person.posts.first.firm # raises ActiveRecord::StrictLoadingViolationError
|
366
|
+
```
|
615
367
|
|
616
368
|
After:
|
617
369
|
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
`fetch`
|
626
|
-
`each`
|
627
|
-
`first`
|
628
|
-
`values`
|
629
|
-
`[]=`
|
630
|
-
|
631
|
-
*Rafael Mendonça França*
|
632
|
-
|
633
|
-
* `where.not` now generates NAND predicates instead of NOR.
|
634
|
-
|
635
|
-
Before:
|
636
|
-
|
637
|
-
User.where.not(name: "Jon", role: "admin")
|
638
|
-
# SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
|
639
|
-
|
640
|
-
After:
|
641
|
-
|
642
|
-
User.where.not(name: "Jon", role: "admin")
|
643
|
-
# SELECT * FROM users WHERE NOT (name == 'Jon' AND role == 'admin')
|
644
|
-
|
645
|
-
*Rafael Mendonça França*
|
646
|
-
|
647
|
-
* Remove deprecated `ActiveRecord::Result#to_hash` method.
|
370
|
+
```ruby
|
371
|
+
person = Person.find(1)
|
372
|
+
person.strict_loading!(mode: :n_plus_one_only)
|
373
|
+
person.posts.first # this is 1+1, not N+1
|
374
|
+
# SELECT * FROM posts WHERE person_id = 1 ORDER BY id LIMIT 1;
|
375
|
+
person.posts.first.firm # no longer raises
|
376
|
+
```
|
648
377
|
|
649
|
-
*
|
378
|
+
*Reid Lynch*
|
650
379
|
|
651
|
-
*
|
380
|
+
* Allow `Sqlite3Adapter` to use `sqlite3` gem version `2.x`.
|
652
381
|
|
653
|
-
*
|
382
|
+
*Mike Dalessio*
|
654
383
|
|
655
|
-
*
|
384
|
+
* Allow `ActiveRecord::Base#pluck` to accept hash values.
|
656
385
|
|
657
|
-
|
386
|
+
```ruby
|
387
|
+
# Before
|
388
|
+
Post.joins(:comments).pluck("posts.id", "comments.id", "comments.body")
|
658
389
|
|
659
|
-
|
660
|
-
|
390
|
+
# After
|
391
|
+
Post.joins(:comments).pluck(posts: [:id], comments: [:id, :body])
|
392
|
+
```
|
661
393
|
|
662
|
-
*
|
394
|
+
*fatkodima*
|
663
395
|
|
664
|
-
*
|
396
|
+
* Raise an `ActiveRecord::ActiveRecordError` error when the MySQL database returns an invalid version string.
|
665
397
|
|
666
|
-
|
398
|
+
*Kevin McPhillips*
|
667
399
|
|
668
|
-
|
400
|
+
* `ActiveRecord::Base.transaction` now yields an `ActiveRecord::Transaction` object.
|
669
401
|
|
670
|
-
|
402
|
+
This allows to register callbacks on it.
|
671
403
|
|
672
404
|
```ruby
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
AnimalsRecord.connected_to(role: :writing, shard: :one) do
|
678
|
-
User.first # reads from default replica
|
679
|
-
Dog.first # reads from shard one primary
|
680
|
-
end
|
681
|
-
|
682
|
-
User.first # reads from default replica
|
683
|
-
Dog.first # reads from default replica
|
684
|
-
|
685
|
-
ApplicationRecord.connected_to(role: :writing, shard: :two) do
|
686
|
-
User.first # reads from shard two primary
|
687
|
-
Dog.first # reads from default replica
|
405
|
+
Article.transaction do |transaction|
|
406
|
+
article.update(published: true)
|
407
|
+
transaction.after_commit do
|
408
|
+
PublishNotificationMailer.with(article: article).deliver_later
|
688
409
|
end
|
689
410
|
end
|
690
411
|
```
|
691
412
|
|
692
|
-
*
|
693
|
-
|
694
|
-
* Allow double-dash comment syntax when querying read-only databases
|
695
|
-
|
696
|
-
*James Adam*
|
413
|
+
*Jean Boussier*
|
697
414
|
|
698
|
-
* Add `
|
415
|
+
* Add `ActiveRecord::Base.current_transaction`.
|
699
416
|
|
700
|
-
Returns
|
417
|
+
Returns the current transaction, to allow registering callbacks on it.
|
701
418
|
|
702
419
|
```ruby
|
703
|
-
|
704
|
-
|
705
|
-
|
420
|
+
Article.current_transaction.after_commit do
|
421
|
+
PublishNotificationMailer.with(article: article).deliver_later
|
422
|
+
end
|
706
423
|
```
|
707
424
|
|
708
|
-
|
709
|
-
|
710
|
-
*Guillaume Briday*
|
711
|
-
|
712
|
-
* Fix `read_attribute_before_type_cast` to consider attribute aliases.
|
425
|
+
*Jean Boussier*
|
713
426
|
|
714
|
-
|
427
|
+
* Add `ActiveRecord.after_all_transactions_commit` callback.
|
715
428
|
|
716
|
-
|
429
|
+
Useful for code that may run either inside or outside a transaction and needs
|
430
|
+
to perform work after the state changes have been properly persisted.
|
717
431
|
|
718
432
|
```ruby
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
433
|
+
def publish_article(article)
|
434
|
+
article.update(published: true)
|
435
|
+
ActiveRecord.after_all_transactions_commit do
|
436
|
+
PublishNotificationMailer.with(article: article).deliver_later
|
437
|
+
end
|
724
438
|
end
|
725
439
|
```
|
726
440
|
|
727
|
-
|
441
|
+
In the above example, the block is either executed immediately if called outside
|
442
|
+
of a transaction, or called after the open transaction is committed.
|
728
443
|
|
729
|
-
|
730
|
-
total number of rows affected, just like their non-batched counterparts.
|
444
|
+
If the transaction is rolled back, the block isn't called.
|
731
445
|
|
732
|
-
|
733
|
-
Person.in_batches.update_all("first_name = 'Eugene'") # => 42
|
734
|
-
Person.in_batches.delete_all # => 42
|
735
|
-
```
|
736
|
-
|
737
|
-
Fixes #40287.
|
738
|
-
|
739
|
-
*Eugene Kenny*
|
740
|
-
|
741
|
-
* Add support for PostgreSQL `interval` data type with conversion to
|
742
|
-
`ActiveSupport::Duration` when loading records from database and
|
743
|
-
serialization to ISO 8601 formatted duration string on save.
|
744
|
-
Add support to define a column in migrations and get it in a schema dump.
|
745
|
-
Optional column precision is supported.
|
746
|
-
|
747
|
-
To use this in 6.1, you need to place the next string to your model file:
|
748
|
-
|
749
|
-
attribute :duration, :interval
|
750
|
-
|
751
|
-
To keep old behavior until 7.0 is released:
|
752
|
-
|
753
|
-
attribute :duration, :string
|
754
|
-
|
755
|
-
Example:
|
756
|
-
|
757
|
-
create_table :events do |t|
|
758
|
-
t.string :name
|
759
|
-
t.interval :duration
|
760
|
-
end
|
761
|
-
|
762
|
-
class Event < ApplicationRecord
|
763
|
-
attribute :duration, :interval
|
764
|
-
end
|
446
|
+
*Jean Boussier*
|
765
447
|
|
766
|
-
|
767
|
-
Event.last.duration # => 2 days
|
768
|
-
Event.last.duration.iso8601 # => "P2D"
|
769
|
-
Event.new(duration: 'P1DT12H3S').duration # => 1 day, 12 hours, and 3 seconds
|
770
|
-
Event.new(duration: '1 day') # Unknown value will be ignored and NULL will be written to database
|
448
|
+
* Add the ability to ignore counter cache columns until they are backfilled.
|
771
449
|
|
772
|
-
|
450
|
+
Starting to use counter caches on existing large tables can be troublesome, because the column
|
451
|
+
values must be backfilled separately of the column addition (to not lock the table for too long)
|
452
|
+
and before the use of `:counter_cache` (otherwise methods like `size`/`any?`/etc, which use
|
453
|
+
counter caches internally, can produce incorrect results). People usually use database triggers
|
454
|
+
or callbacks on child associations while backfilling before introducing a counter cache
|
455
|
+
configuration to the association.
|
773
456
|
|
774
|
-
|
457
|
+
Now, to safely backfill the column, while keeping the column updated with child records added/removed, use:
|
775
458
|
|
776
459
|
```ruby
|
777
|
-
class
|
778
|
-
|
460
|
+
class Comment < ApplicationRecord
|
461
|
+
belongs_to :post, counter_cache: { active: false }
|
779
462
|
end
|
780
463
|
```
|
781
464
|
|
782
|
-
|
465
|
+
While the counter cache is not "active", the methods like `size`/`any?`/etc will not use it,
|
466
|
+
but get the results directly from the database. After the counter cache column is backfilled, simply
|
467
|
+
remove the `{ active: false }` part from the counter cache definition, and it will now be used by the
|
468
|
+
mentioned methods.
|
783
469
|
|
784
|
-
*
|
470
|
+
*fatkodima*
|
785
471
|
|
786
|
-
*
|
472
|
+
* Retry known idempotent SELECT queries on connection-related exceptions.
|
787
473
|
|
788
|
-
|
474
|
+
SELECT queries we construct by walking the Arel tree and / or with known model attributes
|
475
|
+
are idempotent and can safely be retried in the case of a connection error. Previously,
|
476
|
+
adapters such as `TrilogyAdapter` would raise `ActiveRecord::ConnectionFailed: Trilogy::EOFError`
|
477
|
+
when encountering a connection error mid-request.
|
789
478
|
|
790
|
-
*
|
479
|
+
*Adrianna Chang*
|
791
480
|
|
792
|
-
|
481
|
+
* Allow association's `foreign_key` to be composite.
|
793
482
|
|
794
|
-
|
483
|
+
`query_constraints` option was the only way to configure a composite foreign key by passing an `Array`.
|
484
|
+
Now it's possible to pass an Array value as `foreign_key` to achieve the same behavior of an association.
|
795
485
|
|
796
|
-
*
|
797
|
-
`ActiveRecord::StatementInvalid` when they encounter a connection error.
|
486
|
+
*Nikita Vasilevsky*
|
798
487
|
|
799
|
-
|
488
|
+
* Allow association's `primary_key` to be composite.
|
800
489
|
|
801
|
-
|
802
|
-
|
490
|
+
Association's `primary_key` can be composite when derived from associated model `primary_key` or `query_constraints`.
|
491
|
+
Now it's possible to explicitly set it as composite on the association.
|
803
492
|
|
804
|
-
*
|
493
|
+
*Nikita Vasilevsky*
|
805
494
|
|
806
|
-
* Add
|
495
|
+
* Add `config.active_record.permanent_connection_checkout` setting.
|
807
496
|
|
808
|
-
|
497
|
+
Controls whether `ActiveRecord::Base.connection` raises an error, emits a deprecation warning, or neither.
|
809
498
|
|
810
|
-
|
499
|
+
`ActiveRecord::Base.connection` checkouts a database connection from the pool and keeps it leased until the end of
|
500
|
+
the request or job. This behavior can be undesirable in environments that use many more threads or fibers than there
|
501
|
+
is available connections.
|
811
502
|
|
812
|
-
|
503
|
+
This configuration can be used to track down and eliminate code that calls `ActiveRecord::Base.connection` and
|
504
|
+
migrate it to use `ActiveRecord::Base.with_connection` instead.
|
813
505
|
|
814
|
-
|
506
|
+
The default behavior remains unchanged, and there is currently no plans to change the default.
|
815
507
|
|
816
|
-
*
|
508
|
+
*Jean Boussier*
|
817
509
|
|
818
|
-
|
819
|
-
class Comment < ActiveRecord::Base
|
820
|
-
enum label: [:default, :child]
|
821
|
-
has_many :children, class_name: "Comment", foreign_key: :parent_id
|
822
|
-
end
|
510
|
+
* Add dirties option to uncached.
|
823
511
|
|
824
|
-
|
825
|
-
|
826
|
-
```
|
512
|
+
This adds a `dirties` option to `ActiveRecord::Base.uncached` and
|
513
|
+
`ActiveRecord::ConnectionAdapters::ConnectionPool#uncached`.
|
827
514
|
|
828
|
-
|
515
|
+
When set to `true` (the default), writes will clear all query caches belonging to the current thread.
|
516
|
+
When set to `false`, writes to the affected connection pool will not clear any query cache.
|
829
517
|
|
830
|
-
|
518
|
+
This is needed by Solid Cache so that cache writes do not clear query caches.
|
831
519
|
|
832
|
-
|
833
|
-
by `store_full_sti_class` class attribute.
|
520
|
+
*Donal McBreen*
|
834
521
|
|
835
|
-
|
522
|
+
* Deprecate `ActiveRecord::Base.connection` in favor of `.lease_connection`.
|
836
523
|
|
837
|
-
|
524
|
+
The method has been renamed as `lease_connection` to better reflect that the returned
|
525
|
+
connection will be held for the duration of the request or job.
|
838
526
|
|
839
|
-
|
840
|
-
|
841
|
-
depending on `config.active_record.schema_format` configuration value.
|
527
|
+
This deprecation is a soft deprecation, no warnings will be issued and there is no
|
528
|
+
current plan to remove the method.
|
842
529
|
|
843
|
-
*
|
530
|
+
*Jean Boussier*
|
844
531
|
|
845
|
-
*
|
532
|
+
* Deprecate `ActiveRecord::ConnectionAdapters::ConnectionPool#connection`.
|
846
533
|
|
847
|
-
|
848
|
-
|
849
|
-
post.title # => "WELCOME TO THE WEBLOG"
|
850
|
-
post.body # => ActiveModel::MissingAttributeError
|
851
|
-
|
852
|
-
# Rails 6.0 (ignore the `select` values)
|
853
|
-
post = Post.select("UPPER(title) AS title").eager_load(:comments).first
|
854
|
-
post.title # => "Welcome to the weblog"
|
855
|
-
post.body # => "Such a lovely day"
|
856
|
-
|
857
|
-
# Rails 6.1 (respect the `select` values)
|
858
|
-
post = Post.select("UPPER(title) AS title").eager_load(:comments).first
|
859
|
-
post.title # => "WELCOME TO THE WEBLOG"
|
860
|
-
post.body # => ActiveModel::MissingAttributeError
|
861
|
-
```
|
534
|
+
The method has been renamed as `lease_connection` to better reflect that the returned
|
535
|
+
connection will be held for the duration of the request or job.
|
862
536
|
|
863
|
-
*
|
537
|
+
*Jean Boussier*
|
864
538
|
|
865
|
-
*
|
539
|
+
* Expose a generic fixture accessor for fixture names that may conflict with Minitest.
|
866
540
|
|
867
541
|
```ruby
|
868
|
-
|
869
|
-
|
870
|
-
end
|
871
|
-
|
872
|
-
# Rails 6.0
|
873
|
-
Post.type_for_attribute(:written_at) # => #<Type::Value ... precision: nil, ...>
|
874
|
-
|
875
|
-
# Rails 6.1
|
876
|
-
Post.type_for_attribute(:written_at) # => #<Type::DateTime ... precision: 6, ...>
|
542
|
+
assert_equal "Ruby on Rails", web_sites(:rubyonrails).name
|
543
|
+
assert_equal "Ruby on Rails", fixture(:web_sites, :rubyonrails).name
|
877
544
|
```
|
878
545
|
|
879
|
-
*
|
546
|
+
*Jean Boussier*
|
880
547
|
|
881
|
-
*
|
548
|
+
* Using `Model.query_constraints` with a single non-primary-key column used to raise as expected, but with an
|
549
|
+
incorrect error message.
|
882
550
|
|
883
|
-
|
884
|
-
class Book < ActiveRecord::Base
|
885
|
-
enum status: [:proposed, :written, :published], _default: :published
|
886
|
-
end
|
551
|
+
This has been fixed to raise with a more appropriate error message.
|
887
552
|
|
888
|
-
|
889
|
-
```
|
553
|
+
*Joshua Young*
|
890
554
|
|
891
|
-
|
555
|
+
* Fix `has_one` association autosave setting the foreign key attribute when it is unchanged.
|
892
556
|
|
893
|
-
|
557
|
+
This behavior is also inconsistent with autosaving `belongs_to` and can have unintended side effects like raising
|
558
|
+
an `ActiveRecord::ReadonlyAttributeError` when the foreign key attribute is marked as read-only.
|
894
559
|
|
895
|
-
*
|
560
|
+
*Joshua Young*
|
896
561
|
|
897
|
-
*
|
898
|
-
allows you to specify that all string columns should be frozen unless
|
899
|
-
otherwise specified. This will reduce memory pressure for applications which
|
900
|
-
do not generally mutate string properties of Active Record objects.
|
562
|
+
* Remove deprecated behavior that would rollback a transaction block when exited using `return`, `break` or `throw`.
|
901
563
|
|
902
|
-
*
|
564
|
+
*Rafael Mendonça França*
|
903
565
|
|
904
|
-
* Deprecate `
|
566
|
+
* Deprecate `Rails.application.config.active_record.commit_transaction_on_non_local_return`.
|
905
567
|
|
906
|
-
*
|
568
|
+
*Rafael Mendonça França*
|
907
569
|
|
908
|
-
*
|
570
|
+
* Remove deprecated support to pass `rewhere` to `ActiveRecord::Relation#merge`.
|
909
571
|
|
910
|
-
|
911
|
-
david_and_mary = Author.where(id: [david, mary])
|
912
|
-
mary_and_bob = Author.where(id: [mary, bob])
|
572
|
+
*Rafael Mendonça França*
|
913
573
|
|
914
|
-
|
574
|
+
* Remove deprecated support to pass `deferrable: true` to `add_foreign_key`.
|
915
575
|
|
916
|
-
|
917
|
-
david_and_mary.or(mary_and_bob) # => [david, mary, bob]
|
918
|
-
```
|
576
|
+
*Rafael Mendonça França*
|
919
577
|
|
920
|
-
|
578
|
+
* Remove deprecated support to quote `ActiveSupport::Duration`.
|
921
579
|
|
922
|
-
*
|
923
|
-
and will be consistently replaced by the latter condition in Rails 7.0.
|
924
|
-
To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`.
|
580
|
+
*Rafael Mendonça França*
|
925
581
|
|
926
|
-
|
927
|
-
# Rails 6.1 (IN clause is replaced by merger side equality condition)
|
928
|
-
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
|
582
|
+
* Remove deprecated `#quote_bound_value`.
|
929
583
|
|
930
|
-
|
931
|
-
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
|
584
|
+
*Rafael Mendonça França*
|
932
585
|
|
933
|
-
|
934
|
-
Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob]
|
586
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::ConnectionPool#connection_klass`.
|
935
587
|
|
936
|
-
|
937
|
-
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
|
938
|
-
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]
|
939
|
-
```
|
588
|
+
*Rafael Mendonça França*
|
940
589
|
|
941
|
-
|
590
|
+
* Remove deprecated support to apply `#connection_pool_list`, `#active_connections?`, `#clear_active_connections!`,
|
591
|
+
`#clear_reloadable_connections!`, `#clear_all_connections!` and `#flush_idle_connections!` to the connections pools
|
592
|
+
for the current role when the `role` argument isn't provided.
|
942
593
|
|
943
|
-
*
|
594
|
+
*Rafael Mendonça França*
|
944
595
|
|
945
|
-
|
596
|
+
* Remove deprecated `#all_connection_pools`.
|
946
597
|
|
947
|
-
*
|
598
|
+
*Rafael Mendonça França*
|
948
599
|
|
949
|
-
|
950
|
-
`ActiveRecord::Persistence.upsert_all` was used with the name of an expression index, an error
|
951
|
-
was raised. Adding a guard around the formatting behavior for the `:unique_by` corrects this.
|
600
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::SchemaCache#data_sources`.
|
952
601
|
|
953
|
-
|
602
|
+
*Rafael Mendonça França*
|
954
603
|
|
955
|
-
|
956
|
-
create_table :books, id: :integer, force: true do |t|
|
957
|
-
t.column :name, :string
|
958
|
-
t.index "lower(name)", unique: true
|
959
|
-
end
|
604
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::SchemaCache.load_from`.
|
960
605
|
|
961
|
-
|
962
|
-
```
|
606
|
+
*Rafael Mendonça França*
|
963
607
|
|
964
|
-
|
608
|
+
* Remove deprecated `#all_foreign_keys_valid?` from database adapters.
|
965
609
|
|
966
|
-
*
|
610
|
+
*Rafael Mendonça França*
|
967
611
|
|
968
|
-
*
|
612
|
+
* Remove deprecated support to passing coder and class as second argument to `serialize`.
|
969
613
|
|
970
|
-
|
614
|
+
*Rafael Mendonça França*
|
971
615
|
|
972
|
-
|
973
|
-
add_check_constraint :products, "price > 0", name: "price_check"
|
974
|
-
remove_check_constraint :products, name: "price_check"
|
975
|
-
```
|
616
|
+
* Remove deprecated support to `ActiveRecord::Base#read_attribute(:id)` to return the custom primary key value.
|
976
617
|
|
977
|
-
*
|
618
|
+
*Rafael Mendonça França*
|
978
619
|
|
979
|
-
*
|
980
|
-
to enable/disable strict_loading mode by default for a model. The configuration's value is
|
981
|
-
inheritable by subclasses, but they can override that value and it will not impact parent class.
|
620
|
+
* Remove deprecated `TestFixtures.fixture_path`.
|
982
621
|
|
983
|
-
|
622
|
+
*Rafael Mendonça França*
|
984
623
|
|
985
|
-
|
986
|
-
class Developer < ApplicationRecord
|
987
|
-
self.strict_loading_by_default = true
|
624
|
+
* Remove deprecated behavior to support referring to a singular association by its plural name.
|
988
625
|
|
989
|
-
|
990
|
-
end
|
626
|
+
*Rafael Mendonça França*
|
991
627
|
|
992
|
-
|
993
|
-
dev.projects.first
|
994
|
-
# => ActiveRecord::StrictLoadingViolationError Exception: Developer is marked as strict_loading and Project cannot be lazily loaded.
|
995
|
-
```
|
628
|
+
* Deprecate `Rails.application.config.active_record.allow_deprecated_singular_associations_name`.
|
996
629
|
|
997
|
-
*
|
630
|
+
*Rafael Mendonça França*
|
998
631
|
|
999
|
-
*
|
632
|
+
* Remove deprecated support to passing `SchemaMigration` and `InternalMetadata` classes as arguments to
|
633
|
+
`ActiveRecord::MigrationContext`.
|
1000
634
|
|
1001
|
-
*
|
635
|
+
*Rafael Mendonça França*
|
1002
636
|
|
1003
|
-
*
|
637
|
+
* Remove deprecated `ActiveRecord::Migration.check_pending!` method.
|
1004
638
|
|
1005
|
-
|
639
|
+
*Rafael Mendonça França*
|
1006
640
|
|
1007
|
-
|
1008
|
-
create_table "accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
|
1009
|
-
end
|
1010
|
-
```
|
641
|
+
* Remove deprecated `ActiveRecord::LogSubscriber.runtime` method.
|
1011
642
|
|
1012
|
-
|
643
|
+
*Rafael Mendonça França*
|
1013
644
|
|
1014
|
-
|
1015
|
-
create_table "accounts", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
1016
|
-
end
|
1017
|
-
```
|
645
|
+
* Remove deprecated `ActiveRecord::LogSubscriber.runtime=` method.
|
1018
646
|
|
1019
|
-
*
|
647
|
+
*Rafael Mendonça França*
|
1020
648
|
|
1021
|
-
*
|
1022
|
-
See ActiveRecord::DelegatedType for the full description.
|
649
|
+
* Remove deprecated `ActiveRecord::LogSubscriber.reset_runtime` method.
|
1023
650
|
|
1024
|
-
*
|
651
|
+
*Rafael Mendonça França*
|
1025
652
|
|
1026
|
-
*
|
653
|
+
* Remove deprecated support to define `explain` in the connection adapter with 2 arguments.
|
1027
654
|
|
1028
|
-
|
655
|
+
*Rafael Mendonça França*
|
1029
656
|
|
1030
|
-
|
1031
|
-
accounts = Account.group(:firm_id)
|
1032
|
-
|
1033
|
-
# duplicated group fields, deprecated.
|
1034
|
-
accounts.merge(accounts.where.not(credit_limit: nil)).sum(:credit_limit)
|
1035
|
-
# => {
|
1036
|
-
# [1, 1] => 50,
|
1037
|
-
# [2, 2] => 60
|
1038
|
-
# }
|
1039
|
-
|
1040
|
-
# use `uniq!(:group)` to deduplicate group fields.
|
1041
|
-
accounts.merge(accounts.where.not(credit_limit: nil)).uniq!(:group).sum(:credit_limit)
|
1042
|
-
# => {
|
1043
|
-
# 1 => 50,
|
1044
|
-
# 2 => 60
|
1045
|
-
# }
|
1046
|
-
```
|
657
|
+
* Remove deprecated `ActiveRecord::ActiveJobRequiredError`.
|
1047
658
|
|
1048
|
-
*
|
659
|
+
*Rafael Mendonça França*
|
1049
660
|
|
1050
|
-
*
|
661
|
+
* Remove deprecated `ActiveRecord::Base.clear_active_connections!`.
|
1051
662
|
|
1052
|
-
|
663
|
+
*Rafael Mendonça França*
|
1053
664
|
|
1054
|
-
|
1055
|
-
accounts = Account.where(id: [1, 2]).annotate("david and mary")
|
665
|
+
* Remove deprecated `ActiveRecord::Base.clear_reloadable_connections!`.
|
1056
666
|
|
1057
|
-
|
1058
|
-
accounts.merge(accounts.rewhere(id: 3))
|
1059
|
-
# SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */ /* david and mary */
|
667
|
+
*Rafael Mendonça França*
|
1060
668
|
|
1061
|
-
|
1062
|
-
accounts.merge(accounts.rewhere(id: 3)).uniq!(:annotate)
|
1063
|
-
# SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */
|
1064
|
-
```
|
669
|
+
* Remove deprecated `ActiveRecord::Base.clear_all_connections!`.
|
1065
670
|
|
1066
|
-
*
|
671
|
+
*Rafael Mendonça França*
|
1067
672
|
|
1068
|
-
*
|
673
|
+
* Remove deprecated `ActiveRecord::Base.flush_idle_connections!`.
|
1069
674
|
|
1070
|
-
|
1071
|
-
cache. This avoids raising an unnecessary `ActiveRecord::StaleObjectError`
|
1072
|
-
upon subsequent transactions by maintaining parity with the corresponding
|
1073
|
-
database record's `lock_version` column.
|
675
|
+
*Rafael Mendonça França*
|
1074
676
|
|
1075
|
-
|
677
|
+
* Remove deprecated `name` argument from `ActiveRecord::Base.remove_connection`.
|
1076
678
|
|
1077
|
-
*
|
679
|
+
*Rafael Mendonça França*
|
1078
680
|
|
1079
|
-
*
|
681
|
+
* Remove deprecated support to call `alias_attribute` with non-existent attribute names.
|
1080
682
|
|
1081
|
-
|
1082
|
-
david_and_mary = Author.where(id: david.id..mary.id)
|
683
|
+
*Rafael Mendonça França*
|
1083
684
|
|
1084
|
-
|
1085
|
-
david_and_mary.merge(Author.where(id: bob)) # => []
|
685
|
+
* Remove deprecated `Rails.application.config.active_record.suppress_multiple_database_warning`.
|
1086
686
|
|
1087
|
-
|
1088
|
-
david_and_mary.merge(Author.rewhere(id: bob)) # => [bob]
|
687
|
+
*Rafael Mendonça França*
|
1089
688
|
|
1090
|
-
|
1091
|
-
david_and_mary.merge(Author.where(id: bob), rewhere: true) # => [bob]
|
1092
|
-
```
|
689
|
+
* Add `ActiveRecord::Encryption::MessagePackMessageSerializer`.
|
1093
690
|
|
1094
|
-
|
691
|
+
Serialize data to the MessagePack format, for efficient storage in binary columns.
|
1095
692
|
|
1096
|
-
|
1097
|
-
|
1098
|
-
or email verification, where you want the bearer of the signed id to be able to interact with the
|
1099
|
-
underlying record, but usually only within a certain time period.
|
693
|
+
The binary encoding requires around 30% less space than the base64 encoding
|
694
|
+
used by the default serializer.
|
1100
695
|
|
1101
|
-
|
1102
|
-
signed_id = User.first.signed_id expires_in: 15.minutes, purpose: :password_reset
|
696
|
+
*Donal McBreen*
|
1103
697
|
|
1104
|
-
|
698
|
+
* Add support for encrypting binary columns.
|
1105
699
|
|
1106
|
-
|
1107
|
-
User.find_signed signed_id, purpose: :password_reset # => nil, since the signed id has expired
|
700
|
+
Ensure encryption and decryption pass `Type::Binary::Data` around for binary data.
|
1108
701
|
|
1109
|
-
|
1110
|
-
|
702
|
+
Previously encrypting binary columns with the `ActiveRecord::Encryption::MessageSerializer`
|
703
|
+
incidentally worked for MySQL and SQLite, but not PostgreSQL.
|
1111
704
|
|
1112
|
-
|
1113
|
-
```
|
705
|
+
*Donal McBreen*
|
1114
706
|
|
1115
|
-
|
707
|
+
* Deprecated `ENV["SCHEMA_CACHE"]` in favor of `schema_cache_path` in the database configuration.
|
1116
708
|
|
1117
|
-
*
|
709
|
+
*Rafael Mendonça França*
|
1118
710
|
|
1119
|
-
|
711
|
+
* Add `ActiveRecord::Base.with_connection` as a shortcut for leasing a connection for a short duration.
|
1120
712
|
|
1121
|
-
|
713
|
+
The leased connection is yielded, and for the duration of the block, any call to `ActiveRecord::Base.connection`
|
714
|
+
will yield that same connection.
|
1122
715
|
|
1123
|
-
|
716
|
+
This is useful to perform a few database operations without causing a connection to be leased for the
|
717
|
+
entire duration of the request or job.
|
1124
718
|
|
1125
|
-
*
|
719
|
+
*Jean Boussier*
|
1126
720
|
|
1127
|
-
|
721
|
+
* Deprecate `config.active_record.warn_on_records_fetched_greater_than` now that `sql.active_record`
|
722
|
+
notification includes `:row_count` field.
|
1128
723
|
|
1129
|
-
|
1130
|
-
posts = Post.joins(:comments).group(:"posts.hidden")
|
1131
|
-
posts = posts.where("posts.hidden": false, "comments.hidden": false)
|
724
|
+
*Jason Nochlin*
|
1132
725
|
|
1133
|
-
|
1134
|
-
|
726
|
+
* The fix ensures that the association is joined using the appropriate join type
|
727
|
+
(either inner join or left outer join) based on the existing joins in the scope.
|
1135
728
|
|
1136
|
-
|
1137
|
-
posts.unscope(where: :hidden).count
|
1138
|
-
# => { false => 11, true => 1 }
|
729
|
+
This prevents unintentional overrides of existing join types and ensures consistency in the generated SQL queries.
|
1139
730
|
|
1140
|
-
|
1141
|
-
posts.unscope(where: :"comments.hidden").count
|
1142
|
-
# => { false => 11 }
|
1143
|
-
```
|
731
|
+
Example:
|
1144
732
|
|
1145
|
-
*Ryuta Kamizono*, *Slava Korolev*
|
1146
733
|
|
1147
|
-
* Fix `rewhere` to truly overwrite collided where clause by new where clause.
|
1148
734
|
|
1149
735
|
```ruby
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
relation = Essay.where(writer: steve)
|
736
|
+
# `associated` will use `LEFT JOIN` instead of using `JOIN`
|
737
|
+
Post.left_joins(:author).where.associated(:author)
|
738
|
+
```
|
1154
739
|
|
1155
|
-
|
1156
|
-
relation.rewhere(writer: david).to_a # => []
|
740
|
+
*Saleh Alhaddad*
|
1157
741
|
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
742
|
+
* Fix an issue where `ActiveRecord::Encryption` configurations are not ready before the loading
|
743
|
+
of Active Record models, when an application is eager loaded. As a result, encrypted attributes
|
744
|
+
could be misconfigured in some cases.
|
1161
745
|
|
1162
|
-
*
|
746
|
+
*Maxime Réty*
|
1163
747
|
|
1164
|
-
*
|
748
|
+
* Deprecate defining an `enum` with keyword arguments.
|
1165
749
|
|
1166
750
|
```ruby
|
1167
|
-
|
1168
|
-
|
751
|
+
class Function > ApplicationRecord
|
752
|
+
# BAD
|
753
|
+
enum color: [:red, :blue],
|
754
|
+
type: [:instance, :class]
|
755
|
+
|
756
|
+
# GOOD
|
757
|
+
enum :color, [:red, :blue]
|
758
|
+
enum :type, [:instance, :class]
|
759
|
+
end
|
1169
760
|
```
|
1170
761
|
|
1171
|
-
*
|
1172
|
-
|
1173
|
-
* Deprecate passing a column to `type_cast`.
|
1174
|
-
|
1175
|
-
*Ryuta Kamizono*
|
1176
|
-
|
1177
|
-
* Deprecate `in_clause_length` and `allowed_index_name_length` in `DatabaseLimits`.
|
1178
|
-
|
1179
|
-
*Ryuta Kamizono*
|
1180
|
-
|
1181
|
-
* Support bulk insert/upsert on relation to preserve scope values.
|
1182
|
-
|
1183
|
-
*Josef Šimánek*, *Ryuta Kamizono*
|
1184
|
-
|
1185
|
-
* Preserve column comment value on changing column name on MySQL.
|
762
|
+
*Hartley McGuire*
|
1186
763
|
|
1187
|
-
|
764
|
+
* Add `config.active_record.validate_migration_timestamps` option for validating migration timestamps.
|
1188
765
|
|
1189
|
-
|
766
|
+
When set, validates that the timestamp prefix for a migration is no more than a day ahead of
|
767
|
+
the timestamp associated with the current time. This is designed to prevent migrations prefixes
|
768
|
+
from being hand-edited to future timestamps, which impacts migration generation and other
|
769
|
+
migration commands.
|
1190
770
|
|
1191
|
-
|
771
|
+
*Adrianna Chang*
|
1192
772
|
|
1193
|
-
|
773
|
+
* Properly synchronize `Mysql2Adapter#active?` and `TrilogyAdapter#active?`.
|
1194
774
|
|
1195
|
-
|
775
|
+
As well as `disconnect!` and `verify!`.
|
1196
776
|
|
1197
|
-
|
777
|
+
This generally isn't a big problem as connections must not be shared between
|
778
|
+
threads, but is required when running transactional tests or system tests
|
779
|
+
and could lead to a SEGV.
|
1198
780
|
|
1199
|
-
*
|
1200
|
-
|
1201
|
-
Fixes #38219.
|
1202
|
-
|
1203
|
-
*Josh Brody*
|
1204
|
-
|
1205
|
-
* Add support for `if_not_exists` option for adding index.
|
1206
|
-
|
1207
|
-
The `add_index` method respects `if_not_exists` option. If it is set to true
|
1208
|
-
index won't be added.
|
781
|
+
*Jean Boussier*
|
1209
782
|
|
1210
|
-
|
783
|
+
* Support `:source_location` tag option for query log tags.
|
1211
784
|
|
1212
785
|
```ruby
|
1213
|
-
|
786
|
+
config.active_record.query_log_tags << :source_location
|
1214
787
|
```
|
1215
788
|
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
*Prathamesh Sonpatki*
|
1221
|
-
|
1222
|
-
* Add `ActiveRecord::Base#previously_new_record?` to show if a record was new before the last save.
|
789
|
+
Calculating the caller location is a costly operation and should be used primarily in development
|
790
|
+
(note, there is also a `config.active_record.verbose_query_logs` that serves the same purpose)
|
791
|
+
or occasionally on production for debugging purposes.
|
1223
792
|
|
1224
|
-
*
|
1225
|
-
|
1226
|
-
* Support descending order for `find_each`, `find_in_batches`, and `in_batches`.
|
1227
|
-
|
1228
|
-
Batch processing methods allow you to work with the records in batches, greatly reducing memory consumption, but records are always batched from oldest id to newest.
|
793
|
+
*fatkodima*
|
1229
794
|
|
1230
|
-
|
795
|
+
* Add an option to `ActiveRecord::Encryption::Encryptor` to disable compression.
|
1231
796
|
|
1232
|
-
|
797
|
+
Allow compression to be disabled by setting `compress: false`
|
1233
798
|
|
1234
799
|
```ruby
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
800
|
+
class User
|
801
|
+
encrypts :name, encryptor: ActiveRecord::Encryption::Encryptor.new(compress: false)
|
802
|
+
end
|
1238
803
|
```
|
1239
804
|
|
1240
|
-
*
|
805
|
+
*Donal McBreen*
|
1241
806
|
|
1242
|
-
*
|
807
|
+
* Deprecate passing strings to `ActiveRecord::Tasks::DatabaseTasks.cache_dump_filename`.
|
1243
808
|
|
1244
|
-
|
809
|
+
A `ActiveRecord::DatabaseConfigurations::DatabaseConfig` object should be passed instead.
|
1245
810
|
|
1246
|
-
*
|
811
|
+
*Rafael Mendonça França*
|
1247
812
|
|
1248
|
-
* Add
|
813
|
+
* Add `row_count` field to `sql.active_record` notification.
|
1249
814
|
|
1250
|
-
|
815
|
+
This field returns the amount of rows returned by the query that emitted the notification.
|
1251
816
|
|
1252
|
-
|
817
|
+
This metric is useful in cases where one wants to detect queries with big result sets.
|
1253
818
|
|
1254
|
-
*
|
819
|
+
*Marvin Bitterlich*
|
1255
820
|
|
1256
|
-
|
821
|
+
* Consistently raise an `ArgumentError` when passing an invalid argument to a nested attributes association writer.
|
1257
822
|
|
1258
|
-
|
823
|
+
Previously, this would only raise on collection associations and produce a generic error on singular associations.
|
1259
824
|
|
1260
|
-
|
825
|
+
Now, it will raise on both collection and singular associations.
|
1261
826
|
|
1262
|
-
*
|
827
|
+
*Joshua Young*
|
1263
828
|
|
1264
|
-
|
829
|
+
* Fix single quote escapes on default generated MySQL columns.
|
1265
830
|
|
1266
|
-
|
831
|
+
MySQL 5.7.5+ supports generated columns, which can be used to create a column that is computed from an expression.
|
1267
832
|
|
1268
|
-
|
833
|
+
Previously, the schema dump would output a string with double escapes for generated columns with single quotes in the default expression.
|
1269
834
|
|
1270
|
-
|
835
|
+
This would result in issues when importing the schema on a fresh instance of a MySQL database.
|
1271
836
|
|
1272
|
-
|
837
|
+
Now, the string will not be escaped and will be valid Ruby upon importing of the schema.
|
1273
838
|
|
1274
|
-
*
|
839
|
+
*Yash Kapadia*
|
1275
840
|
|
1276
|
-
*
|
841
|
+
* Fix Migrations with versions older than 7.1 validating options given to
|
842
|
+
`add_reference` and `t.references`.
|
1277
843
|
|
1278
|
-
|
844
|
+
*Hartley McGuire*
|
1279
845
|
|
1280
|
-
|
846
|
+
* Add `<role>_types` class method to `ActiveRecord::DelegatedType` so that the delegated types can be introspected.
|
1281
847
|
|
1282
|
-
*
|
848
|
+
*JP Rosevear*
|
1283
849
|
|
1284
|
-
|
850
|
+
* Make `schema_dump`, `query_cache`, `replica` and `database_tasks` configurable via `DATABASE_URL`.
|
1285
851
|
|
1286
|
-
|
852
|
+
This wouldn't always work previously because boolean values would be interpreted as strings.
|
1287
853
|
|
1288
|
-
|
854
|
+
e.g. `DATABASE_URL=postgres://localhost/foo?schema_dump=false` now properly disable dumping the schema
|
855
|
+
cache.
|
1289
856
|
|
1290
|
-
|
1291
|
-
# config/database.yml
|
1292
|
-
production:
|
1293
|
-
primary:
|
1294
|
-
database: my_database
|
1295
|
-
primary_shard_one:
|
1296
|
-
database: my_database_shard_one
|
1297
|
-
```
|
857
|
+
*Mike Coutermarsh*, *Jean Boussier*
|
1298
858
|
|
1299
|
-
|
859
|
+
* Introduce `ActiveRecord::Transactions::ClassMethods#set_callback`.
|
1300
860
|
|
1301
|
-
|
1302
|
-
|
1303
|
-
self.abstract_class = true
|
861
|
+
It is identical to `ActiveSupport::Callbacks::ClassMethods#set_callback`
|
862
|
+
but with support for `after_commit` and `after_rollback` callback options.
|
1304
863
|
|
1305
|
-
|
1306
|
-
default: { writing: :primary },
|
1307
|
-
shard_one: { writing: :primary_shard_one }
|
1308
|
-
}
|
1309
|
-
```
|
864
|
+
*Joshua Young*
|
1310
865
|
|
1311
|
-
|
866
|
+
* Make `ActiveRecord::Encryption::Encryptor` agnostic of the serialization format used for encrypted data.
|
1312
867
|
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
end
|
1317
|
-
```
|
868
|
+
Previously, the encryptor instance only allowed an encrypted value serialized as a `String` to be passed to the message serializer.
|
869
|
+
|
870
|
+
Now, the encryptor lets the configured `message_serializer` decide which types of serialized encrypted values are supported. A custom serialiser is therefore allowed to serialize `ActiveRecord::Encryption::Message` objects using a type other than `String`.
|
1318
871
|
|
1319
|
-
The
|
872
|
+
The default `ActiveRecord::Encryption::MessageSerializer` already ensures that only `String` objects are passed for deserialization.
|
1320
873
|
|
1321
|
-
*
|
874
|
+
*Maxime Réty*
|
1322
875
|
|
1323
|
-
*
|
876
|
+
* Fix `encrypted_attribute?` to take into account context properties passed to `encrypts`.
|
1324
877
|
|
1325
|
-
|
878
|
+
*Maxime Réty*
|
1326
879
|
|
1327
|
-
|
880
|
+
* The object returned by `explain` now responds to `pluck`, `first`,
|
881
|
+
`last`, `average`, `count`, `maximum`, `minimum`, and `sum`. Those
|
882
|
+
new methods run `EXPLAIN` on the corresponding queries:
|
1328
883
|
|
1329
884
|
```ruby
|
1330
|
-
|
1331
|
-
|
885
|
+
User.all.explain.count
|
886
|
+
# EXPLAIN SELECT COUNT(*) FROM `users`
|
887
|
+
# ...
|
888
|
+
|
889
|
+
User.all.explain.maximum(:id)
|
890
|
+
# EXPLAIN SELECT MAX(`users`.`id`) FROM `users`
|
891
|
+
# ...
|
1332
892
|
```
|
1333
893
|
|
1334
|
-
|
894
|
+
*Petrik de Heus*
|
1335
895
|
|
1336
|
-
|
1337
|
-
|
1338
|
-
db_config.name
|
1339
|
-
```
|
896
|
+
* Fixes an issue where `validates_associated` `:on` option wasn't respected
|
897
|
+
when validating associated records.
|
1340
898
|
|
1341
|
-
*
|
899
|
+
*Austen Madden*, *Alex Ghiculescu*, *Rafał Brize*
|
1342
900
|
|
1343
|
-
*
|
901
|
+
* Allow overriding SQLite defaults from `database.yml`.
|
1344
902
|
|
1345
|
-
|
1346
|
-
|
903
|
+
Any PRAGMA configuration set under the `pragmas` key in the configuration
|
904
|
+
file takes precedence over Rails' defaults, and additional PRAGMAs can be
|
905
|
+
set as well.
|
1347
906
|
|
1348
|
-
```
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
rails db:drop:animals
|
1355
|
-
rails db:migrate
|
1356
|
-
rails db:migrate:primary
|
1357
|
-
rails db:migrate:animals
|
907
|
+
```yaml
|
908
|
+
database: storage/development.sqlite3
|
909
|
+
timeout: 5000
|
910
|
+
pragmas:
|
911
|
+
journal_mode: off
|
912
|
+
temp_store: memory
|
1358
913
|
```
|
1359
914
|
|
1360
|
-
|
1361
|
-
`rails db:test:prepare` can additionally operate on a single database. For example:
|
915
|
+
*Stephen Margheim*
|
1362
916
|
|
1363
|
-
|
1364
|
-
rails db:schema:dump
|
1365
|
-
rails db:schema:dump:primary
|
1366
|
-
rails db:schema:dump:animals
|
1367
|
-
rails db:schema:load
|
1368
|
-
rails db:schema:load:primary
|
1369
|
-
rails db:schema:load:animals
|
1370
|
-
rails db:structure:dump
|
1371
|
-
rails db:structure:dump:primary
|
1372
|
-
rails db:structure:dump:animals
|
1373
|
-
rails db:structure:load
|
1374
|
-
rails db:structure:load:primary
|
1375
|
-
rails db:structure:load:animals
|
1376
|
-
rails db:test:prepare
|
1377
|
-
rails db:test:prepare:primary
|
1378
|
-
rails db:test:prepare:animals
|
1379
|
-
```
|
917
|
+
* Remove warning message when running SQLite in production, but leave it unconfigured.
|
1380
918
|
|
1381
|
-
|
919
|
+
There are valid use cases for running SQLite in production. However, it must be done
|
920
|
+
with care, so instead of a warning most users won't see anyway, it's preferable to
|
921
|
+
leave the configuration commented out to force them to think about having the database
|
922
|
+
on a persistent volume etc.
|
1382
923
|
|
1383
|
-
*
|
924
|
+
*Jacopo Beschi*, *Jean Boussier*
|
1384
925
|
|
1385
|
-
|
926
|
+
* Add support for generated columns to the SQLite3 adapter.
|
1386
927
|
|
1387
|
-
|
928
|
+
Generated columns (both stored and dynamic) are supported since version 3.31.0 of SQLite.
|
929
|
+
This adds support for those to the SQLite3 adapter.
|
1388
930
|
|
1389
931
|
```ruby
|
1390
|
-
|
1391
|
-
|
932
|
+
create_table :users do |t|
|
933
|
+
t.string :name
|
934
|
+
t.virtual :name_upper, type: :string, as: 'UPPER(name)'
|
935
|
+
t.virtual :name_lower, type: :string, as: 'LOWER(name)', stored: true
|
1392
936
|
end
|
1393
|
-
|
1394
|
-
dev = Developer.first
|
1395
|
-
dev.projects.first
|
1396
|
-
# => ActiveRecord::StrictLoadingViolationError: The projects association is marked as strict_loading and cannot be lazily loaded.
|
1397
937
|
```
|
1398
938
|
|
1399
|
-
*
|
939
|
+
*Stephen Margheim*
|
1400
940
|
|
1401
|
-
*
|
941
|
+
* TrilogyAdapter: ignore `host` if `socket` parameter is set.
|
1402
942
|
|
1403
|
-
|
943
|
+
This allows to configure a connection on a UNIX socket via `DATABASE_URL`:
|
1404
944
|
|
1405
|
-
|
1406
|
-
|
1407
|
-
```ruby
|
1408
|
-
dev = Developer.strict_loading.first
|
1409
|
-
dev.audit_logs.to_a
|
1410
|
-
# => ActiveRecord::StrictLoadingViolationError: Developer is marked as strict_loading and AuditLog cannot be lazily loaded.
|
945
|
+
```
|
946
|
+
DATABASE_URL=trilogy://does-not-matter/my_db_production?socket=/var/run/mysql.sock
|
1411
947
|
```
|
1412
948
|
|
1413
|
-
*
|
1414
|
-
|
1415
|
-
* Add support for PostgreSQL 11+ partitioned indexes when using `upsert_all`.
|
1416
|
-
|
1417
|
-
*Sebastián Palma*
|
1418
|
-
|
1419
|
-
* Adds support for `if_not_exists` to `add_column` and `if_exists` to `remove_column`.
|
949
|
+
*Jean Boussier*
|
1420
950
|
|
1421
|
-
|
951
|
+
* Make `assert_queries_count`, `assert_no_queries`, `assert_queries_match`, and
|
952
|
+
`assert_no_queries_match` assertions public.
|
1422
953
|
|
1423
|
-
|
954
|
+
To assert the expected number of queries are made, Rails internally uses `assert_queries_count` and
|
955
|
+
`assert_no_queries`. To assert that specific SQL queries are made, `assert_queries_match` and
|
956
|
+
`assert_no_queries_match` are used. These assertions can now be used in applications as well.
|
1424
957
|
|
1425
958
|
```ruby
|
1426
|
-
class
|
1427
|
-
|
1428
|
-
|
959
|
+
class ArticleTest < ActiveSupport::TestCase
|
960
|
+
test "queries are made" do
|
961
|
+
assert_queries_count(1) { Article.first }
|
1429
962
|
end
|
1430
|
-
end
|
1431
|
-
```
|
1432
963
|
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
964
|
+
test "creates a foreign key" do
|
965
|
+
assert_queries_match(/ADD FOREIGN KEY/i, include_schema: true) do
|
966
|
+
@connection.add_foreign_key(:comments, :posts)
|
967
|
+
end
|
1437
968
|
end
|
1438
969
|
end
|
1439
970
|
```
|
1440
971
|
|
1441
|
-
*
|
1442
|
-
|
1443
|
-
* Regexp-escape table name for MS SQL Server.
|
1444
|
-
|
1445
|
-
Add `Regexp.escape` to one method in ActiveRecord, so that table names with regular expression characters in them work as expected. Since MS SQL Server uses "[" and "]" to quote table and column names, and those characters are regular expression characters, methods like `pluck` and `select` fail in certain cases when used with the MS SQL Server adapter.
|
1446
|
-
|
1447
|
-
*Larry Reid*
|
1448
|
-
|
1449
|
-
* Store advisory locks on their own named connection.
|
1450
|
-
|
1451
|
-
Previously advisory locks were taken out against a connection when a migration started. This works fine in single database applications but doesn't work well when migrations need to open new connections which results in the lock getting dropped.
|
1452
|
-
|
1453
|
-
In order to fix this we are storing the advisory lock on a new connection with the connection specification name `AdvisoryLockBase`. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.
|
972
|
+
*Petrik de Heus*, *fatkodima*
|
1454
973
|
|
1455
|
-
|
974
|
+
* Fix `has_secure_token` calls the setter method on initialize.
|
1456
975
|
|
1457
|
-
*
|
976
|
+
*Abeid Ahmed*
|
1458
977
|
|
1459
|
-
|
978
|
+
* When using a `DATABASE_URL`, allow for a configuration to map the protocol in the URL to a specific database
|
979
|
+
adapter. This allows decoupling the adapter the application chooses to use from the database connection details
|
980
|
+
set in the deployment environment.
|
1460
981
|
|
1461
|
-
```
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
pool: 5
|
1466
|
-
schema_cache_path: tmp/schema/main.yml
|
982
|
+
```ruby
|
983
|
+
# ENV['DATABASE_URL'] = "mysql://localhost/example_database"
|
984
|
+
config.active_record.protocol_adapters.mysql = "trilogy"
|
985
|
+
# will connect to MySQL using the trilogy adapter
|
1467
986
|
```
|
1468
987
|
|
1469
|
-
*
|
1470
|
-
|
1471
|
-
* Deprecate `#remove_connection` in favor of `#remove_connection_pool` when called on the handler.
|
1472
|
-
|
1473
|
-
`#remove_connection` is deprecated in order to support returning a `DatabaseConfig` object instead of a `Hash`. Use `#remove_connection_pool`, `#remove_connection` will be removed in Rails 7.0.
|
988
|
+
*Jean Boussier*, *Kevin McPhillips*
|
1474
989
|
|
1475
|
-
|
990
|
+
* In cases where MySQL returns `warning_count` greater than zero, but returns no warnings when
|
991
|
+
the `SHOW WARNINGS` query is executed, `ActiveRecord.db_warnings_action` proc will still be
|
992
|
+
called with a generic warning message rather than silently ignoring the warning(s).
|
1476
993
|
|
1477
|
-
*
|
994
|
+
*Kevin McPhillips*
|
1478
995
|
|
1479
|
-
|
996
|
+
* `DatabaseConfigurations#configs_for` accepts a symbol in the `name` parameter.
|
1480
997
|
|
1481
|
-
*
|
998
|
+
*Andrew Novoselac*
|
1482
999
|
|
1483
|
-
*
|
1000
|
+
* Fix `where(field: values)` queries when `field` is a serialized attribute
|
1001
|
+
(for example, when `field` uses `ActiveRecord::Base.serialize` or is a JSON
|
1002
|
+
column).
|
1484
1003
|
|
1485
|
-
*
|
1004
|
+
*João Alves*
|
1486
1005
|
|
1487
|
-
*
|
1006
|
+
* Make the output of `ActiveRecord::Core#inspect` configurable.
|
1488
1007
|
|
1489
|
-
|
1008
|
+
By default, calling `inspect` on a record will yield a formatted string including just the `id`.
|
1490
1009
|
|
1491
1010
|
```ruby
|
1492
|
-
Post.
|
1011
|
+
Post.first.inspect #=> "#<Post id: 1>"
|
1493
1012
|
```
|
1494
1013
|
|
1495
|
-
|
1496
|
-
|
1497
|
-
```ruby
|
1498
|
-
Post.where.missing(:author)
|
1499
|
-
```
|
1500
|
-
|
1501
|
-
*Tom Rossi*
|
1502
|
-
|
1503
|
-
* Ensure `:reading` connections always raise if a write is attempted.
|
1504
|
-
|
1505
|
-
Now Rails will raise an `ActiveRecord::ReadOnlyError` if any connection on the reading handler attempts to make a write. If your reading role needs to write you should name the role something other than `:reading`.
|
1506
|
-
|
1507
|
-
*Eileen M. Uchitelle*
|
1508
|
-
|
1509
|
-
* Deprecate `"primary"` as the `connection_specification_name` for `ActiveRecord::Base`.
|
1510
|
-
|
1511
|
-
`"primary"` has been deprecated as the `connection_specification_name` for `ActiveRecord::Base` in favor of using `"ActiveRecord::Base"`. This change affects calls to `ActiveRecord::Base.connection_handler.retrieve_connection` and `ActiveRecord::Base.connection_handler.remove_connection`. If you're calling these methods with `"primary"`, please switch to `"ActiveRecord::Base"`.
|
1512
|
-
|
1513
|
-
*Eileen M. Uchitelle*, *John Crepezzi*
|
1514
|
-
|
1515
|
-
* Add `ActiveRecord::Validations::NumericalityValidator` with
|
1516
|
-
support for casting floats using a database columns' precision value.
|
1517
|
-
|
1518
|
-
*Gannon McGibbon*
|
1519
|
-
|
1520
|
-
* Enforce fresh ETag header after a collection's contents change by adding
|
1521
|
-
ActiveRecord::Relation#cache_key_with_version. This method will be used by
|
1522
|
-
ActionController::ConditionalGet to ensure that when collection cache versioning
|
1523
|
-
is enabled, requests using ConditionalGet don't return the same ETag header
|
1524
|
-
after a collection is modified.
|
1525
|
-
|
1526
|
-
Fixes #38078.
|
1527
|
-
|
1528
|
-
*Aaron Lipman*
|
1529
|
-
|
1530
|
-
* Skip test database when running `db:create` or `db:drop` in development
|
1531
|
-
with `DATABASE_URL` set.
|
1532
|
-
|
1533
|
-
*Brian Buchalter*
|
1534
|
-
|
1535
|
-
* Don't allow mutations on the database configurations hash.
|
1536
|
-
|
1537
|
-
Freeze the configurations hash to disallow directly changing it. If applications need to change the hash, for example to create databases for parallelization, they should use the `DatabaseConfig` object directly.
|
1538
|
-
|
1539
|
-
Before:
|
1014
|
+
The attributes to be included in the output of `inspect` can be configured with
|
1015
|
+
`ActiveRecord::Core#attributes_for_inspect`.
|
1540
1016
|
|
1541
1017
|
```ruby
|
1542
|
-
|
1543
|
-
|
1018
|
+
Post.attributes_for_inspect = [:id, :title]
|
1019
|
+
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!">"
|
1544
1020
|
```
|
1545
1021
|
|
1546
|
-
|
1022
|
+
With `attributes_for_inspect` set to `:all`, `inspect` will list all the record's attributes.
|
1547
1023
|
|
1548
1024
|
```ruby
|
1549
|
-
|
1550
|
-
|
1551
|
-
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(@db_config.env_name, @db_config.spec_name, config)
|
1025
|
+
Post.attributes_for_inspect = :all
|
1026
|
+
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!", published_at: "2023-10-23 14:28:11 +0000">"
|
1552
1027
|
```
|
1553
1028
|
|
1554
|
-
|
1555
|
-
|
1556
|
-
* Remove `:connection_id` from the `sql.active_record` notification.
|
1557
|
-
|
1558
|
-
*Aaron Patterson*, *Rafael Mendonça França*
|
1559
|
-
|
1560
|
-
* The `:name` key will no longer be returned as part of `DatabaseConfig#configuration_hash`. Please use `DatabaseConfig#owner_name` instead.
|
1561
|
-
|
1562
|
-
*Eileen M. Uchitelle*, *John Crepezzi*
|
1563
|
-
|
1564
|
-
* ActiveRecord's `belongs_to_required_by_default` flag can now be set per model.
|
1565
|
-
|
1566
|
-
You can now opt-out/opt-in specific models from having their associations required
|
1567
|
-
by default.
|
1568
|
-
|
1569
|
-
This change is meant to ease the process of migrating all your models to have
|
1570
|
-
their association required.
|
1571
|
-
|
1572
|
-
*Edouard Chin*
|
1573
|
-
|
1574
|
-
* The `connection_config` method has been deprecated, please use `connection_db_config` instead which will return a `DatabaseConfigurations::DatabaseConfig` instead of a `Hash`.
|
1575
|
-
|
1576
|
-
*Eileen M. Uchitelle*, *John Crepezzi*
|
1577
|
-
|
1578
|
-
* Retain explicit selections on the base model after applying `includes` and `joins`.
|
1029
|
+
In `development` and `test` mode, `attributes_for_inspect` will be set to `:all` by default.
|
1579
1030
|
|
1580
|
-
|
1031
|
+
You can also call `full_inspect` to get an inspection with all the attributes.
|
1581
1032
|
|
1582
|
-
|
1033
|
+
The attributes in `attribute_for_inspect` will also be used for `pretty_print`.
|
1583
1034
|
|
1584
|
-
*
|
1035
|
+
*Andrew Novoselac*
|
1585
1036
|
|
1586
|
-
|
1037
|
+
* Don't mark attributes as changed when reassigned to `Float::INFINITY` or
|
1038
|
+
`-Float::INFINITY`.
|
1587
1039
|
|
1588
|
-
*
|
1040
|
+
*Maicol Bentancor*
|
1589
1041
|
|
1590
|
-
|
1042
|
+
* Support the `RETURNING` clause for MariaDB.
|
1591
1043
|
|
1592
|
-
*
|
1044
|
+
*fatkodima*, *Nikolay Kondratyev*
|
1593
1045
|
|
1594
|
-
|
1046
|
+
* The SQLite3 adapter now implements the `supports_deferrable_constraints?` contract.
|
1595
1047
|
|
1596
|
-
|
1597
|
-
|
1598
|
-
*John Crepezzi*
|
1599
|
-
|
1600
|
-
* Specifying `implicit_order_column` now subsorts the records by primary key if available to ensure deterministic results.
|
1601
|
-
|
1602
|
-
*Paweł Urbanek*
|
1603
|
-
|
1604
|
-
* `where(attr => [])` now loads an empty result without making a query.
|
1605
|
-
|
1606
|
-
*John Hawthorn*
|
1607
|
-
|
1608
|
-
* Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
|
1609
|
-
|
1610
|
-
*Hiroyuki Ishii*
|
1611
|
-
|
1612
|
-
* Add support for `belongs_to` to `has_many` inversing.
|
1613
|
-
|
1614
|
-
*Gannon McGibbon*
|
1615
|
-
|
1616
|
-
* Allow length configuration for `has_secure_token` method. The minimum length
|
1617
|
-
is set at 24 characters.
|
1618
|
-
|
1619
|
-
Before:
|
1048
|
+
Allows foreign keys to be deferred by adding the `:deferrable` key to the `foreign_key` options.
|
1620
1049
|
|
1621
1050
|
```ruby
|
1622
|
-
|
1051
|
+
add_reference :person, :alias, foreign_key: { deferrable: :deferred }
|
1052
|
+
add_reference :alias, :person, foreign_key: { deferrable: :deferred }
|
1623
1053
|
```
|
1624
1054
|
|
1625
|
-
|
1055
|
+
*Stephen Margheim*
|
1056
|
+
|
1057
|
+
* Add the `set_constraints` helper to PostgreSQL connections.
|
1626
1058
|
|
1627
1059
|
```ruby
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1060
|
+
Post.create!(user_id: -1) # => ActiveRecord::InvalidForeignKey
|
1061
|
+
|
1062
|
+
Post.transaction do
|
1063
|
+
Post.connection.set_constraints(:deferred)
|
1064
|
+
p = Post.create!(user_id: -1)
|
1065
|
+
u = User.create!
|
1066
|
+
p.user = u
|
1067
|
+
p.save!
|
1068
|
+
end
|
1631
1069
|
```
|
1632
1070
|
|
1633
|
-
*
|
1071
|
+
*Cody Cutrer*
|
1634
1072
|
|
1635
|
-
*
|
1073
|
+
* Include `ActiveModel::API` in `ActiveRecord::Base`.
|
1636
1074
|
|
1637
|
-
*
|
1638
|
-
|
1639
|
-
* Add `DatabaseConfig#configuration_hash` to return database configuration hashes with symbol keys, and use all symbol-key configuration hashes internally. Deprecate `DatabaseConfig#config` which returns a String-keyed `Hash` with the same values.
|
1640
|
-
|
1641
|
-
*John Crepezzi*, *Eileen Uchitelle*
|
1642
|
-
|
1643
|
-
* Allow column names to be passed to `remove_index` positionally along with other options.
|
1644
|
-
|
1645
|
-
Passing other options can be necessary to make `remove_index` correctly reversible.
|
1646
|
-
|
1647
|
-
Before:
|
1648
|
-
|
1649
|
-
add_index :reports, :report_id # => works
|
1650
|
-
add_index :reports, :report_id, unique: true # => works
|
1651
|
-
remove_index :reports, :report_id # => works
|
1652
|
-
remove_index :reports, :report_id, unique: true # => ArgumentError
|
1653
|
-
|
1654
|
-
After:
|
1655
|
-
|
1656
|
-
remove_index :reports, :report_id, unique: true # => works
|
1657
|
-
|
1658
|
-
*Eugene Kenny*
|
1659
|
-
|
1660
|
-
* Allow bulk `ALTER` statements to drop and recreate indexes with the same name.
|
1661
|
-
|
1662
|
-
*Eugene Kenny*
|
1663
|
-
|
1664
|
-
* `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
|
1665
|
-
|
1666
|
-
*Eugene Kenny*
|
1667
|
-
|
1668
|
-
* Call `while_preventing_writes` directly from `connected_to`.
|
1669
|
-
|
1670
|
-
In some cases application authors want to use the database switching middleware and make explicit calls with `connected_to`. It's possible for an app to turn off writes and not turn them back on by the time we call `connected_to(role: :writing)`.
|
1671
|
-
|
1672
|
-
This change allows apps to fix this by assuming if a role is writing we want to allow writes, except in the case it's explicitly turned off.
|
1673
|
-
|
1674
|
-
*Eileen M. Uchitelle*
|
1675
|
-
|
1676
|
-
* Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
|
1677
|
-
|
1678
|
-
*Kir Shatrov*
|
1679
|
-
|
1680
|
-
* Stop trying to read yaml file fixtures when loading Active Record fixtures.
|
1681
|
-
|
1682
|
-
*Gannon McGibbon*
|
1683
|
-
|
1684
|
-
* Deprecate `.reorder(nil)` with `.first` / `.first!` taking non-deterministic result.
|
1685
|
-
|
1686
|
-
To continue taking non-deterministic result, use `.take` / `.take!` instead.
|
1687
|
-
|
1688
|
-
*Ryuta Kamizono*
|
1689
|
-
|
1690
|
-
* Preserve user supplied joins order as much as possible.
|
1691
|
-
|
1692
|
-
Fixes #36761, #34328, #24281, #12953.
|
1693
|
-
|
1694
|
-
*Ryuta Kamizono*
|
1695
|
-
|
1696
|
-
* Allow `matches_regex` and `does_not_match_regexp` on the MySQL Arel visitor.
|
1697
|
-
|
1698
|
-
*James Pearson*
|
1699
|
-
|
1700
|
-
* Allow specifying fixtures to be ignored by setting `ignore` in YAML file's '_fixture' section.
|
1701
|
-
|
1702
|
-
*Tongfei Gao*
|
1703
|
-
|
1704
|
-
* Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
|
1705
|
-
|
1706
|
-
*John Crepezzi*, *Eileen Uchitelle*
|
1707
|
-
|
1708
|
-
* Add a warning for enum elements with 'not_' prefix.
|
1709
|
-
|
1710
|
-
class Foo
|
1711
|
-
enum status: [:sent, :not_sent]
|
1712
|
-
end
|
1713
|
-
|
1714
|
-
*Edu Depetris*
|
1715
|
-
|
1716
|
-
* Make currency symbols optional for money column type in PostgreSQL.
|
1717
|
-
|
1718
|
-
*Joel Schneider*
|
1719
|
-
|
1720
|
-
* Add support for beginless ranges, introduced in Ruby 2.7.
|
1721
|
-
|
1722
|
-
*Josh Goodall*
|
1723
|
-
|
1724
|
-
* Add `database_exists?` method to connection adapters to check if a database exists.
|
1725
|
-
|
1726
|
-
*Guilherme Mansur*
|
1727
|
-
|
1728
|
-
* Loading the schema for a model that has no `table_name` raises a `TableNotSpecified` error.
|
1729
|
-
|
1730
|
-
*Guilherme Mansur*, *Eugene Kenny*
|
1731
|
-
|
1732
|
-
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
1733
|
-
|
1734
|
-
Fixes #36022.
|
1735
|
-
|
1736
|
-
*Ryuta Kamizono*
|
1737
|
-
|
1738
|
-
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
1739
|
-
|
1740
|
-
Fixes #36465.
|
1741
|
-
|
1742
|
-
*Jeff Doering*
|
1743
|
-
|
1744
|
-
* Add support for multiple databases to `rails db:abort_if_pending_migrations`.
|
1745
|
-
|
1746
|
-
*Mark Lee*
|
1747
|
-
|
1748
|
-
* Fix sqlite3 collation parsing when using decimal columns.
|
1749
|
-
|
1750
|
-
*Martin R. Schuster*
|
1751
|
-
|
1752
|
-
* Fix invalid schema when primary key column has a comment.
|
1075
|
+
*Sean Doyle*
|
1753
1076
|
|
1754
|
-
|
1077
|
+
* Ensure `#signed_id` outputs `url_safe` strings.
|
1755
1078
|
|
1756
|
-
*
|
1079
|
+
*Jason Meller*
|
1757
1080
|
|
1758
|
-
*
|
1081
|
+
* Add `nulls_last` and working `desc.nulls_first` for MySQL.
|
1759
1082
|
|
1760
|
-
*
|
1083
|
+
*Tristan Fellows*
|
1761
1084
|
|
1762
|
-
* Allow
|
1085
|
+
* Allow for more complex hash arguments for `order` which mimics `where` in `ActiveRecord::Relation`.
|
1763
1086
|
|
1764
|
-
|
1087
|
+
```ruby
|
1088
|
+
Topic.includes(:posts).order(posts: { created_at: :desc })
|
1089
|
+
```
|
1765
1090
|
|
1091
|
+
*Myles Boone*
|
1766
1092
|
|
1767
|
-
Please check [
|
1093
|
+
Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/activerecord/CHANGELOG.md) for previous changes.
|