2015/02/11分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
find_in_batches
now accepts an:end_at
parameter that complements the:start
parameter to specify where to stop batch processing.- fix
remove_reference
withforeign_key: true
on MySQL. #18664.
Maintain a consistent order in ActiveRecord::Base#attributes
activerecord/lib/active_record/attribute_set/builder.rb
の修正です。
ActiveRecord::Base#attributes
が、keyの名前順にソートした値を返すよう修正しています。
Rails 4.1.8まではソートされていた値が返っていたのが、Rails 4.2.0からはソートされてない状態(普通のHash
)になっていたのを、4.1.8の挙動に合わせたとの事。
なお、"ソートされている事"は仕様としてある訳ではないのですが、ユーザからの要望により、修正する方向に倒れたようです。
Merge pull request #18860 from alex-handley/enhancement/dependent_documentation_fix
activerecord/lib/active_record/associations.rb
のdocの修正です。
has_many
のデフォルトの挙動が:nullify
オプションを指定した場合と同じ、と記載されていたのですが、実際は異なる(何もしない)なので、説明を修正しています。
Refactor microsecond precision to be database agnostic
ActiveRecordの修正です。
microsecond precision に関する処理のリファクタリングを行っています。
railties/test/generators/plugin_generator_test.rb
の修正です。
pluginのテストで、bundle install
を実行して、その際に表示されるメッセージを確認するテストがあるのですが、その際に確認するメッセージに誤りがあったのを修正しています。
Fixed typos in ActiveRecord CHANGELOG [ci skip]
activerecord/CHANGELOG.md
の修正です。
specifiying
-> specifying
、Sqlite3
-> SQLite3
にそれぞれタイポを修正しています。
Merge pull request #12257 from vipulnsward/end_on_find_in_batches
activerecord/lib/active_record/relation/batches.rb
の修正です。
find_in_batches
、find_each
メソッドに、バッチ処理の最後の値を指定する為のend_at
オプションを追加しています。
User.find_each(start: 2000, end_at: 10000, batch_size: 5000) do |user| NewsMailer.weekly(user).deliver_now end
上記の場合、生成されるSQLはSELECT "users".* FROM "users" WHERE ("users"."id" >= 2000) AND ("users"."id" <= 10000) ORDER BY "users"."id" ASC LIMIT 5000
となり、
最大5000件、ただ、対象となるIDの上限は、10000、という事になります
railties/test/generators/plugin_generator_test.rb
の修正です。
先程行ったpluginのテストの対応が間違っていたらしく、再度修正しています。
Dont check bundler output on plugin generator test
railties/test/generators/plugin_generator_test.rb
の修正です。
先のコミットの続きです。テストの際、bundle install
成功時のメッセージを確認するのではなく、エラーメッセージが"出力されて無い事"を確認するよう、テストを修正しています。
Convert stale? and fresh_when to use keyword arguments.
actionpack/lib/action_controller/metal/conditional_get.rb
の修正です。
fresh_when
、stale?
メソッドの引数にキーワード引数を使用するよう修正しています。
Adding subsection on 'upgrading' guide about 4.2 foreign key support [ci skip]
A Guide for Upgrading Ruby on Rails
の修正です。
Foreign Key Support
の項を追加して、foreigner
gemからの移行方法についての説明を記載しています。
The datetime precision with zero should be dumped
activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb
、
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
の修正です。
先に行われたprecision
に関するリファクタリングで、precision
の値が0の場合、precision
の設定が出力されなくなったのですが、
PostgreSQLではdatetime
カラムのprecision
に0は有効な値の為、PostgreSQLの場合は0でも出力するよう修正しています。
Fix wrong kwarg "record" from #18872
actionpack/lib/action_controller/metal/conditional_get.rb
の修正です。
stale?
メソッドの引数をキーワード引数にする対応で、etag
引数のデフォルト値が誤っていたのを修正しています。
Use keyword argument in transaction
activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
の修正です。
transaction
メソッドの引数にキーワード引数を使用するよう修正しています。
Remove cast_type
in ColumnDefinition
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
の修正です。
ColumnDefinition
クラスの親クラスのStruct
クラスから、使用していない:cast_type
を削除しています。
Fix typo in Rails::Application#migration_railties
railties/lib/rails/application.rb
のdocの修正です。
Rails::Application#migration_railties
メソッドのdocのタイポ("then" -> "them)を修正しています。
Fix some typos in railties/lib/rails/engine.rb [ci-skip]
railties/lib/rails/engine.rb
のdocの修正です。
rails engineについて説明している箇所にあったタイポを修正しています。タイポ、というかグラマーの修正のような。
guides, various testing guide changes. [ci skip]
rails guideのA Guide to Testing Rails Applications
の修正です。
80文字を超えている行に改行を追加、順序なしリストを順序付きリストへ変更等を行っています。
fix remove_reference
with foreign_key: true
on MySQL. #18664.
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
の修正です。
remove_reference
メソッドの引数にforeign_key: true
を指定した場合に、referenceを削除する前に外部キーを削除するよう修正しています。
remove_reference(:products, :user, index: true, foreign_key: true)
add test to ensure remove_reference
with index and fk is invertable.
activerecord/test/cases/migration/command_recorder_test.rb
の修正です。
inverse_of
メソッドにremove_reference
を指定した場合のテストを追加しています。
prefer drop_table :table, if_exists: true
over explicit checks.
activerecord/test/cases/migration/references_foreign_key_test.rb
の修正です。
tableの存在チェックを行う際、table_exists?
メソッドで確認してdrop_table
メソッドを呼び出していたのを、drop_table
メソッドのif_exists
オプションで確認するよう修正しています。
Remove code duplication in ActionView::Helpers::Tags::Base
actionview/lib/action_view/helpers/tags/base.rb
、
actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
の修正です。
ActionView::Helpers::Tags::Base
の各メソッドで重複してた処理をメソッドに切り出しています。