2015/09/25分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Implement ActiveRecord::Base.ignored_columns
validates_acceptance_ofshouldn't require a database connection
Implement ActiveRecord::Base.ignored_columns
activerecord/lib/active_record/model_schema.rbの修正です。
Active Recordに認識させたくないカラムを指定する為の、ActiveRecord::Base.ignored_columnsを追加しています。
class Developer < ActiveRecord::Base self.ignored_columns = %w(first_name last_name) end
soundcloud/lhm やpt-online-schema-change のような、オンラインのスキーマ変更ツールを使う際に役に立つのでは、との事です。
Fix typo in ignored_columns test [skip ci]
activerecord/test/cases/base_test.rbの修正です。
テスト名でattributeをattirbuteにタイポしている箇所があったので修正しています。
Make assert_difference return the result of the yielded block.
activesupport/lib/active_support/testing/assertions.rbの修正です。
assert_differenceメソッド、assert_no_differenceメソッドがブロックを実行した結果を戻り値として返すよう修正しています。
post = assert_difference -> { Post.count } do
Post.create
end
assert_predicate post, :persisted?
Clean up the implementation of AR::Dirty
Active Record / Active Modelの修正です。
ActiveRecord::Dirtyで行っていたattributesのdirtyチェック処理をattribute objectsで行うようリファクタリングしています。
これにより、dirtyチェックの多くが遅延評価されるようになり、attributesの書き込み処理の性能が向上したとの事です。
Encapsulate a lot of the logic from Dirty in an object
activerecord/lib/active_record/attribute_methods/dirty.rb、
activerecord/lib/active_record/attribute_mutation_tracker.rbの修正です。
AttributeMethods::Dirtyで行っていたdirtyチェック処理の多くを、新規に作成したAttributeMutationTrackerクラスで行うよう修正しています。
Improve the performance of save and friends
Active Record / Active Modelの修正です。
Rails 4.2から、レコードの保存/更新処理の性能が劣化していたのを改善する為の対応を行っています。
dirty trackingが重くなってしまっていた(attributeのインスタンス生成処理が重い?)ので、dirtyチェックを遅延評価出来るよう対応したのと、更新前後の値の比較を容易に出来るようにする為の新たなtracker用クラス(NullMutationTracker)を作成し、対応したとの事です。
We still need to reset @changed_attributes in changes_applied
activerecord/lib/active_record/attribute_methods/dirty.rbの修正です。
changes_appliedメソッドとclear_changes_informationメソッドで@changed_attributesをリセットするよう修正しています。
Add a few debug statements to figure out the build failure
activerecord/test/cases/dirty_test.rbの修正です。
CIでtest_setting_time_attributes_with_time_zone_field_to_itself_should_not_be_marked_as_a_changeのテストがコケてしまうのですが、ローカルでは再現しないらしく、printデバッグ文を一時的に追加しています。
mutate headers before committing the response
actionpack/lib/action_dispatch/http/response.rbの修正です。
response objectの状態をコミット後にヘッダーからContent-Type、Content-Lengthを削除する場合があったのを、コミット前に削除するよう修正しています。
move the Header hash to the super class
actionpack/lib/action_controller/metal/live.rb、
actionpack/lib/action_dispatch/http/response.rbの修正です。
ActionController::Live::Response::Headerクラスを親クラスであるResponseクラス配下に移動しています。
処理をResponseクラスに集約する為に移動させたようです。
build the Set-Cookie header functionally
actionpack/lib/action_dispatch/middleware/cookies.rbの修正です。
writeメソッドで行っていたcookie headerの設定処理を、メソッド(make_set_cookie_header)に切り出しています。
activerecord/test/cases/dirty_test.rbの修正です。
Add a few debug statements to figure out the build failure で追加したデバッグ分を削除しています。
Apply subsecond precision on assignment when using TZ aware attributes
activerecord/lib/active_record/attribute_methods/time_zone_conversion.rbの修正です。
TimeZoneが設定されているdatetime型のattributesをtime objectに変換する際、subsecond precisionの値を設定するよう修正しています。
DB側でsubsecond persisionに対応してない場合ナノ秒がトランケイトされない為、DBから値を読み込んだ際にでナノ秒の値が変わってしまった場合に実質的には値が変わってないのに値が変更されたと認識されてしまう恐れがあるので、対応を追加したようです。
Don't assert fractional seconds can be applied on unsupported adapters
activerecord/test/cases/dirty_test.rbの修正です。
datetime precisionをサポートしていないDBで、datetime型のカラムにprecisionを指定したテストを行わないようskip処理を追加しています。
Quote prepared statements of sanitize_sql_array
activerecord/test/cases/sanitize_test.rbの修正です。
sanitize_sql_arrayメソッドのテストで、エスケープせずにプレースホルダを使用している箇所があったのですが、エスケープしてないSQLは当然危険ですし、実際そのような使い方はされるべきではないだろう、
という事で、エスケープするよう修正しています。
Fix deprecated mime types via constants
actionpack/lib/action_dispatch/http/mime_type.rbの修正です。
先日deprecateになったmime typeを定数から取得する処理を使用している箇所があったのを、Mime::Type経由で値を取得するよう修正しています。
validates_acceptance_of shouldn't require a database connection
activemodel/lib/active_model/validations/acceptance.rbの修正です。
validates_acceptance_ofを使用している場合に、クラスロード時にDBへの接続が必要だったのを、クラスロード時にはDBへの接続を行わずに済むよう修正しています。
元々はvalidates_acceptance_ofの初期化処理で、attributeと存在チェックの為にattribute_method?メソッドを使用しており、このメソッドがDBへの接続が必須だったのですが、
method_missingを使用して存在チェックを遅延評価されるよう修正したようです。