なるようになるブログ

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

rails commit log流し読み(2019/04/10)

2019/04/10分のコミットです。

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

railties/CHANGELOG.md

activerecord/CHANGELOG.md


Clarify exists check in logs

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

レコードが存在するかどうかのチェック処理の際のログをxx Exists"からxx Exists?に修正しています。

xx Existsだと存在チェックの為の処理である、という事が少しわかりづらい為との事です。


Merge pull request #35905 from BatedUrGonnaDie/dont-override-job-seed-adapter

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

Seed database with inline ActiveJob job adapterでseedを読み込む際にActive Jobのadapterを強制的にinlineにするようにしたのですが、これをadapterがasyncの場合のみinlineにするよう修正しています。

inlineにした事により、modelの作成処理の流れでenqueue jobsを使用している場合(e.g. modelでafter_create { SomeJob.set(wait_until: 5.minutes.from_now).perform_later(self) }を指定等)に、そこでエラーになってしまう(inline adapterだとenqueue jobsを使用出来ない為)というリグレッションが発生していました。で、その対応として、async(デフォルト)の場合のみinlineにするようにし、明示的にadapterが指定されている場合は何もしないようにしています。


Adds named_captures to MatchData to emulate Regex

actionpack/lib/action_dispatch/journey/path/pattern.rbの修正です。

ActionDispatch::Journey::Path::MatchDatanamed_capturesメソッドを追加しています。MatchDataのようにcaptureした値を取得する為のメソッドで、デバッグの際に使用する想定との事です。


Merge pull request #35875 from Shopify/alloc-free-comparisons

Active Recordの修正です。

TypeMetadata、及び、Columnクラスの==hashメソッドの比較処理でオブジェクトの生成を行わないようリファクタリングしています。

どちらのメソッドでも対象となるattributeをArrayに切り出してから処理を行っていたのですが、それをやめて直接値を参照するようにしています。


There is no need to create QueryAttribute to just type cast a value

activerecord/lib/active_record/connection_adapters/abstract/database_statements.rbactiverecord/lib/active_record/insert_all.rbの修正です。

type castをするのに、Relation::QueryAttributeインスタンスを作成し使用していたの、Relation::QueryAttributeは使用しないよう修正しています。type cast処理だけを行いたい場合Relation::QueryAttributeは無くても処理は行える為。


Remove unused sequence_name in sql_for_insert

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

sql_for_insertメソッドから使用していないsequence_nameメソッドを削除しています。


Add assertions for lazy sync transaction state

activerecord/test/cases/transactions_test.rbの修正です。

テストでtransaction stateについても確認するよう修正しています。


Exclude all node_modules from the RuboCop check

.rubocop.ymlの修正です。

RuboCopの対象から全てのnode_modulesを除くよう修正しています。


Accidentally lost comment in Column#== and Column#hash

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

TypeMetadata及びColumnクラスの==hashメソッドの比較処理を改善した、Merge pull request #35875 from Shopify/alloc-free-comparisonsで、比較するattributeからcommentが誤って削除されてしまっていたのを再度比較の対象とするよう修正しています。


Merge pull request #28155 from lcreid/belongs_to

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

autosave: trueが指定されている、かつ、参照が循環しているassociationがあった場合に、idの指定が無い不正なjoin recordが生成されてしまうバグがあったのを修正しています。


Remove unused callbacks in the Topic model

activerecord/test/models/topic.rbの修正です。

Topic modelから使用していないコールバックを削除しています。

が、実際にはまだ使用している箇所があった為、次のコミットでRevertしています。


Revert "Remove unused callbacks in the Topic model"

という訳で直前のコミットをRevertしています。


Adding type option example to the documentation [ci skip] (#35917)

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

referencesメソッドのdocにtypeオプションを指定した場合のexampleを追加しています。