2018/01/10分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Fixed inconsistency with
first(n)
when used withlimit()
. - Fix nested
has_many :through
associations on unpersisted parent instances.
resolve inconsistencies between first and to_a.first with limit
activerecord/lib/active_record/relation/finder_methods.rb
の修正です。
first(n)
+ limit
メソッドを使用した場合に、limit
に指定した値が無視されていた(指定した値で結果が制限されていなかった)のを、結果のレコード数がlimit
に指定した値になるよう修正しています。
last(n)
+ limit
を使用した場合と挙動を合わせる為。
Merge pull request #31534 from claudiob/kaspth-approach
rails new
した際にActive Storage用のmigrationファイルが自動で生成されるようになっていたのを、生成しないよう修正しています。
代わりに、Active Storageを使用しようとして、Active Storage用のテーブルが存在しない場合、エラーメッセージにbin/rails active_storage:install
を実行する旨説明を表示するよう修正しています。
Merge pull request #29685 from ayanko/fix-slow-name-error-missing-name
activesupport/lib/active_support/core_ext/name_error.rb
の修正です。
NameError#missing_name
メソッドでmessage
を取得する際に、original_message
が定義されていれば、そちらの値を使用するよう修正しています。
+ # Since ruby v2.3.0 `did_you_mean` gem is loaded by default. + # It extends NameError#message with spell corrections which are SLOW. + # We should use original_message message instead. + message = respond_to?(:original_message) ? original_message : self.message +
上記コメントにもある通り、NameError#message
はdid_you_mean
によるスペル補正が入り、その分遅いためoriginal_message
を使用するようにしたとの事です。
Bring back passing single record support for Preloader
activerecord/lib/active_record/associations/preloader.rb
の修正です。
Preloader#preload
メソッドのrecords
引数に単一のrecordを渡せるよう修正しています。
Rails 5.1までは渡せるようになっていたのですが、Preloader
クラスはRails内部でのみ使用するクラスであり、Rails内部では必ずArray
で渡すようになっていたため、単一のrecordが渡された場合のケア(Array.wrap
の呼び出し)は削除されていました。
ただ、Preloader#preload
メソッドを直接使用しているケースがあったらしい為(issueが作成された)、互換性の為に再度単一recordを渡せるよう戻しています。
docの修正です。
the
が二回連続で記載されている箇所があったのを修正しています。
railties/test/generators/app_generator_test.rb
、
railties/test/generators/shared_generator_tests.rb
の修正です。
Don't include Active Storage migrations in new appsの対応により不要になったactive_storage:install
のテスト、及び、不要なmigrationが生成されるかどうかのチェックを削除しています。
activerecord/lib/active_record/associations/through_association.rb
、
activerecord/lib/active_record/reflection.rb
の修正です。
has_many :through
associationをnestして使用している場合に、親のインスタンスが永続化されていないと子のインスタンスから値が取得出来ないバグがあったのを修正しています。
class Post < ActiveRecord::Base belongs_to :author has_many :books, through: :author has_many :subscriptions, through: :books end class Author < ActiveRecord::Base has_one :post has_many :books has_many :subscriptions, through: :books end class Book < ActiveRecord::Base belongs_to :author has_many :subscriptions end class Subscription < ActiveRecord::Base belongs_to :book end
上記のようなassociationが定義されていた場合に、post
が永続化されていない場合にpost.subscriptions
が必ず空になってしまっていたのが、正しく値を取得出来るようになっています。
Fix stale_state
for nested has_many :through
associations
activerecord/lib/active_record/associations/through_association.rb
、
activerecord/lib/active_record/reflection.rb
の修正です。
has_many :through
associationをnestして使用している、かつ、through先のrecordが変更された場合に、reflectionの情報が正しくreloadされるよう修正しています。