なるようになるブログ

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

rails commit log流し読み(2019/03/01)

2019/03/01分のコミットです。

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

activerecord/CHANGELOG.md


[ci skip] The find method coerces the given arguments to integer if the primary key is integer

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

[ci skip] Fix the documentation of ActiveRecord::FinderMethods#findで修正したto_iメソッドが呼ばれる条件の説明に誤りがあった(primary keyがintegerの場合にto_iが呼ばれるので元の説明が正しい)のを再度修正しています。


Removes unnecessary dot in regexp

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

TranslationHelper#html_safe_translation_key?メソッドの正規表現から、不要なドットを削除しています。


Reset dirty topics table for SerializedAttributeTest

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

SerializedAttributeTest実行時にtopics tableをリセットするよう修正しています。

topics tableの状態を変えてしまうテストがあり、その影響でSerializedAttributeTestがエラーになってしまうのを避ける為。


Avoid Topic.dup to prevent weird test failure

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

test_serialized_attribute_works_under_concurrent_initial_accessでテスト用にmodelをdupしていた(テスト内でattributeを変更しており他のテストに影響が出るのを避ける為)のを、Class.newでサブクラスを作成するよう修正しています。

dupしてクラスを作成すると何故かエラーになってしまう事がある為。


Remove unused requires

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

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


Merge pull request #33611 from willianveiga/feature/reselect-method

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

ActiveRecord::QueryMethodsselect statementを再指定する為のreselectメソッドを追加しています。 unscope(:select).select(fields)のショートハンド。

Post.select(:title, :body).reselect(:created_at)
# => SELECT `posts.created_at` FROM `posts`

Relax table name detection in from to allow any extension like INDEX hint

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

fromメソッドのテーブル名取得処理を修正し、from("comments USE INDEX (PRIMARY)")のようなINDEX hintを含むSQLも使用出来るよう修正しています。Rails 5.2まではこのような使い方が出来、元の挙動を維持する為。


Merge pull request #35431 from kamipo/enable_sql_cache_on_find

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

base classではfindメソッドでSQL statement cacheが有効になるよう修正しています。