なるようになるブログ

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

rails commit log流し読み(2024/01/19)

2024/01/19分のコミットです。

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

railties/CHANGELOG.md

activerecord/CHANGELOG.md


Merge pull request #50783 from Shopify/append-pk-to-returning-columns-if-returning-is-empty

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

RETURNINGに他のカラムが指定されていない場合、必ずprimary_keyを返すよう修正しています。Rails 7.0まではカラムが指定されてなかった場合必ずprimary_keyを返すようになっていたのが、Rails 7.1で返さないよう変更されてしまったため、7.0までと同じ挙動になるよう修正しています。


Merge pull request #50775 from mockdeep/rf-thread_fix

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

strict localsを使用している場合に、@templatesへの値の設定処理がスレッドアンセーフになっていたのを修正しています。


[Tests only] Expand trigger populated PK test case to run against more DBs

activerecord/test/cases/persistence_test.rbactiverecord/test/schema/schema.rbの修正です。

DB側のTRIGGERでPKを生成する場合の挙動のテストがPostgreSQLでのみ実行されていたのを、MySQLでも実行でもするよう修正しています。


Merge pull request #50737 from skipkayhil/hm-further-optimize-tag-builder

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

TagBuilderのtag生成処理で不要なオブジェクトの生成を減らすようリファクタリングしています。


Remove outdated comment in ExceptionsWrapper#show? [ci skip]

actionpack/lib/action_dispatch/middleware/exception_wrapper.rbの修正です。

ExceptionsWrapper#show?のコード内から現在の実装と異なる内容のコメントを削除しています。


Print bin/rails help on unrecognized bare options

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

bin/railsに不正なオプションが指定された場合にusageを表示するよう修正しています。

before

$ bin/rails -V
rake, version 13.0.6

$ bin/rails -s
Running 0 tests in a single process (parallelization threshold is 50)
...

$ bin/rails -S
invalid option: -S

after

$ bin/rails -V
Usage:
  bin/rails COMMAND [options]

You must specify a command. The most common commands are:
...

$ bin/rails -s
Usage:
  bin/rails COMMAND [options]

You must specify a command. The most common commands are:
...

$ bin/rails -S
Usage:
  bin/rails COMMAND [options]

You must specify a command. The most common commands are:
...

Fix bin/rails -T when no default task is defined

railties/lib/rails/commands/rake/rake_command.rbの修正です。

default taskが何も定義されていない場合にbin/rails -Tを実行した場合に、UnrecognizedCommandError raiseされてしまうバグがあったのを修正しています。


Remove unsupported values for config.action_dispatch.show_exceptions [ci skip]

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

config.action_dispatch.show_exceptionsについて説明している箇所から、現在は使用出来ない値について説明している箇所を削除しています。


Fix RateLimitingTest assertion for :by option

actionpack/test/controller/rate_limiting_test.rbの修正です。

rate_limitingbyオプションを指定するテストで、byに指定されたオプションに関するテストが正しく行われてなかったのを修正しています。


[Fix #50803] Consistently raise an ArgumentError when passing an invalid argument to a nested attributes association writer

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

nested attributes associationのwriterに不正な値を指定した場合に、ArgumentErrorをraiseするよう修正しています。元々、associationがcollection associationだった場合はArgumentErrorするようになっていたのですが、associationがsingular associationの場合はそうなっておらず、この対応によりsingular associationの場合も同じようにArgumentErrorをraiseするようになっています。


Freeze and dedup quote_column_name and quote_table_name caches

Active Recordの修正です。

quote_column_namequote_table_nameメソッドでfreezeした値を返すよう修正しています。誤って呼び出し側で値を変更してしまうのを避ける為。


Add example to parts documentation [ci-skip]

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

Duration#partsメソッドのdocにexampleコードを追加しています。