なるようになるブログ

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

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

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

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

actionmailbox/CHANGELOG.md

actionmailer/CHANGELOG.md

actionpack/CHANGELOG.md

activejob/CHANGELOG.md

activemodel/CHANGELOG.md

activerecord/CHANGELOG.md


Fix spelling of Additionally

rails guideのSecuring Rails Applicationsの修正です。

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


Merge pull request #43636 from TooManyBees/fix-preloader-association-nil-error

activerecord/lib/active_record/associations/preloader/association.rbの修正です。

preloaderのrecordsにnilを指定した場合にNoMethodErrorが発生してしまうリグレッションがあったのを修正しています。

が、この対応によりCIが壊れてしまったので、後ほどRevertされています。


Revert "Merge pull request #43636 from TooManyBees/fix-preloader-association-nil-error"

直前の、preloaderのrecordsにnilを指定した場合にNoMethodErrorが発生してしまうリグレッションがあったのを修正した対応をRevertしています。CIが壊れてしまった為。


Remove deprecated MAILGUN_INGRESS_API_KEY and mailgun_api_key configurations

actionmailbox/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rbの修正です。

deprecatedになっていたMAILGUN_INGRESS_API_KEY envのサポート、及び、Rails.application.credentials.action_mailbox.mailgun_api_keyを削除しています。


Remove deprecated ActionMailer::DeliveryJob and ActionMailer::Parameterized::DeliveryJob

Action Mailerの修正です。

deprecatedになっていたActionMailer::DeliveryJobActionMailer::Parameterized::DeliveryJobを削除しています。


Remove deprecated ActionDispatch::Response.return_only_media_type_on_content_type.

actionpack/lib/action_dispatch/http/response.rbの修正です。

deprecatedになっていたActionDispatch::Response.return_only_media_type_on_content_typeを削除しています。


Remove deprecated Rails.config.action_dispatch.hosts_response_app

actionpack/lib/action_dispatch/middleware/host_authorization.rbrailties/lib/rails/application/default_middleware_stack.rbの修正です。

deprecatedになっていたRails.config.action_dispatch.hosts_response_appを削除しています。


Remove deprecated ActionDispatch::SystemTestCase#host!

actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rbの修正です。

deprecatedになっていたActionDispatch::SystemTestCase#host!を削除しています。


Remove deprecated support to passing a path to fixture_file_upload relative to fixture_path

actionpack/lib/action_dispatch/testing/test_process.rbの修正です。

deprecatedになっていたfixture_file_uploadfixture_pathからの相対パスを指定した場合のサポートを削除しています。


Remove deprecated Rails.config.action_view.raise_on_missing_translations

Action Viewの修正です。

deprecatedになっていたRails.config.action_view.raise_on_missing_translationsを削除しています。


Removed deprecated behavior that was not halting after_enqueue/after_perform callbacks when a previous callback was halted with throw :abort.

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

deprecatedになっていた、after_enqueue / after_perform callbacksで前のcallbackがthrow :abortで終了した場合も処理を継続する、という挙動を削除しています。合わせて、この挙動を制御する為のconfig(Rails.config.active_job.skip_after_callbacks_if_terminated)をdeprecatedにしています。


Remove deprecated enumeration of ActiveModel::Errors instances as a Hash

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errorsのenumeration処理でインスタンスHashとして扱う挙動を削除しています。


Remove deprecated ActiveModel::Errors#to_h

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errors#to_hを削除しています。


Remove deprecated ActiveModel::Errors#slice!

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errors#slice!を削除しています。


Remove deprecated ActiveModel::Errors#values

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errors#valuesを削除しています。


Remove deprecated ActiveModel::Errors#keys

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errors#keysを削除しています。


Remove deprecated ActiveModel::Errors#to_xml

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errors#to_xmlを削除しています。


Remove unused method

activemodel/lib/active_model/errors.rbの修正です。

上記deprecatedメソッドの削除により不要になったメソッドを削除しています。


Remove deprecated support concat errors to ActiveModel::Errors#messages

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errors#messagesに対するエラーメッセージのconcat処理を削除しています。


Remove deprecated support clear errors from ActiveModel::Errors#messages

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errors#messagesに対するerrorsのclear処理を削除しています。


Remove unnecessary class

activemodel/lib/active_model/errors.rbの修正です。

不要になったdeprecated処理の為のクラスを削除しています。


Implement each using a delegator and make sure all enumerable methods are available

activemodel/lib/active_model/errors.rbの修正です。

ActiveModel::Errors#eachメソッドを独自に定義してたのを、他のenumerableメソッドと同様にdelegatorを使用するよう修正しています。deprecatedになっていた既存の挙動を削除することにより、独自のメソッドを定義する必要が無くなった為。


Remove deprecated support delete errors from ActiveModel::Errors#messages

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errors#messagesに対するerrorsのdelete処理を削除しています。


Remove deprecated support to use []= in ActiveModel::Errors#messages

activemodel/lib/active_model/errors.rbの修正です。

deprecatedになっていたActiveModel::Errors#messagesに対する[]=メソッドを削除しています。


Remove support to Marshal and YAML load Rails 5.x error format

activemodel/lib/active_model/errors.rbの修正です。

Rails 5系のコードで作成されたActiveModel::ErrorsインスタンスのMarshal、 YAMLデータのロード処理のサポートを削除しています。


Remove support to Marshal load Rails 5.x ActiveModel::AttributeSet format

activemodel/lib/active_model/attribute_set/builder.rbの修正です。

Rails 5系のコードで作成されたActiveModel::AttributeSetインスタンスのMarshalデータのロード処理のサポートを削除しています。


Remove deprecated ActiveRecord::Base.allow_unsafe_raw_sql

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

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


Remove deprecated option :spec_name in the configs_for method

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

deprecatedになっていたconfigs_forメソッドの:spec_name引数を削除しています。


Remove deprecated support to YAML load ActiveRecord::Base instance in the Rails 4.2 and 4.1 formats

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

Rails 4.1、及び、4.2のコードで作成されたActiveRecord::BaseインスタンスYAMLデータのロード処理のサポートを削除しています。


Remove deprecation warning when using :interval column is used in PostgreSQL database

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

deprecatedになっていたPostgreSQLinterval datatypeをStringとして扱う処理を削除しています。今後は、ActiveSupport::Durationとして扱われるようになります。


Remove deprecated private API in ActiveRecord::Associations::Preloader

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

deprecacatedになっていたActiveRecord::Associations::PreloaderAPIを削除しています。private APIなのでCHANGELOGはなし。


Remove deprecacated support to resolve connection using "primary" as connection specification name

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

deprecatedになっていたconnection specification nameにprimaryという値を指定した場合の挙動を削除しています。


Remove deprecated support to quote ActiveRecord::Base objects

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

deprecatedになっていた#quoteメソッドにActiveRecord::Baseインスタンスを渡した場合の挙動を削除しています。


Remove deprecated support to type cast to database values ActiveRecord::Base objects

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

deprecatedになっていた#type_castメソッドにActiveRecord::Baseインスタンスを渡した場合の挙動を削除しています。


Remove deprecated support to pass a column to type_cast

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

deprecatedになっていた#type_castメソッドにcolumnを渡した場合の挙動を削除しています。


Inline _quote method

Active Recordの修正です。

quoteメソッドが_quoteメソッドを呼び出すだけになっていたのを、quote_quoteで行っていた処理を行うようにして、_quoteを削除するよう修正しています。


Inline _type_cast

Active Recordの修正です。

type_castメソッドが_type_castメソッドを呼び出すだけになっていたのを、type_cast_type_castで行っていた処理を行うようにして、_type_castを削除するよう修正しています。


Improve language in upgrading guide

rails guideのUpgrading Ruby on Railsの修正です。

One file, one constant (at the same top-level)の項の言い回しを修正しています。


Add automatic shard swapping middleware

Active Recordの修正です。

DBのshardのスワッピングを自動で行う為のRack middlewareを追加しています。

複数DB用のmiddlewareと同様に、requestの内容を元にどのsharedを使用するか、というresolverを指定出来るようになっています。

config.active_record.shard_resolver = ->(request) {
  subdomain = request.subdomain
  tenant = Tenant.find_by_subdomain!(subdomain)
  tenant.shard
}

また、request毎のスワッピングを禁止したい場合は、config.active_record.shard_selector{ lock: true }を指定すればよいようになっています。


Introduce ActiveSupport::IsolatedExecutionState for internal use

Active Supportの修正です。

requestやjobのlocal dataの保持にThreadを使うようになっていたのを、Fiberを使用出来るよう修正しています(ThreadだとEnumeratorのように異なるFiberで実行される処理で問題になっていた為)。

Threa / Fiberどちらを使用するかはconfig(config.active_support.isolation_level)で指定出来るようになっており、デフォルトはThreadになっています。Fiberにしたい場合は、左記configに:fiberを指定すればOKです。