なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2016/04/24)

2016/04/24分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activesupport/CHANGELOG.md

activerecord/CHANGELOG.md


Add Time#sec_fraction

activesupport/lib/active_support/core_ext/time/calculations.rbの修正です。

秒の分数をRationalで返すTime#sec_fractionメソッドを追加しています。

Time.new(2012, 8, 29, 0, 0, 0.5).sec_fraction
# => (1/2)

Add CHANGELOG entry for #24700

activesupport/CHANGELOG.mdの修正です。

DateTime#localtimeDateTime#getlocalメソッドを追加した対応について、CHANGELOGにentryを追加してます。


Add additional aliases for DateTime#utc

activesupport/lib/active_support/core_ext/date_time/calculations.rbの修正です。

DateTime#utcのaliasとして、#getgm#gmtimeメソッドを追加しています。


Change Time#sec_fraction to use subsec

activesupport/lib/active_support/core_ext/time/calculations.rbの修正です。

Time#sec_fractionメソッドで、subsecメソッドを使用するよう修正しています。

  def sec_fraction
-    Rational(nsec, 1000000000)
+    subsec
   end

Add DateTime#subsec

activesupport/lib/active_support/core_ext/date_time/calculations.rbの修正です。

秒の分数をRationalで返すDateTime#subsecメソッドを追加しています。

DateTime.new(2012, 8, 29, 0, 0, 0.5).subsec
# => (1/2)

内部的には、#sec_fractionメソッドを呼び出しているだけです。

def subsec
  sec_fraction
end

Make getlocal and getutc always return instances of Time

Active Supportの修正です。

ActiveSupport::TimeWithZoneDateTimegetlocalgetutcメソッドが、必ずTime`クラスのインスタンスを返すよう修正しています。

ActiveSupport::TimeWithZoneDateTimeインスタンスをラップしている時に、to_timeメソッドの呼び出しがstack level too deep errorになってしまうバグがあり、その修正の為に対応を行ったようです。


Follow up of https://github.com/rails/rails/commit/c9c5788a527b70d7f983e2b4b47e3afd863d9f48

activesupport/CHANGELOG.mdactivesupport/lib/active_support/core_ext/date_and_time/compatibility.rbのdocの修正です。

CHANGELOGActiveSupport.to_time_preserves_timezoneについてのentry、及びpreserve_timezone accessorについてのdocについて、グラマーの修正を行っています。


Share lock: avoid livelock due to exclusive thread sleeping before waiting threads wake

activesupport/lib/active_support/concurrency/share_lock.rbの修正です。

排他スレッドの処理終了を待つ前に、#broadcastを使用してスレッドを再開するよう修正しています。

              yield_shares(compatible: compatible, block_share: true) do
+                @cv.broadcast
                 @cv.wait_while { @exclusive_thread || eligible_waiters?(compatible) }

Followup of #15771

activerecord/lib/active_record/locking/optimistic.rbの修正です。

Active Recordの楽観的排他制御用処理で、lock_versionカラムにnilを指定した場合に、エラーになってしまっていたのを修正しています。


Fix typo in ActiveJob #retry_job doc

activejob/lib/active_job/enqueuing.rbのdocの修正です。

retry_jobメソッドのdoc内のexampleコードで、ScraperScrapperにタイポしている箇所があったのを修正しています。


Deprecate request_via_redirect method.

actionpack/lib/action_dispatch/testing/integration.rbの修正です。

request_via_redirectメソッドを使用した際に、deprecateメッセージを表示するよう修正しています。

他のxxx_via_redirectメソッド(get_via_redirectpost_via_redirect等)はDeprecate *_via_redirect integration test methods by aditya-kapoor · Pull Request #18693 · rails/railsで、使用した際にdeprecateメッセージを表示するようになっていたのですが、request_via_redirectについては対応が漏れてしまっていたので、追加で対応を行っています。


Add :nodoc: to insert_versions_sql [ci skip]

activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rbactiverecord/lib/active_record/connection_adapters/abstract_adapter.rbの修正です。

private APIであるinsert_versions_sql:nodoc:を設定しています。


Remove in the doc about MySQL versions below 5 [ci skip]

activerecord/lib/active_record/connection_adapters/abstract/database_statements.rbのdocの修正です。

transactionメソッドのdocにMySQL 5未満の場合の注意事項が記載されていたのですが、Rails 5ではMySQL 5.0以上のみをサポートするようになり、MySQL 5.0未満はサポート対象外になった為、該当の注意事項を削除しています。


Move require 'ipaddr' in postgresql/oid/cidr.rb

activerecord/lib/active_record/connection_adapters/postgresql/oid/cidr.rbactiverecord/lib/active_record/connection_adapters/postgresql_adapter.rbの修正です。

ipaddrrequireactiverecord/lib/active_record/connection_adapters/postgresql/oid/cidr.rbで行うよう修正しています。

ipaddrを実際に使用しているのはActiveRecord::ConnectionAdapters::PostgreSQL::OID::Cidrクラスの為。


Move select_rows implementation to super class

activerecord/lib/active_record/connection_adapters/abstract/database_statements.rbactiverecord/lib/active_record/connection_adapters/sqlite3_adapter.rbの修正です。

SQLite3Adapterクラスで定義していたselect_rowsメソッドの実装を親クラスに移動しています。


add channels files in stats task

railties/lib/rails/tasks/statistics.rakeの修正です。

stats taskで、channelsディレクトリのファイルも表示されるよう修正しています。


Merge pull request #23461 from kamipo/prepared_statements_for_mysql2_adapter

Active Recordの修正です。

Mysql2AdapterでPrepared statementを使用出来るように対応しています。

デフォルトでは無効になっており、config/database.ymlprepared_statements: trueを設定する事で使用出来るようになりますた。また、mysql2 gem 0.4.4以上が必要となっています。


Fix broken build, channel files are also included in bin/rails stats now

railties/test/application/rake_test.rbの修正です。

先のstats taskでchannelsディレクトリのファイルも表示されるよう修正した対応で、テストの修正が漏れていたので、対応しています。


Add #23461 to release notes

rails guideのRuby on Rails 5.0 Release Notesの修正です。

Mysql2AdapterでPrepared statementを使用出来るようにした対応について、Notable changesの項にentryを追加しています。