2015/01/02分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Fix
reaping_frequency
option when the value is a string. - Allow precision option for MySQL datetimes.
- Format the datetime string according to the precision of the datetime field.
- Change
ActiveRecord::Relation#update
behavior so that it can be called without passing ids of the records to be updated. - Fixed automatic inverse_of for models nested in module.
Stop passing the column to the connection adapter when quoting defaults
activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb
の修正です。
connection adapterのquoteメソッドにカラムの情報を渡すのを止めています。
カラムはtype cast処理でしか使用してないので、削除していく方針のようです。
Stop using the column for type information in sanitization
activerecord/lib/active_record/sanitization.rb
の修正です。
quote_bound_value
メソッドの引数から"column"を削除しています。
先と同じく、カラム情報削除対応。代わりに、quote_bound_value
を呼び出す前にtype_cast_for_database
を呼び出すよう対応しています。
Don't load an entire table into memory to copy it on SQLite
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
の修正です。
copy_table_contents
メソッドで、最初に"SELECT"クエリーを発行してデータを取得してから"INSERT"していたのを、ひとつのSQL("INSERT INFO SELECT ")で行うよう修正しています。
Don't rely on the column for type information in uniquness validations
activerecord/lib/active_record/validations/uniqueness.rb
の修正です。
connection adapterのtype_cast
メソッドにカラムの情報を渡すのを止めています。 代わりに、type_cast
にvalueを渡す前にtype_cast_for_database
を呼び出すよう対応しています。
💣 I forgot to commit the arity change
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
の修正です。
ConnectionAdapters#Quoting#type_cast
メソッドの第二引数のcolumnにデフォルト引数を設定しています。先のコミットでtype_cast
メソッドでカラムを渡さないようにしたのですが、呼び出さき側の方の対応が漏れていたので、対応しています。
Stop relying on columns in sqlite quoting tests
activerecord/test/cases/adapters/sqlite3/quoting_test.rb
の修正です。
sqliteのquotingのテストで、type_cast
メソッドにカラム情報を渡すのを止めています。
Stop relying on columns in mysql quoting tests
activerecord/test/cases/adapters/mysql/quoting_test.rb
の修正です。
MySQLのquotingのテストで、type_cast
メソッドにカラム情報を渡すのを止めています。
Stop relying on columns for type information in mysql2 casting tests
activerecord/test/cases/adapters/mysql2/boolean_test.rb
の修正です。
MySQL2ののテストで、type_cast
メソッドにカラム情報を渡すのを止めています。
Stop depending on columns for type information in PG quoting tests
activerecord/test/cases/adapters/postgresql/quoting_test.rb
の修正です。
PostgreSQLのquotingのテストで、type_cast
メソッドにカラム情報を渡すのを止めています。
Stop explicitly passing nil
as the column to type_cast
activerecord/test/cases/adapters/sqlite3/quoting_test.rb
の修正です。
先に行ったsqliteのquotingのテストの修正で、type_cast
メソッドの第二引数にnilを渡すよう修正していたのですが、そもそも第二引数を渡さないよう修正しています。type_cast
メソッドの第二引数はデフォルト引数が設定されているので、そもそも渡す必要が無いから、ですかねえ。
Check by @v before converting the entry on expired?
activesupport/lib/active_support/cache.rb
の修正です。
Entry#expired?
メソッドで`convert_version_4beta1_entry!を行うかどうかチェックする変数を"@value" -> "@v"に修正しています。
Rails3.xから4.0の間にcacheに使用するインスタンス変数が"@v"から"@value"に変更になっており、cacheに関する各メソッドで変数のマイグレーション処理が行われていたのですが、
本来"@v"の方の変数があるか見なくてはならない所が、"@value"の方を見てしまい、expired?
メソッドでRailsバージョンアップ時に正しくデータのコンバージョンが行われないバグが起きてしまっていたので、その対応です。 割と今更感ある気もしますが…。 4-2-stable ブランチにバックポート済み。
Remove conversion code for old Rails cache entry
activesupport/lib/active_support/cache.rb
の修正です。
先に説明したcacheのコンバージョンに関する処理をすべて削除しています。Rails 5系のコードには不要な為との事。
Fix test description to match the test behaviour
railties/test/generators/scaffold_generator_test.rb
の修正です。
scaffoldのテストで、テスト内容とテスト名が一致してなかったテストがあったので、テスト名を修正しています。
Fix scaffold generator with --helper=false option
railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
の修正です。
--helper=false
オプションを設定した場合に、helperファイルが生成されないようgeneratorを修正しています。
Add --skip-action-mailer (or -M) to rails generate
generatorの修正です。
generatorに--skip-action-mailer
オプションを追加しています。名前の通りで、設定すると、appのgenerate時にActionMailerに関するファイルをインクルードしないようにしてくれます。 オプションは"-M"でもOK。
Do not run integration tests for the test adapter
activejob/Rakefile
の修正です。
test用のadapterではintegration testを実施しないよう修正しています。
Do not check only for the Rails constant
activerecord/lib/active_record/migration.rb
、
activesupport/lib/active_support/core_ext/kernel/debugger.rb
activesupport/lib/active_support/deprecation/behaviors.rb
の修正です。
"Rails"定数が定義されているかどうかチェックしている処理を、Rails.env
、Rails.logger
が定義されているか確認するよう修正しています。
rails-html-sanitizer
等のgemでRails
定数が設定されている場合があり、その場合に期待通りの動作とならない為、チェックする定数を変更したとの事です。
Merge pull request #18080 from korbin/fix_reaping_frequency_configuration
activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
の修正です。
Reaper
クラスのコンストラクタでオプションのチェックをする際、reaping_frequency
のFloatへの変更処理を追加しています。
reaping_frequency
がStringだった場合に適切に値が設定されないバグがあった為対応しています。具体的には、DATABASE_URL
を使用している場合に問題になっていたとの事。
Including links to earlier releases guides (4.1.8 and 4.0.12) [ci skip]
guides/source/_welcome.html.erb
の修正です。
Rails 4.1.8、4.0.12の各バージョンのRails Guideのリンクを追加しています。
Add branch to gems pointing to github so that we can use local checkouts
Gemfile
の修正です。
jquery-rails
、arel
についてbranch: 'master'
の指定を追加しています。
Verify the helper name with plural as it is generated
railties/test/generators/scaffold_generator_test.rb
の修正です。
helperファイルが生成されない事を確認するテストで、確認対象のファイル名に誤りがあったのを修正しています。
- assert_no_file "app/helpers/post_helper.rb" + assert_no_file "app/helpers/posts_helper.rb"
railties/test/generators/scaffold_generator_test.rb
の修正です。
" ambiguous first argument; put parentheses or a space even after /' operator'
"のwarningが出てたのを対応しています。
Allow precision option for MySQL datetimes.
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
の修正です。
MySQLのdatetime型にprecision
オプションが設定出来るよう対応しています。
t.datetime :written_on, precision: 6
precision、MySQL 5.6.4から設定出来るようになったんですねえ。 MySQLのマニュアルご参照。
Format the datetime string according to the precision of the datetime field.
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
の修正です。
MySQL 5.6からミリ秒を扱えるようになったのですが、カラムで扱える以上の精度を値に指定した場合、自動で四捨五入されてしまいます。
例えば、"2014-08-17 12:30:00.999999"をdatetime型のにカラムに指定した場合、MySQL 5.5では"2014-08-17 12:30"が設定されたのですが、MySQL 5.6では四捨五入されて、"2014-08-17 12:31"が設定されてしまうとの事です。
これは、MySQLの仕様でそうなっているとの事です。Datetime rounding problem
とはいえ、自動で四捨五入されるのは、あまり望まない挙動だよね、という事でprecision
オプションを指定していた場合、四捨五入が行われないようACtiveRecord側で値のフォーマットを行うよう修正しています。
……認識あってるかなあ。
Merge pull request #18290 from lucascaton/guides_updates
各guideの修正です。
Railsのバージョンを表示している箇所を、一通り5.0.0に修正しています。
Merge pull request #11898 from prathamesh-sonpatki/patch-update
activerecord/lib/active_record/relation.rb
の修正です。
ActiveRecord::Relation#update
の振る舞いがかわり、引数にidの指定が無くても動作するようになっています。
# Before # ArgumentError: wrong number of arguments (1 for 2) Comment.where(group: 'expert').update(body: "Group of Rails Experts") # After # Comments with group expert updated with body "Group of Rails Experts" Comment.where(group: 'expert').update(body: "Group of Rails Experts")
これは割と便利そう。 update_all
だとcallbacksとvalidationsが実行されないので、そちらの処理が必要な場合はこの形が良さそう。
Integration requests should work in contexts without setup and teardown
actionpack/lib/action_controller/test_case.rb
の修正です。
reset_template_assertion
の修正です。
インスタンス変数のクリアーを行う際、インスタンス変数がnilではないかどうか、確認してから削除するよう修正しています。
Merge pull request #15746 from amccloud/auto-inverse_of-in-module
activerecord/lib/active_record/reflection.rb
の修正です。
automatic_inverse_of
メソッドでネストしているmodelについて正しく値を返してなかったのを修正しています。
Add a hidden_field on the file_field
actionview/lib/action_view/helpers/tags/file_field.rb
の修正です。
file_field
を使用した際、自動でhidden_field
も作成するよう対応しています。
file_field("user", "avatar") # => <input name="user[avatar]" type="hidden" value="" /><input id="user_avatar" name="user[avatar]" type="file" />
file_field
だけをフォームに使用した場合、Strong Parameterでのチェック時にActionController::ParameterMissing - param is missing or the value is empty: document
が起きてしまうので、回避策としてhidden
タグを追加しているとの事です。paramsにfileは含まれないからですねえ。なるほど。
因みに、hidden_field
を生成したくない場合は、include_hidden
オプションにfalse
を設定すればOKです。
file_field("user", "avatar", 'include_hidden' => false)