なるようになるブログ

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

rails commit log流し読み(2014/07/14)

2014/07/14分のコミットです。

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

activerecord/CHANGELOG.md

actionpack/CHANGELOG.md


Fix typos like a html to an html and 'an mail' to 'an email'. [ci skip]

各docの修正です。a htmlan htmlに、an mailan emailに修正しています。


Format pass on 4.2 release notes [ci skip]

guides/source/4_2_release_notes.mdの修正です。

改行の追加、インデントの調整等、見やすさの調整を行っています。


[ci skip] Little bit doc code improvement.

activemodel/lib/active_model/errors.rbのdocの修正です。サンプルを修正しています。

-  #       errors.add(:name, "cannot be nil") if name == nil
+  #       errors.add(:name, "cannot be nil") if name.nil?

name.nil?の方が明確ですね。


Merge pull request #16127 from Envek/fix_16111

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

PostgreSQLで、primary keyのデフォルトに、custom functionを使用していた場合に出力内容がおかしかったのを修正しています。

ちょっと解りづらかったので、テストコードから抜粋。

onnection.execute <<-SQL
CREATE OR REPLACE FUNCTION my_uuid_generator() RETURNS uuid
AS $$ SELECT * FROM uuid_generate_v4() $$
LANGUAGE SQL VOLATILE;
SQL

# Create such a table with custom function as default value generator
connection.create_table('pg_uuids_2', id: :uuid, default: 'my_uuid_generator()') do |t|
  t.string 'name'
  t.uuid 'other_uuid_2', default: 'my_uuid_generator()'
end

上記のような形でmy_uuid_generatorというFUNCTIONを定義していた場合に、

ActiveRecord::SchemaDumper.dump(connection, schema)
assert_match(/\bcreate_table "pg_uuids_2", id: :uuid, default: "my_uuid_generator\(\)"/, schema.string)
assert_match(/t\.uuid   "other_uuid_2", default: "my_uuid_generator\(\)"/, schema.string)

正しくcreate_tableSQLが生成されるよう修正されています。


Stash original path in ShowExceptions middleware

actionpack/lib/action_dispatch/middleware/show_exceptions.rbの修正です。

ActionDispatch::ShowExceptions#render_exceptionメソッドenv["PATH_INFO"]env["action_dispatch.original_path"]に格納するよう対応しています。

今までは、ExceptionWrapperクラスでPATH_INFO情報を上書きしてしまっていたので、PATH_INFOを取得するすべが無かったんですね。


Address ORA-00972: identifier is too long when tested with Oracle

ActiveRecordのテストの修正です。

Oracleの識別子(列名)は30byteまでしか指定出来ないらしく、30byte以上の列名があったのを修正しています。

30byteって、意外と短いんですね。