なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2021/11/20)

2021/11/20分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


Merge pull request #43625 from Shopify/error-reporting-api

Active Support、railtiesの修正です。

error reporting処理の為のActiveSupport::ErrorReporter classを追加しています。Railsのerror reporting処理がRailsの中で統一されてなくて、それを統一する為の対応。

ActiveSupport::ErrorReporterにはerror発生時に処理をおこなう為のsubscriberを登録する事ができるようになっています。また、subscriberはreport(Exception, handled: Boolean, context: Hash)メソッドが定義されている必要がります。

ActiveSupport::ErrorReporterはerrorが発生した際に、subscriberを呼び出しで処理を継続するhandleメソッドと、subscriberを呼び出して処理を停止するrecordメソッドがそれぞれpublic APIとして提供されています。また、ActiveSupport::ErrorReporterはshort handとして、Rails.errorで使用出来るようになっています。

Rollback transactions when the block returns earlier than expected

activerecord/lib/active_record/connection_adapters/abstract/transaction.rbの修正です。

deprecatedになっていた、transaction block内でreturnbreakthrowを使用した場合、transactionがcommitされて終了する、という振る舞いを削除しています。今後は、rollbackされるようになります。


Remove deprecated DatabaseConfig#config method

activerecord/lib/active_record/database_configurations/database_config.rbactiverecord/lib/active_record/database_configurations/hash_config.rbの修正です。

deprecatedになっていたDatabaseConfig#configメソッドを削除しています。


Remove deprecated rake tasks: activerecord/lib/active_record/railties/databases.rakeの修正です。

deprecatedになっていたdb:xx等のrake taskを削除しています。


Remove deprecation for aggregations that are grouping in duplicated fields

activerecord/lib/active_record/relation/calculations.rbの修正です。

deprecatedになっていた、aggregations + groupした場合に同じfieldsが複数生成されてしまう、という挙動を削除しています。


Remove deprecated support to Model.reorder(nil).first to search using non-deterministic order.

activerecord/lib/active_record/relation/finder_methods.rbactiverecord/lib/active_record/relation/query_methods.rbの修正です。

deprecatedになっていた、reorder(nil) + first / first!を使用した場合に実行されるSQLORDERが指定されない、という挙動が削除されました。今後はreorder(nil)が指定されていてもORDERが指定されるようなっています。


Remove code duplication by moving logic to check_if_method_has_arguments!

activerecord/lib/active_record/relation/query_methods.rbの修正です。

重複して行われていたargsの展開・空の値の削除処理を削除しています。


Remove deprecation for duplicated query annotations

activerecord/lib/active_record/relation/query_methods.rbの修正です。

deprecatedになっていた、aggregations + annotateした場合に同じfieldsが複数生成されてしまう、という挙動を削除しています。


Change how Merging conditions on the same column works

activerecord/lib/active_record/relation/where_clause.rbの修正です。

deprecatedになっていた、同じカラムに対するmergeで両方の条件を保持する、という挙動を削除して、後者の条件で処理が行われるようにしています。

# Rails 6.1
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob]


# Rails 7.0
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]

Remove deprecated environment and name arguments from Tasks::DatabaseTasks.schema_up_to_date?

activerecord/lib/active_record/tasks/database_tasks.rbの修正です。

deprecatedになっていた、Tasks::DatabaseTasks.schema_up_to_date?environmentname引数を削除しています。


Remove deprecated methods in `Tasks::DatabaseTasks

activerecord/lib/active_record/tasks/database_tasks.rbの修正です。

deprecatedになっていたTask::DatabaseTasksの各メソッドを削除しています。合わせて、使われなくなったTasks::DatabaseTasks.schema_file_typeをdeprecateにしています。


Remove deprecated config.active_support.use_sha1_digests

activesupport/lib/active_support/railtie.rbの修正です。

deprecatedになっていたconfg.active_support.use_sha1_digestsを削除しています。


Remove deprecated URI.parser

activesupport/lib/active_support/core_ext.rbactivesupport/lib/active_support/core_ext/uri.rbの修正です。

deprecatedになっていたURI.parserを削除しています。


Remove deprecated support to use Range#include? to check the inclusion of a value in a date time range is deprecated

activesupport/lib/active_support/core_ext/range/include_time_with_zone.rbの修正です。

deprecatedになっていた、Range#include?でのdate time rangeに値が含まれているかをチェックする挙動を削除しています。


Merge pull request #43421 from seanpdoyle/action-view-unify-form-implementation

actionview/lib/action_view/helpers/form_helper.rbの修正です。

form_forメソッドでform_withを再利用するよう修正しています。


Merge PR #42006

activerecord/lib/active_record/log_subscriber.rbの修正です。

ActiveRecord::Base.filter_attributesで指定されたattributeについて、SQL queryのlogでもfilter処理が行われるようする修正しています。

# Before:
# => Foo Load (0.2ms)  SELECT "foos".* FROM "foos" WHERE "foos"."passw" = ? LIMIT ?  [["passw", "hello"], ["LIMIT", 1]]

# After:
# => Foo Load (0.5ms)  SELECT "foos".* FROM "foos" WHERE "foos"."passw" = ? LIMIT ?  [["passw", "[FILTERED]"], ["LIMIT", 1]]

Merge pull request #43045 from sandip-mane/array-syntax-consistancy

activestorage/db/migrate/20170806125915_create_active_storage_tables.rbの修正です。

Arrayの指定方法に、他の箇所と合わせるよう修正しています。


Remove deprecate ActiveSupport::Multibyte::Unicode.default_normalization_form

activesupport/lib/active_support/multibyte/unicode.rbの修正です。

deprecatedになっていたActiveSupport::Multibyte::Unicode.default_normalization_formを削除しています。


Remove deprecated :return_false_on_aborted_enqueue option

activejob/lib/active_job/callbacks.rbの修正です。

deprecatedになっていたActiveJob.return_false_on_aborted_enqueueを削除しています。


Remove duplicated tests

activemodel/test/cases/errors_test.rbの修正です。

重複していたテストを削除しています。


Remove deprecated ActiveRecord::Base.connection_config

activerecord/lib/active_record/connection_handling.rbの修正です。

deprecatedになっていたActiveRecord::Base.connection_configを削除しています。


Remove deprecated ActiveRecord::Base.arel_attribute

activerecord/lib/active_record/core.rbの修正です。

deprecatedになっていたActiveRecord::Base.arel_attributeを削除しています。


Remove deprecated ActiveRecord::Base.configurations.default_hash.

activerecord/lib/active_record/database_configurations.rbの修正です。

deprecatedになっていたActiveRecord::Base.configurations.default_hashを削除しています。


Remove deprecated ActiveRecord::Base.configurations.to_h

activerecord/lib/active_record/database_configurations.rbの修正です。

deprecatedになっていたActiveRecord::Base.configurations.to_hを削除しています。


Fix typo

activerecord/lib/active_record/connection_adapters/abstract/transaction.rbの修正です。

becausebecaseにタイポしていたのを修正しています。


Remove deprecated ActiveRecord::Result#map! and ActiveRecord::Result#collect!

activerecord/lib/active_record/result.rbの修正です。

deprecatedになっていたActiveRecord::Result#map!ActiveRecord::Result#collect!を削除しています。


Merge pull request #43675 from esparta/fix_race_conditions_test_cache_ii

activesupport/test/cache/behaviors/cache_store_behavior.rbactivesupport/test/cache/behaviors/cache_store_version_behavior.rbの修正です。

Active Supportのcacheのテストで、異なるテストで同じkeyを使っていた為に並列に実行するとランダムにfailしてしまっていたのを、keyにランダムな値を使用するようにして、並列に実行してもfailしないよう修正しています。


Fix typo

activerecord/lib/active_record/encryption/encrypted_attribute_type.rbのdocの修正です。

EncryptedAttributeType#initializeメソッドのdoc内のタイポを修正しています。