なるようになるブログ

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

rails commit log流し読み(2017/06/29)

2017/06/29分のコミットです。

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

activerecord/CHANGELOG.md


Merge pull request #29595 from fatkodima/result_lambda_class_checking

actionpack/lib/abstract_controller/callbacks.rbactivesupport/lib/active_support/callbacks.rbの修正です。

callback処理の中で引数がProcがどうかチェックしていたのを削除しています。渡される値は必ずProcであり、チェックが不要な為。


Merge pull request #29588 from greysteil/add-gemspec-links

コンポーネントのgemspecに、metadataとしてsource_code_urichangelog_uriを設定しています。

s.metadata = {
  "source_code_uri" => "https://github.com/rails/rails/tree/v#{version}/activemodel",
  "changelog_uri"   => "https://github.com/rails/rails/blob/v#{version}/activemodel/CHANGELOG.md"
}

こんなの書けるんですねえ。知らなかった。参考:Leverage metadata to populate gems urls v2 by kbrock · Pull Request #1234 · rubygems/rubygems.org

因みにPRを投げた方は、Dependabot - Automated Dependency UpdatesでPRを投げる際のリンクに使用する予定だそうです。


Merge pull request #29600 from kamipo/show_query_cache_keys

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

test_exceptional_middleware_clears_and_disables_cache_on_errorでテストに失敗した際にquery cacheのkeyを表示するよう修正しています。

test_exceptional_middleware_clears_and_disables_cache_on_errorは最近CI上でランダムでエラーになるようになっており、エラーになった際の調査の為に表示するようにしています。


Add a test case for unscoping default_scope in associations

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

associationのdefault_scopeをunscopeした場合のテストを追加しています。


Don’t passing klass.connection to AssociationScope

Active Recordの修正です。

Associations::AssociationScope.scope#scopeの引数からconnectionを削除しています。

上記メソッドは第一引数にassociationを渡しており、associationからconnectionを取得出来る為。


Enable query cache if set a configurations

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

DBへのconnectionがないと、ActiveRecord::Base.cacheを呼び出してもquery cacheが使用されなかったのを、connectionが無い状態でも接続先の情報があればquery cacheが使用されるよう修正しています。


Fix eager loading to respect store_full_sti_class setting

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

eager loadを行う際にstore_full_sti_classの設定内容が無視されていたのを、store_full_sti_classが設定されている場合も正しいtypeをloadするよう修正しています。


Fix grammar for documentation of rails/command.rb [ci skip]

rails guideのThe Rails Initialization Processの修正です。

rails/command.rbの項のグラマーの修正を行っています。


Show query cache keys in test_middleware_caches

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

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

test_middleware_cachesでテストに失敗した際にquery cacheのkeyを表示するよう修正しています。

先ほどのtest_exceptional_middleware_clears_and_disables_cache_on_errorと同様に、ランダムでテストがエラーになってしまう為、調査用。


Remove delegating to arel in a relation

Active Recordの修正です。

Relationで一部処理をarelにdelegateしていたのを、delegateしないよう修正しています。

delegateが必要なのはrelation.bound_attributesを使用する場合だけで、その場合は直接relation.arelを呼ぶようににして対応しています。


Merge pull request #28928 from kamipo/remove_habtm_initialize

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

不要なHasAndBelongsToManyReflection#initializeメソッドを削除しています。


Merge pull request #29076 from kamipo/use_timestamp_attributes_for_update_in_model

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

Timestamp#max_updated_column_timestampメソッドのtimestamp_namesのデフォルト引数を取得するのにtimestamp_attributes_for_updateを使用していたのを、timestamp_attributes_for_update_in_modelメソッド経由で値を取得するよう修正しています。


Merge pull request #29416 from kamipo/remove_unused_subject_model

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

使用していないSubject modelを削除しています。


Merge pull request #29301 from kamipo/receiver_in_scope_should_be_relation

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

Scoping::Named#scopeメソッドでinstance_execを実行するレシーバーがklassになっていたのを、relationになるよう修正しています。

default_scopeやassociationのscope処理ではレシーバーがrelationになっており、合わせる為に、との事です。


Merge pull request #29129 from kamipo/prevent_extra_through_scope

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

reset_associationメソッド内でthrough_scopeを呼び出していたのを、reset_associationの引数にthrough_scopeを渡すようにして、不要な呼び出しを行わないよう修正しています。


Merge pull request #29612 from kamipo/use_quote_method_rather_than_single_quote

Active Recordの修正です。

カラムやテーブルのクォート処理に'を指定している箇所があったのを、quoteメソッドを使用するよう修正しています。


Merge pull request #28932 from kamipo/remove_method_missing_in_relation_delegation

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

呼び出される事の無いRelation::Delegationmethod_missingを削除しています。


Merge pull request #29569 from kamipo/fix_to_scoping_is_correctly_restored

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

STI subclassが、parent classのunscoped blockの中でunscopedを使用した場合に、blockの外に出ても元のscopeに正しく戻されないバグがあったのを修正しています。


Merge pull request #29616 from kamipo/remove_unused_aliased_table_name

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

使用していないAssociationaliased_table_nameメソッドを削除しています。


Deprecate delegating to arel in Relation

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

Relationareldelegateしていたメソッドがdeprecateになりました。

現状、areldelegateするメソッドがどれかが不明確な状態になっています(klassdelegateするメソッドとareldelegateするメソッドが混在している)。不明確な状態をなくす為に、arelへのdelegateは無くす方向で考えいるようで、その前段階として、delegateが行われた場合、deprecateメッセージが表示されるよう対応しています。


Fix the next version of Rails from 5.3 to 6.0

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

deprecateメッセージで表示する次のRailsのバージョンを5.3から6.0に更新しています。5.2の次は6.0になる予定の為。