なるようになるブログ

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

rails commit log流し読み(2022/09/21)

2022/09/21分のコミットです。

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

activejob/CHANGELOG.md


Merge pull request #45770 from RyanMacG/update-docs-for-unscoped

activerecord/lib/active_record/scoping/default.rbのdocの修正です。

unscopedメソッドのdocに、associationに対してunscopedを指定した場合の挙動についての説明を追加しています。


Typo in error_reporting guide [ci-skip]

rails guideのError Reporting in Rails Applicationsの修正です。

doc内のタイポの修正を行っています。


Fix being able to pass --force to db:system:change

railties/lib/rails/commands/db/system/change/change_command.rbの修正です。

db:system:changeコマンドに、--forceオプションを渡せるよう修正しています。


Merge pull request #46080 from jdelStrother/sidekiq-activejob

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

Sidekiqの処理を行うのに、Sidekiq::Clientを直接使用いていたのを、ラッパークラス(JobWrapper.perform_async)経由で処理を行うよう修正しています。Sidekiqのclientを変更していた場合(Sidekiq::TransactionAwareClientを使用している場合等)に、そちらのclientで処理を行えるようにする為。


Communicate minimum Sidekiq version in its adapter

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

Sidekiq 4.1以上がロード出来ない場合にエラーとなるよう修正しています。直前の変更がSidekiq 4.1以上を必要とする対応だった為。


Ignore qunit for spelling check

.github/workflows/lint.ymlの修正です。

spelling checkにcodespellのみを使うよう修正、及び、qunitのファイルはspelling checkの対象にしないよう修正しています。


Merge pull request #45216 from yahonda/rubocop_minitest_020_enables_skip_ensure_cop

テストの中で特定の条件の場合テストをskipするようにしていたのを、条件をテストの外で行うようにして、そもそもskip対象の場合はテストが実行されないよう修正しています。テストが実行されてないのにテストの中で定義されているensureだけが実行されてしまうのを避ける為。

rails commit log流し読み(2022/09/20)

2022/09/20分のコミットです。

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

actionview/CHANGELOG.md


Merge pull request #45502 from ehelms/add-license

rails.gemspecの修正です。

gemファイルにライセンスファイルを含むよう修正しています。


Don't delegate tasks to ActiveRecord::Base

Active Recordの修正です。

各adapterのdatabase taskクラスでActiveRecord::Baseに一部メソッドをdelegateしていたのを、delegateは使用しないよう修正しています。database taskクラスのリファクタリングを予定しており、その準備との事です。


Register autoload for ActiveRecord::LogSubscriber

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

ActiveRecord::LogSubscriberをautoloadの対象に追加しています。Fix Active Record :db_runtime metricの修正により、ActiveRecord::LogSubscriberrailtiesの処理の延長でロードされなくなくなり、autoloadの対象にしておかないと定数参照時にエラーになってしまう為。


upgrade to QUnit 2 for ujs tests

Action Viewのテストの修正です。

ujsのテストで使用しているQUnitのバージョンを2系に更新しています。


Use system(.., exception: true) for dummy apps

Improve error messages on bin/setupで行った、bin/setupのコマンド実行処理をsystemメソッド + exceptionオプションに変更する対応を、各dummyアプリケーションのbin/setupに適応しています。


Allow passing a class to dom_id

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

dom_idメソッドにclassを指定出来るよう修正しています。

dom_id(Post) # => "new_post"

rails commit log流し読み(2022/09/19)

2022/09/19分のコミットです。

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

activerecord/CHANGELOG.md


Improve error messages on bin/setup

railties/lib/rails/generators/rails/app/templates/bin/setup.ttの修正です。

bin/setup内のコマンド実行処理で、systemメソッドにexceptionオプションを指定するよう修正しています。元々はexceptionオプション無しのsystemメソッドで、処理が失敗した場合に独自のエラーメッセージを出力するようになっていたのですが、exceptionオプションを指定した方がコマンド失敗時のより詳細なエラーメッセージを取得出来る為。


Merge pull request #46048 from rails/fix-hash-collisions

Active Record、Active Modelの修正です。

Active Recordの検索条件にHashなどのObjectを指定、かつ、一度検索処理をした後に、同じObjectの値を変更して再度検索処理をしたような場合、正しい結果が得られない(最初に実行した結果がquery cacheが返される)事がまれに発生するバグがあったのを修正しています。

参考: Querying with mutable bound parameters can produce false-positive query cache hits


Updating the ActiveRecord::Store and changing it back should not mark accessor as changed

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

store_accessor attritbuteの値を一度変更し、その後元の値に戻した場合に、本来変更が無い、と見なされる筈のdirtyの値が変更がある、と判定されてしまうバグがあったのを修正しています。

rails commit log流し読み(2022/09/18)

2022/09/18分のコミットです。

CHANGELOGへの追加はありませんでした。


Use sslmode option instead of ssl_mode for MySQL command connections

activerecord/lib/active_record/tasks/mysql_database_tasks.rbrailties/lib/rails/commands/dbconsole/dbconsole_command.rbの修正です。

MySQL--ssl-modeを指定するオプション名を、sslmodeからssl_modeに変更しています。mysql2 gemでのオプション名がssl_modeになっておりそれに合わせる為。


Fix word case

windowsWindowsに、jrubyJRubyにそれぞれ修正しています。


Fix word case. html -> HTML

htmlHTMLに修正しています。

rails commit log流し読み(2022/09/17)

2022/09/17分のコミットです。

CHANGELOGへの追加はありませんでした。


Fix word case. json -> JSON

各箇所のjsonJSONに変更しています。


Improve warning when db is missing

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

指定されたDBが見つからなかった場合のメッセージのグラマー、言い回しの修正を行っています。


Fix logger tags for SchemaMigration and InternalMetadata

activerecord/lib/active_record/internal_metadata.rbactiverecord/lib/active_record/schema_migration.rbの修正です。

SchemaMigration、及び、InternalMetadataのログで、インスタンスがそのままログ出力されてしまうようになっていたのを、クラス名を出力するよう修正しています。


Merge pull request #42933 from ghiculescu/postgres-column-types

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

PostgreSQL adapterのquery実行時のoid typeの取得処理を、幾つかの型では行ってなかった(pg gemでcastされたtypeをそのまま使用していた)のを、全ての型で変換処理を行うよう修正しています。ActiveRecord::Result#column_typesメソッドで正しく型情報を取得出来るようにする為。


Tiny copy fix in CHANGELOGs [ci-skip]

activerecord/CHANGELOG.mdrailties/CHANGELOG.mdの修正です。

CHANGELOGのグラマーの修正を行っています。


Add CHANGELOG entry for #45738 [ci-skip] (#46056)

actioncable/CHANGELOG.mdの修正です。

connected()メソッドのcallbackでreconnect処理が行われたどうかを判別出来るようにする為のパラメータ({reconnected})を追加した、Add ability to handle reconnects with the connected() callbackの対応についてCHANGELOGにエントリーを追加しています。

rails commit log流し読み(2022/09/16)

2022/09/16分のコミットです。

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

activesupport/CHANGELOG.md

activerecord/CHANGELOG.md

railties/CHANGELOG.md


Fix link for ActionController in Layouts and Rendering docs

rails guideのLayouts and Rendering in Railsの修正です。

renderメソッドのAPI docのリンク先をAbstractController::Rendering#renderからActionController::Renderer#renderに修正しています。通常アプリケーションで使用するのはActionController::Renderer#renderメソッドである、かつ、オプションについての説明が記載されているのはActionControllerの方のdocだけな為。


Merge pull request #45298 from joshuay03/fix-inconsistent-polymorphic-association-autosave

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

polymorphic associationsのautosave処理で、recordが変更されたかどうかをチェックする際に、idだけ使用してpolymorphicのtypeが考慮されないバグがあったのを修正しています。


Add puma app server to Gemfile in order to start test/dummy (#45950)

railties/lib/rails/generators/rails/plugin/plugin_generator.rbの修正です。

dummy application用のGemfileにpumaを含むよう修正しています。アプリケーションサーバの指定が無いとplugin用のserverの起動がエラーになる為。


Pass deprecator to AS::Deprecation callbacks

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

ActiveSupport::Deprecation behavior callbackにdeprecator instanceを渡すよう修正しています。下記のようにcallbackの引数を3つ指定、または、splat argを指定した場合に受け取れるようになっています。

->(message, callstack, deprecator) { ... }
->(*args) { ... }
->(message, *other_args) { ... }

Merge pull request #46043 from yahonda/remove_rubinius_code

Rubinius向けのコードを削除しています。Rubiniusがもうメンテされていない為。


Merge pull request #46008 from p8/activerecord/ssl-verify-connection

activerecord/lib/active_record/tasks/mysql_database_tasks.rbrailties/lib/rails/commands/dbconsole/dbconsole_command.rbの修正です。

MySQLのdbtask、及びdbconsoleコマンドで、MySQLssl-modeオプションを使用出来るよう修正しています。


Add assert_error_reported and assert_no_error_reported

Active Supportの修正です。

exceptionが発生し、かつ、そのexceptionがRails.errorでreportされた事を確認する為のassert_error_reportedメソッド、及び、exceptionが発生したがRails.errorでreportされないことを確認する為のassert_no_error_reportedメソッドを追加しています。


Merge pull request #45771 from andrewn617/type-cast-attribute-changed-from-and-to-options

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

ActiveModel::Dirty#attribute_changed?メソッドのfromtoオプションの値をtype castするよう修正しています。enumの値がSymbolやStringで指定された場合にも正しくチェック出来るようにする為。


Added status in API documentation for ActionController::Renderer#render

actionpack/lib/action_controller/renderer.rbのdocの修正です。

ActionController::Renderer#renderメソッドのdocに、:statusオプションについての説明を追加しています。

rails commit log流し読み(2022/09/15)

2022/09/15分のコミットです。

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

activesupport/CHANGELOG.md


Remove redundant ELSE branch from the ActiveRecord::Base.in_order_of SQL query

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

ActiveRecord::Base.in_order_ofが生成するSQLから不要なELSE branchを削除しています。


Fix flaky PostgreSQL enum migration reversibility test

activerecord/test/cases/adapters/postgresql/invertible_migration_test.rbの修正です。

テストで生成したenumの削除処理が行われていなかったのを修正しています。


Merge pull request #46026 from jonathanhefner/deprecation-non-global-disallowed_warnings

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

ActiveSupport::Deprecation#disallowed_warningsで設定した内容が、全てのActiveSupport::Deprecationインスタンスに影響が出るようになっていたのを、設定したインスタンスでのみ影響を受けるよう修正しています。合わせて、globalのActiveSupport::Deprecation.disallowed_warningsで設定した内容は、globalのActiveSupport::Deprecation.warnにのみ影響が出るようにし、個別のインスタンスの設定には影響が出ないよう修正しています。


Test more AS::Deprecation behavior callbacks

activesupport/test/deprecation_test.rbの修正です。

ActiveSupport::Deprecationbehaviorにcallbackを指定した場合のテストを追加しています。


Derive arity of AS::Deprecation behavior callbacks

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

ActiveSupport::Deprecationのcallbackにarityが定義されていないobject(e.g. callable object)も指定出来るよう修正しています。


Prefer capture_io in AS::Deprecation tests

activesupport/test/deprecation_test.rbの修正です。

stderrをcaptureするのにRails独自のhelperメソッドを使用していたのを、minitestが提供しているメソッド(capture_io)を使用するよう修正しています。

が、他の処理と処理は合わせた方が可読性が良いだろう、という事で後ほどRails独自のhelperメソッドを使うよう戻しています。


Merge pull request #45877 from neilvilela/nc-composed-of-hash

activerecord/lib/active_record/aggregations.rbのdoc、及び、activerecord/test/cases/aggregations_test.rbの修正です。

`composed_ofmappingを指定した場合のテスト、及び、docにexampleを追加しています。


Switch back to capture in AS::Deprecation tests

activesupport/test/deprecation_test.rbの修正です。

Prefer capture_io in AS::Deprecation testsで行った変更を元に戻しています。


Merge pull request #45546 from skipkayhil/decaffeinate-ujs

Action Viewの修正です。

rails-ujsのコードをCoffeeScriptから素のJS(ES2015 module)に変更しています。


Merge pull request #46009 from johnnyshields/bundler-use-windows-platform

railtiesの修正です。

GemfileでplatoformにWindowsを指定するのに、:mswin, :mswin64, :mingw, :x64_mingwを使用していたのを、そのaliasである:windowsを使用するよう修正しています。


Add link to 7.0 release notes in upgrade guide

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

Upgrading from Rails 6.1 to Rails 7.0セクションに、Rails 7.0のリリースノートへのリンクを追加しています。


Add link to 7.1 release notes in upgrade guide

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

Upgrading from Rails 7.0 to Rails 7.1セクションに、Rails 7.1のリリースノートへのリンクを追加しています。


Fix Active Record :db_runtime metric

Active Recordの修正です。

:db_runtime metricの為の値の保持をActiveRecord::LogSubscriberで行っていたのを、ActiveRecord::RuntimeRegistryで行うよう修正しています。