2016/04/23分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Add
ActiveSupport.to_time_preserves_timezone
config option to control howto_time
handles timezones. In Ruby 2.4+ the behavior will change from converting to the local system timezone to preserving the timezone of the receiver. - Add
DateTime#localtime
to return an instance ofTime
in the system's local timezone. Also aliased togetlocal
activesupport/lib/active_support/evented_file_update_checker.rb
の修正です。
pathの階層チェック処理をするのに、refine
を使用してPathname
にメソッドを定義していたのを止めて、普通にActiveSupport::EventedFileUpdateChecker
クラス内に同じ内容のメソッドを定義するよう修正しています。
そちらの方が早い為、との事です。refinement遅いんですかねえ。
Do not attempt to return connection with open transaction to pool (#24610)
activerecord/lib/active_record/query_cache.rb
の修正です。
install_executor_hooks
メソッドで、transaction中じゃない場合のみ、connectionのclear処理を行うよう修正しています。
- ActiveRecord::Base.clear_active_connections! + unless ActiveRecord::Base.connection.transaction_open? + ActiveRecord::Base.clear_active_connections! + end
transaction中にconnectionのclear処理を行おうとすると、デットロックになってしまう問題があった為。
Active Recordの修正です。
INSERT INTO schema_migrations in 1 SQLで、schema_migrations のinsert処理で、insert 1行毎にSQLを発行していたのを、multi-row-insertを使用するよう修正したのですが、古いSQLite(3.7.10以下)ではmulti insertは使用出来ないので、SQLiteのバージョンをチェックし、3.7.10以下の場合は元の通りinsert 1行毎にSQLを発行するよう修正しています。
railties/test/application/configuration_test.rb
の修正です。
テスト名でoverridden
をoverriden
にタイポしている箇所があったのを修正しています。
Schema load: Fix dupe version insert
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
の修正です。
assume_migrated_upto_version
メソッドで、version sqlをinsertする際に使用する変数を誤っていたのを修正しています。
Actionpack documentation typos [ci skip]
Action Packのdocの修正です。
各doc内のグラマーの修正をまとめて行っています。
Add compatibility for Ruby 2.4 to_time
changes
Active Support / railtiesの修正です。
元々DateTime#to_time
、Time#to_time
メソッドは、timezoneの情報を削除した値を返すようになっていたのですが、Ruby 2.4からtimezoneの情報を保持するようになりました。
これによりRailsの既存の処理が壊れてしまった(timezone情報を保持しない前提の処理になっていた為)箇所がある為、#to_time
メソッドを上書きして、timezoneの情報を保持した値を返すかどうかをRails側でハンドリングするよう修正しています。
デフォルトではtimezone
の情報を保持しないようになっていますが、ActiveSupport.to_time_preserves_timezone
にtrueを設定する事で、timezone
の情報を保持した値を返すようになります(Rails 5でrails new
した場合は、デフォルトtrueになるよう設定されています)。
ENV['TZ'] = 'US/Eastern' "2016-04-23T10:23:12.000Z".to_time # => "2016-04-23T06:23:12.000-04:00" ActiveSupport.to_time_preserves_timezone = true "2016-04-23T10:23:12.000Z".to_time # => "2016-04-23T10:23:12.000Z"
また、合わせてシステムのローカルタイムゾーンが設定されたTime
クラスのインスタンスを返す、DateTime#localtime
メソッド、及びそのaliasであるDateTime#getlocal
メソッドが追加されています。
DateTime.new(2016, 3, 11, 15, 11, 12, 0).getlocal # => 2016-03-12 00:11:12 +0900
参考:
- Bug #12189: DateTime#to_time removes timezone information - Ruby trunk - Ruby Issue Tracking System
- Bug #12271:
Time#to_time
removes timezone information - Ruby trunk - Ruby Issue Tracking System
Move DateTime#getlocal
to /core_ext/date_time/calculations.rb
activesupport/lib/active_support/core_ext/date_time/calculations.rb
、
activesupport/lib/active_support/core_ext/date_time/compatibility.rb
の修正です。
先の対応で追加されたDateTime#getlocal
メソッドをactive_support/core_ext/date_time/compatibility.rb
からactive_support/core_ext/date_time/calculations.rb
に移動しています。
DateTime#getlocal
メソッドはpublic APIな為、DateTime#utc
メソッド同様calculations.rb
にあるのが適切だろう、という事で移動したようです。