なるようになるブログ

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

rails commit log流し読み(2019/02/27)

2019/02/27分のコミットです。

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

activerecord/CHANGELOG.md


fixes different count calculation when using size manual select with DISTINCT

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

selectDISTINCTを指定 + countを使用した場合に、relationがload済みかどうかで結果が変わる(relationがloadされていない場合、select部分が無視されたcountが実行される)バグがあったのを修正しています。


[ActiveStorage] Ensure that the _blob association is properly loaded when attaching ::One

activestorage/lib/active_storage/attached/changes/create_one.rbの修正です。

has_one_attachedメソッドを使用している場合に、attachment save時にxx_blob associationが正しくロードされないバグがあったのを修正しています。


Fix random CI failure due to non-deterministic sorting order

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

assertionで値を比較する際に、値をidでsortしてからチェックするよう修正しています。 sortを指定しないと結果が不定になる為。


Test that no datetime precision isn't truncated on assignment

activerecord/test/cases/date_time_precision_test.rbactiverecord/test/cases/time_precision_test.rbの修正です。

値指定時にdatetime precisionが切り捨てられない事を確認するテストを追加しています。


Don't cache find_by statements on STI subclasses

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

STIのサブクラスでfind_by文をキャッシュしないよう修正しています。

type IN (?,?,?,?)部分が動的に変わる(サブクラス毎に変わる)為。


Merge pull request #35411 from rails/pass-locals-to-template

Action Viewの修正です。

ActionView::Template#initializeの引数にlocalsを指定するのを必須にするよう修正しています(この時点では互換性の為に値を指定しないでも問題無いようになっていま)。

No nil format on templates や、Template has one variant と同様の対応で、template object生成時に必要な値を全て保持出来るようにする為。


Fix code examples' indentation in ActionDispatch::Routing [ci skip]

actionpack/lib/action_dispatch/routing.rbのdocの修正です。

ActionDispatch::Routing moduleのdoc内のexampleコードのインデントがおかしくなっていたのを修正しています。


Add negative scopes for all enum values (#35381)

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

enum定義時にnegative scope(not_xxx)も定義するよう修正しています。

class Post < ActiveRecord::Base
  enum status: %i[ drafted active trashed ]
end

Post.not_drafted # => where.not(status: :drafted)
Post.not_active  # => where.not(status: :active)
Post.not_trashed # => where.not(status: :trashed)

:scissors:

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

不要なスペースを削除するよう修正しています。


Fix preload with nested associations

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

through associationのpreload処理で、middle recordがnilの場合にassociationのreset処理を行わないよう修正しています。

nestしたassociationをpreloadする際にmiddle recordがnilになってしまう事があり、その場合にエラーになってしまうのを避ける為。


Run activesupport's memcache store tests on Buildkite

Active Supportの修正です。

テストの際に使用するmemcache serverをMEMCACHE_SERVERS env経由で指定するよう修正しています。memcache storeに関するテストがBuildkite上で動作するようにする為。


Fix test that was broken by adding a default scope to an existing model

Active Recordのテストの修正です。

先の、Fix preload with nested associationsの修正の際に、既存のmodelのdefault_scopeを追加したのですが、その影響で既存のテストが壊れてしまったので、default_scopeを指定する為のmodelを既存のmodelとは別に定義するよう修正しています。


Fix random CI failure due to non-deterministic sorting order

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

assertionで値を比較する際に、値をidでsortしてからチェックするよう修正しています。 sortを指定しないと結果が不定になる為。


Fix indentation [ci skip]

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

インデントがずれてしまった箇所があったのを修正しています。