2017/09/18分のコミットです。
CHANGELOGへの追加はありませんでした。
Add missing round bracket in “Ruby on Rails 5.1 Release Notes” guide
rails guideのRuby on Rails 5.1 Release Notes
の修正です。
“Deprecated passing string to :if
and :unless
conditional options on set_callback
and skip_callback
"の対応へのコミットのリンクに閉じ括弧が不足していたのを修正しています。
Remove useless condition in reset_association
activerecord/lib/active_record/associations/preloader/through_association.rb
の修正です。
ThroughAssociation#reset_association
メソッドのresetすべきかどうかの判定処理から、不要なoptionのチェック処理を削除しています。
- should_reset = (through_scope != through_reflection.klass.unscoped) || - (options[:source_type] && through_reflection.collection?) + should_reset = through_scope != through_reflection.klass.unscoped
options[:source_type]
が設定されている場合、必ずthrough_scope
が設定されており、through_scope
だけをチェックすれば良い為。
Return through_scope
only if the scope is not empty scope
activerecord/lib/active_record/associations/preloader/through_association.rb
の修正です。
ThroughAssociation#reset_association
メソッドでscopeがempty scopeじゃない場合のみ値を返すよう修正しています。empty scopeの場合scopeのmerge処理が不要な為。
Don’t pass reflection_scope
to preload_scope
if reflection.scope
isn’t given
activerecord/lib/active_record/associations/preloader/through_association.rb
の修正です。
ThroughAssociation#associated_records_by_owner
メソッドでreflection.scope
がnilの場合、不要なorderのmerge処理は行わないよう修正しています。
Early return if records.empty?
in Preloader#preload
activerecord/lib/active_record/associations/preloader.rb
の修正です。
Preloader#preload
メソッドでrecords
が空の場合不要なArrayの生成処理を行わいよう修正しています。
Place class level update
, destroy
, and delete
in Persistence::ClassMethods
https://github.com/rails/rails/commit/9ac7dd47c5e847f7dbfb8d527ee2b917fa9fcd38
Active Recordの修正です。
activerecord::Relation
クラスに定義されていたclass levelのupdate
、destroy
、delete
メソッドをPersistenc::ClassMethods
に移動しています。
そもそもRelationに依存しているメソッドではないので、Persistence::ClassMethods
に定義されている方が適切な為との事です。
Ensure returning affected objects for class level update
and destroy
activerecord/lib/active_record/persistence.rb
の修正です。
class levetのupdate
、destroy
が更新・削除されたオブジェクトのみ返すよう修正しています。
def update(id = :all, attributes) if id.is_a?(Array) - id.map.with_index { |one_id, idx| update(one_id, attributes[idx]) } + id.map.with_index { |one_id, idx| update(one_id, attributes[idx]) }.compact elsif id == :all all.each { |record| record.update(attributes) } else @@ -112,6 +112,7 @@ def update(id = :all, attributes) object.update(attributes) object end + rescue RecordNotFound end
合わせて、RecordNotFound
をrescueするようにしています。これはupdate
、destroy
は内部的にfind
を使用しており、不正なidが指定された場合にRecordNotFound
がraiseされてしまう事があるため。
id
(primary key) is not only an integer [ci skip]
activerecord/lib/active_record/persistence.rb
のdocの修正です。
class levelのdestroy
メソッドのdocに、引数のid
に指定出来るのはIntegerまたはIntegerのArrayであるむね説明が記載されていたのですが、実際はid
はIntegerとは限らない為、説明を修正しています。
Remove the code that swapping scope
and options
activerecord/lib/active_record/associations.rb
、
activerecord/lib/active_record/associations/builder/association.rb
Association.create_reflection
メソッドでscope
引数がHashだった場合、それをoptions
に設定していた処理があったのを削除しています。
scope
にoptions
が設定される事があった為そのような処理にしていたようなのですが、現状そのような状態になる事はない為削除したようです。
Fix collided sequence name detection
activerecord/lib/active_record/connection_adapters/postgresql/column.rb
の修正です。
sequence nameの検出処理に誤りがあり、sequence nameが衝突した場合にserial
の判定が正しく行えないバグがあったのを修正しています。
Remove unused require in ActiveStorage::Variation
activestorage/app/models/active_storage/variation.rb
の修正です。
使用していないactive_support/core_ext/object/inclusion
のrequireを削除しています。
Extract associate_records_to_owner
to refactor Preloader::Association
Active Recordの修正です。
Preloader::Association#preload
で行っていたassociationの関連付けをPreloader::Association#associate_records_to_owner
メソッドで行うようリファクタリングしています。
Preloader
、Preloader::Association
にそれぞれpreload
メソッドがあるのがわかりずらいのと、preload
というメソッド名で中でassociated_records_by_owner
を呼んでいるのがわかりずらい為、上記のようなリファクタを行ったようです。
The name of the key on the owner is abstracted as reflection.join_foreign_key
Active Recordの修正です。
Preloader::Association#owner_key_name
メソッドでreflection.join_foreign_key
の結果を返すよう修正、及び、この対応により不要になったAssociation
の子クラスのowner_key_name
メソッドを削除しています。
The name of the key on the associated record is abstracted as reflection.join_primary_key
Active Recordの修正です。
Preloader::Association#association_key_name
メソッドでreflection.join_primary_key
の結果を返すよう修正、及び、この対応により不要になったAssociation
の子クラスのowner_key_name
メソッドを削除しています。
Remove unused delegation to reflection.options
in Preloader::Association
activerecord/lib/active_record/associations/preloader/association.rb
、
activerecord/lib/active_record/associations/preloader/through_association.rb
の修正です。
使用していないPreloader::Association#options
メソッドを削除しています。
Merge pull request #26707 from jcoleman/add_attribute_names_cache_busting_spec
activerecord/test/cases/attributes_test.rb
の修正です。
Model.columns
の値が変わった時にModel.attribute_names
のキャッシュが破棄される事を確認するテストを追加しています。
rails guideのRuby on Rails Security Guide
の修正です。
Custom credentials
の項のグラマーの修正を行っています。
rails guideのCaching with Rails: An Overview
の修正です。
Javascript
-> JavaScript
に修正しています。
docの修正です。
“’” -> “‘” に修正しています。
add section to guides for discarding and retrying active jobs [ci skip]
rails guideのActive Job Basics
の修正です。
Retrying or Discarding failed jobs
の項を追加し、retry_on
及びdiscard_on
を使用した場合のexampleコードを追加しています。
Use ApplicationJob instead of ActiveJob::Base in guide [ci skip]
rails guideのActive Job Basics
の修正です。
exampleコードの親クラスをActiveJob::Base
からApplicationJob
に修正しています。