なるようになるブログ

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

rails commit log流し読み(2015/02/03)

2015/02/03分のコミットです。

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

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


Remove unused Column#with_type

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

使用していないColumn#with_typeメソッドを削除しています。


Rename user_provided_types to something more meaningful

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

user_provided_typesattributes_to_define_after_schema_loadsに名前を変更しています。


Fix a typo in autoloading doc and note on autoload_paths [ci skip]

rails guideのAutoloading and Reloading Constantsの修正です。

config.autoload_pathsの設定についてのexampleにtypoがあったのを修正しています。

-config.autoload_paths += "#{Rails.root}/lib"
+config.autoload_paths << "#{Rails.root}/lib"

Properly lookup the limit for bigint

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

bigint型を使用していた場合に、integerの最大値以上の値を設定した場合に、値が正しく設定されないバグがあったのを修正しています。

-        $1.to_i if sql_type =~ /\((.*)\)/
+        case sql_type
+        when /^bigint/i
+          8
+        when /\((.*)\)/
+          $1.to_i
+        end

Generate consistent names for foreign keys

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

foreign keyの名前を作成する際、ランダムな値をsuffixに設定していたのを、テーブル名 + カラム名の文字列から生成したハッシュ値に設定するよう修正しています。

+        identifier = "#{table_name}_#{options.fetch(:column)}_fk"
+        hashed_identifier = Digest::SHA256.hexdigest(identifier).first(10)
         options.fetch(:name) do
-          "fk_rails_#{SecureRandom.hex(5)}"
+          "fk_rails_#{hashed_identifier}"

ランダムだと、マイグレーションを実行する度に名前が変わってしまい、例えばチームで開発している時等に、毎回変わってしまうのは良くないのでは、という事で固定の値になるよう修正したようです。


Person class doesn't contain finder methods, hence usage of Person.find_by is wrong.

activemodel/lib/active_model/dirty.rbのdocの修正です。

ActiveModelを使用するexampleで、finderメソッドを定義してない使用していたのを、finderメソッドを使用しないよう修正しています。


Small enhancement for generators

railties/lib/rails/generators.rbの修正です。

map.flatしていた箇所を、flat_mapを使用するよう修正しています。


Wrap method arguments with parentheses in docs

activemodel/lib/active_model/dirty.rbのdocの修正です。

ActiveModelのexampleに、メソッド呼び出し時に()を使用してない箇所があったので、()を追加しています。


Change AS::Testing::TimeHelpers#travel_to to also stub DateTime.now

ActiveSupport::Testing::TimeHelpers#travel_toメソッドが、Time.nowDate.todayメソッドと同じように、DateTime.nowもstubするよう修正しています。