2017/01/02分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
Added option to ActiveRecord::CounterCache methods.
activerecord/lib/active_record/counter_cache.rb
の修正です。
counter cacheの値を変更するようの各種メソッドに、指定したtimestampカラムを更新する為のtouch
オプションを追加しています。
# `updated_at` / `updated_on`を更新 Topic.increment_counter(:messages_count, 1, touch: true) Topic.decrement_counter(:messages_count, 1, touch: true) # `last_discussed_at`を更新 Topic.reset_counters(18, :messages, touch: :last_discussed_at) # `updated_at` / `last_discussed_at`を更新 Topic.update_counters(18, messages_count: 5, touch: %i( updated_at last_discussed_at ))
Fix tests with counter cache touching and more.
activerecord/lib/active_record/counter_cache.rb
の修正です。
先ほどのcounter cacheの対応について、メソッド名の修正、不足していたテストの追加等のリファクタリングを行っています。
Replace sleep with synchronization
activerecord/test/cases/scoping/default_scoping_test.rb
、
activerecord/test/models/developer.rb
の修正です。
default scopeのテストでsleepを使用していたのを、CyclicBarrier
を使用して同期をとるよう修正しています。
Don't invoke touch_updates
if touch
does not supplied
activerecord/lib/active_record/counter_cache.rb
の修正です。
ActiveRecord::CounterCache.reset_counters
メソッドで、touch
オプションが指定された場合のみ更新処理用のメソッド(touch_updates
)を呼び出すよう修正しています。
Prefer each
over map
because unused return value
activerecord/lib/active_record/counter_cache.rb
の修正です。
値を返していないループでmap
を使用していたのを、each
を使用するよう修正しています。
Merge pull request #27520 from prathamesh-sonpatki/merge-uncountable-tests-for-inflector
activesupport/test/inflector_test.rb
の修正です。
バラバラの箇所に定義されていたuncountable
メソッドに関するテストを一箇所にまとめています。
touch_time
should be type casted to respect the precision of the column
activerecord/lib/active_record/counter_cache.rb
の修正です。
ActiveRecord::CounterCache.update_counters
メソッドで、更新用のSQLを組み立てるのにsanitize_sql_for_assignment
メソッドを使用しています。対象のカラムのprecision
の値を正しく考慮出来るようにする為のようです。
Dump schema cache for custom connection
activerecord/lib/active_record/railties/databases.rake
、
activerecord/lib/active_record/tasks/database_tasks.rb
の修正です。
db:schema:cache:dump
task内の実際のcache dump処理をメソッド(ActiveRecord::Tasks::DatabaseTasks.dump_schema_cache
)に切り出しています。
元の実装だと一つのconnectionしか扱えなかったのですが、メソッドに切り出し、かつ、メソッドの引数にconnectionを指定出来るようにして、任意のconnectionのcacheをdump出来るようにしています。
Fix grammar in active_record/counter_cache.rb [ci skip]
activerecord/lib/active_record/counter_cache.rb
のdocの修正です。
ActiveRecord::CounterCache.reset_counters
メソッドのdocのグラマーの修正を行っています。
Merge pull request #27508 from zzz6519003/patch-1
activejob/test/jobs/application_job.rb
の修正です。
使用していないsupport/job_buffer
のrequireを削除しています。
[ci skip] Use touch; slim wording.
activerecord/lib/active_record/counter_cache.rb
のdocの修正です。
ActiveRecord::CounterCache.reset_counters
メソッドのdocの言い回しの修正を行っています。