なるようになるブログ

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

rails commit log流し読み(2021/10/27)

2021/10/27分のコミットです。

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

activesupport/CHANGELOG.md


remove with_tags from query_logs

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

ActiveRecord::QueryLogsからwith_tagsメソッドを削除しています。

block-scoped tagが必要な場合、contextを使用すれば済むのでwith_tagsを使う要件は無いはず、という理由です。


Link to Host Authorization guides on blocked_host page

actionpack/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erbactionpack/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erbの修正です。

hostがblockされた場合に表示されるエラーページに、Configuring Rails Applications — Ruby on Rails Guidesへのリンクを追加しています。


Merge pull request #43535 from Shopify/remove-query-logs-null-object

Active Recordの修正です。

ActiveRecord::QueryLogsについて、null objectを使用しないようにする等のリファクタリングを行っています。


Skip RedisCacheStore test if no Redis server is running

activesupport/test/cache/stores/mem_cache_store_test.rbactivesupport/test/cache/stores/redis_cache_store_test.rbの修正です。

Redis serverが起動していない場合、RedisCacheStoreに関するテストを実行しないよう修正しています。


Properly clear the ActiveRecord::QueryLogs context

Active Recordの修正です。

request / jobの実行後に必ずActiveRecord::QueryLogsのcontextをclearするよう修正しています。contextが残っていると他のrequest / jobに影響を与えてしまう可能性がある為。


Merge pull request #43545 from etiennebarrie/check-for-default-function-before-attribute-change

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

partial insertsの対象のattributeのチェックをする際に、attributeが変更されているかどうかをチェックしてからdefault functionが指定されているかどうかをチェックしていたのを、default functionが指定されているかどうかを先にチェックするよう修正しています。


Call Executor#wrap around each test

Active Support、Active Recordの修正です。

Rails.application.executor hookをテストの実行前後に実行するよう修正しています。Rails.application.executor hook経由でrequest / jobの状態をリセットする処理(ActiveSupport::CurrentAttributesのリセットなど)を呼ばれるようになっており、より容易にそれらの状態のリセットをしやすくするようにする為。

が、integration testsの挙動を壊してしまう、という問題がある為、後ほどRevertされています。


Use the native Class#descendants if available

activesupport/lib/active_support/core_ext/class/subclasses.rbの修正です。

Ruby本体のClass#descendantsが使える場合、そちらを使用するよう修正しています。Ruby 3.1でRuby本体にClass#descendantsが追加された為。参考: Feature #14394: Class.descendants - Ruby master - Ruby Issue Tracking System


Fix STI in available_records causing new instances of records to be loaded from database

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

ActiveRecord::Associations::Preloadeavailable_recordsオプションにSTI modelを指定した場合に、load済みのレコードがある場合も必ずDBからのデータ取得が行われてしまっていたのを、load済みのデータがある場合はDBからのデータ取得が行われないよう修正しています。