なるようになるブログ

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

rails commit log流し読み(2024/05/02)

2024/05/02分のコミットです。

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

activestorage/CHANGELOG.md

activesupport/CHANGELOG.md

railties/CHANGELOG.md

activerecord/CHANGELOG.md


Avoid seed data execution in CI by replacing db:setup with db:test:prepare

railties/lib/rails/generators/rails/app/templates/github/ci.yml.ttの修正です。

CIでのDBのセットアップ処理をdb:setupからdb:test:prepareに変更しています。CIで不要なseedのロード処理が行われないようにするため。


docs: Update FormHelper comments to use form_with instead of form_for

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

doc内のexampleコードでform_forを使用している箇所をform_withを使用するよう修正しています。現在はform_withを使用するのが推奨されているため。


Remove deprecated config.active_storage.replace_on_assign_to_many

activestorage/lib/active_storage.rbの修正です。

deprecatedになっていたconfig.active_storage.replace_on_assign_to_manyを削除しています。


Remove deprecated config.active_storage.silence_invalid_content_types_warning

activestorage/lib/active_storage.rbの修正です。

deprecatedになっていた`config.active_storage.silence_invalid_content_types_warningを削除しています。


Remove deprecated support for the pre-Ruby 2.4 behavior of to_time

Active Supportの修正です。

deprecatedになっていた、Ruby 2.4より前のバージョン向けの、to_timeメソッドが返すTimeオブジェクトをtimezoneを保持しないようにした対応を削除しています。合わせて、この挙動のためのDateAndTime::Compatibility.preserve_timezone及びconfig.active_support.to_time_preserves_timezoneをdeprecateにしています。


Remove deprecated :pool_size and :pool_timeout options for the cache storage

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

deprecatedになっていた、cache storageの:pool_size:pool_timeoutオプションを削除しています。


Remove deprecated support for config.active_support.cache_format_version = 6.1

Active Supportの修正です。

deprecatedになっていた、Rails v6.1で作成されたcache format向けのサポートを削除しています。


Remove deprecated constants ActiveSupport::LogSubscriber::CLEAR and ActiveSupport::LogSubscriber::BOLD

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

deprecatedになっていた、ActiveSupport::LogSubscriber::CLEAR及びActiveSupport::LogSubscriber::BOLDを削除しています。


Remove deprecated support to bolding log text with positional boolean in ActiveSupport::LogSubscriber#color

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

deprecatedになっていた、ActiveSupport::LogSubscriber#colorのログテキストを太字にするためのpositional argumentのサポートを削除しています。


Remove deprecated config.active_support.disable_to_s_conversion

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

deprecatedになっていた、config.active_support.disable_to_s_conversionを削除しています。


Remove deprecated config.active_support.remove_deprecated_time_with_zone_name

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

deprecatedになっていた、`config.active_support.remove_deprecated_time_with_zone_nameを削除しています。


Remove deprecated config.active_support.use_rfc4122_namespaced_uuids

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

deprecatedになっていた、config.active_support.use_rfc4122_namespaced_uuidsを削除しています。


Remove deprecated support to passing Dalli::Client instances to MemCacheStore

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

deprecatedになっていた、MemCacheStoreDalli::Clientインスタンスを渡した場合のサポートを削除しています。


Remove deprecated #to_default_s from Array, Date, DateTime and Time

deprecatedになっていた、Array, Date, DateTime 及び Time#to_default_sメソッドを削除しています。


Update deprecator horizon for 7.3

activesupport/lib/active_support/core_ext/module/attr_internal.rbの修正です。

attr_internal_naming_format@ prefixで設定した場合に出力するdeprecateメッセージ内の、機能が削除されるRailsのバージョンが誤っていたのを修正しています。


Remove deprecated SafeBuffer#clone_empty

activesupport/lib/active_support/core_ext/string/output_safety.rbの修正です。

deprecatedになっていた、SafeBuffer#clone_emptyを削除しています。


Remove deprecated ActiveSupport::Deprecation delegation to instance

activesupport/lib/active_support/deprecation.rbactivesupport/lib/active_support/deprecation/instance_delegator.rbの修正です。

deprecatedになっていた、ActiveSupport::Deprecationインスタンスへのdelegate処理を削除しています。


Remove deprecated support to call the following methods without passing a deprecator

Active Supportの修正です。。

deprecatedになっていた、deprecatedeprecate_constantなどのdeprecate関連のメソッドをdeprecatorの指定なしで呼び出した場合の挙動を削除しています。


Remove deprecated ActiveSupport::Notifications::Event#children and ActiveSupport::Notifications::Event#parent_of?

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

deprecatedになっていた、ActiveSupport::Notifications::Event#children及びActiveSupport::Notifications::Event#parent_of?を削除しています。


Remove unnecessary deprecation silencing in cache_store_compression_behavior.rb

activesupport/test/cache/behaviors/cache_store_compression_behavior.rbの修正です。

不要なdeprecation silencingの処理を削除しています。


Upgrade prism

Gemfile.lockの修正です。

prism gemのバージョンを最新バージョンに更新しています。


Remove deprecation on calling assert_equal with nil

railties/test/application/backtrace_cleaner_test.rbの修正です。

deprecatedになっている、assert_equalの第一引数にnilを指定している処理を、assert_nilを使用するよう修正しています。


Remove deprecated Rails.application.secrets

railtiesの修正です。

deprecatedになっていた、Rails.application.secretsを削除しています。


Remove deprecated Rails.config.enable_dependency_loading

railties/lib/rails/application/configuration.rbの修正です。

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


Remove deprecated find_cmd_and_exec console helper

railties/lib/rails/commands/dbconsole/dbconsole_command.rbの修正です。

deprecatedになっていた、find_cmd_and_execメソッドを削除しています。


Remove deprecated Rails::Generators::Testing::Behaviour

railties/lib/rails/generators/testing/behavior.rbの修正です。

deprecatedになっていた、Rails::Generators::Testing::Behaviourを削除しています。


Pass validate(check)constraint through change_table

activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rbの修正です。

validate_constraintchange_table block内で使用できるよう修正しています。

change_table :products do |t|
  t.check_constraint "price > discounted_price", name: "price_check", validate: false
  t.validate_check_constraint "price_check"
end

Register Rails console commands/helpers with its latest extension APIs

railtiesの修正です。

Rails console commandとhelperを、IRB v1.13で追加されたextension APIsを使用して実装するよう修正しています。これにより、Rails が追加しているcommandとhelperがIRBのhelpで正しく表示されるようになっています。

参考:Extend IRB


Merge pull request #51702 from akhilgkrishnan/fix-guides-broken-link

rails guideの修正です。

guide内のanchor linksが壊れてないかをチェックするためのguides:lint taskを追加しています。


Add support for recursive CTE in Active Record

Active Recordの修正です。

recursive Common Table Expression (CTE)の為のメソッド(with_recursive)をActive Recordに追加しています。

Post.with_recursive(
  post_and_replies: [
    Post.where(id: 42),
    Post.joins('JOIN post_and_replies ON posts.in_reply_to_id = post_and_replies.id'),
  ]
)

上記を実行した場合、下記のSQLが生成されるようになっています。

WITH RECURSIVE "post_and_replies" AS (
  (SELECT "posts".* FROM "posts" WHERE "posts"."id" = 42)
  UNION ALL
  (SELECT "posts".* FROM "posts" JOIN post_and_replies ON posts.in_reply_to_id = post_and_replies.id)
)
SELECT "posts".* FROM "posts"

Fix typo from Changelog [ci skip]

activerecord/CHANGELOG.mdの修正です。

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


WithChain does not exist in the codebase

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

withメソッドで存在しないクラスを使用している箇所があったのを修正しています。


Don't cast stale_state to String

Active Recordの修正です。

associationの状態を返すstale_stateメソッドで、結果をStringに変換してから返していたのをStringに変換しないよう修正しています。オブジェクトの生成数を減らす為、かつ、Stringに変換しなければならない理由が無さそうだった為。


Merge pull request #51710 from akhilgkrishnan/document-devecontainer

rails guideのGetting Started with Railsの修正です。

rails newが生成するfile/folderについて説明している箇所に、.devcontainer folderについての説明を追加しています。


Merge pull request #51409 from fatkodima/fix-destroy_async-job-for-cpk

Active Recordの修正です。

composite primary keyを使用しているmodelで、associationをdestroy_async jobで削除出来ないバグがあったのを修正しています。