なるようになるブログ

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

rails commit log流し読み(2016/10/15)

2016/10/15分のコミットです。

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

actionpack/CHANGELOG.md


Merge pull request #26788 from Jesus/master

activesupport/lib/active_support/core_ext/hash/transform_values.rbの修正です。

Ruby本体が提供しているHash#transform_valuesが使える場合(Ruby 2.4以上)、そちらを使用する(RailsHash#transform_values)を使用しないよう修正しています。

RubyHash#transform_valuesはCで実装されており、そちらの方が高速な為。


Merge pull request #26785 from yahonda/diag26774

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rbの修正です。

ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter#indexesメソッドで、SUB_PARTカラムの値を取得した際に、to_iメソッドを呼んで明示的にintegerに変換するよう修正しています。

-            indexes.last.lengths.merge!(row[:Column_name] => row[:Sub_part]) if row[:Sub_part]
+            indexes.last.lengths.merge!(row[:Column_name] => row[:Sub_part].to_i) if row[:Sub_part]

元々bigint(3)だったinformation_schema.statisticsテーブルのSUB_PARTカラムが、MySQL 8.0.0-dmrでvarbinary(12)に型が変わってしまった為。


Add comment to remove code when we are in Ruby 2.4

activesupport/lib/active_support/core_ext/hash/transform_values.rbの修正です。

Ruby 2.4以上をサポートした場合、ファイル自体が不要になる旨コメントを追加しています。


Merge pull request #26784 from kamipo/quote_table_name_properly

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

table nameをquoteする際に、シングルクォートで囲むだけだったのを、quoteメソッドを使用してquote処理を行うよう修正しています。


Introduce a benchmark template [ci skip]

bug report templateにbenchmark取得用のtemplateを追加しています。

元々はContributing to Ruby on Rails guideのBenchmark Your Codeの項にbenchmark-ipsを使用したサンプルコードが記載されていたのですが、サンプルでは無く実際に動くコードがあった方が良いだろう、という事でtemplateが追加されたようです。


Pull request for ticket 26769 (#26770)

Configuring Rails Applications guideの修正です。

config.log_formatterについて説明している箇所に、production envでのデフォルトはLogger::Formatterである旨説明が記載されていたのですが、実際はActiveSupport::Logger::SimpleFormatterだった為、その旨説明を修正しています。


Merge pull request #26598 from rutaka-n/raise_record_not_found_with_correct_params

activerecord/lib/active_record/relation/finder_methods.rbの修正です。

ActiveRecord::FinderMethods#raise_record_not_found_exception!RecordNotFoundをraiseする際に、nameパラメータの値も含むよう修正しています。

-        raise RecordNotFound, error
+        raise RecordNotFound.new(error, name)

association経由でfinderメソッドを使用した場合にmodel名を含まれるようにする為。


Merge pull request #26793 from zachaysan/master

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

ActionDispatch::Integration::Session#processメソッドをpublicメソッドに移動、及びActionDispatch::Integration::RequestHelpers#getメソッドのdocに記載されていたhtttp request methodについての説明を#processメソッドのdocに移動しています。

ActionDispatch::Integrationクラスで定義されている以外のhttp method(OPTIONS等)のテストをしたい場合に、#processメソッドを使用する必要がある為 public methodにしたとの事です。


Copy-edit the documentation

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

ActionDispatch::Integration::Session#processメソッドのdocの言い回し、グラマーの修正を行っています。


Merge pull request #26786 from codeodor/patch-1

actionpack/lib/action_controller/renderer.rbの修正です。

ApplicationController.rendererのenvironmentに、Rails内部で保持しているkey(ActionController::Renderer::RACK_KEY_TRANSLATION)以外のkeyを指定した場合に、render時にそのenvironmentの値がnilになっていたのを、keyをStringに変換した値を返すよう修正しています。

-      def rack_key_for(key); RACK_KEY_TRANSLATION[key]; end
+      def rack_key_for(key)
+        RACK_KEY_TRANSLATION.fetch(key, key.to_s)
+      end