2014/06/03分のコミットです。
CHANGELOGにのったコミットは以下の通りです(詳細は本文参照)。
- pg, preserve point type when schema dumping.
- pg, preserve type when schema dumping bit and bit varying columns.
Merge pull request #15379 from xuanxu/rational_precision
ActiveSupport::NumberHelper::NumberConverter::NumberToRoundedConverter#convert
メソッドの修正です。
ActiveSupport::NumberHelper.number_to_rounded
メソッドの引数にRational
クラスを指定した場合に、結果がおかしくなっていたのを修正しています。
# before ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2 #=> "330.00" # after ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2 #=> "333.33"
activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
の修正です。
assert_equal
を使用していた箇所をassert
に修正しています。
- assert_equal true, child.save + assert child.save, 'child object should be saved'
true
かどうか確認するには、assert
の方が明確ですね。
File.exist? instead of File.exists? in bin/setup
railties/lib/rails/generators/rails/app/templates/bin/setup
の修正です。
File.exists?
メソッドの代わりにFile.exist?
メソッドを使用するよう修正しています。File.exists?
でdeprecateになってたんですね。知らなかった。
activerecord/lib/active_record/properties.rb
の修正です。
:internal
にコロンが足りてなかったのを追加しています。
Remove unused initialize_attributes
method
activerecord/lib/active_record/model_schema.rb
の修正です。
使用していないinitialize_attributes
メソッドを削除しています。
Fix typo in ActionController Overview
rails guideのAction Controller Overview
の修正です。
"sensible"ではなく、"sensitive"を使うべき、との事で修正しています。
意味が良く解らなくてググったらこんな記事が間違いやすい英語:Sensibleとsensitive。難しいなあ。
concat is a hotspot (via AV#append=), so just directly define the methods
activesupport/lib/active_support/core_ext/string/output_safety.rb
の修正です。
define_method
メソッドを使ってメソッドを定義していたのをdef
を使うように修正しています。
- %w[concat prepend].each do |method_name| - define_method method_name do |value| - super(html_escape_interpolated_argument(value)) - end + def concat(value) + super(html_escape_interpolated_argument(value)) + def prepend(value) + super(html_escape_interpolated_argument(value)) + end
ActionView#append=
がhotspotだから、とコミットログには記載されていますが、よく解らず。
alias :concat :<< alias :append= :<<
こっちはこっちでalias設定してるんだよなあ。
reduce AS::SafeBuffer allocations
ActiveSupport::String::SafeBuffer#html_escape_interpolated_argument
メソッドの修正です。
元々はActiveSupport::SafeBuffer
クラスを返していたのですが、ActiveSupport:SafeBuffer
クラスである必要性は無いとの事で、ERB::Util.h
を使用しないよう修正しています。
drastically reduce object allocations
ERB::Util.unwrapped_html_escape
メソッドを新設しています。
元々HTML escape処理では、escape処理したStringをActiveSupport::SafeBuffer
でラップしていました。
class String def html_safe ActiveSupport::SafeBuffer.new(self) end end
こんな感じですね。なので、HTML escape処理する度に、ActiveSupport::SafeBuffer
インスタンスが生成されていたのですが、新設されたunwrapped_html_escape
では、escape処理した後、ActiveSupport::SafeBuffer
でラップしないようにしています。
で、幾つかのメソッドでunwrapped_html_escape
処理を使うようにした結果aaronのテストアプリケーションでは、ActiveSupport::SafeBuffer
のオブジェクト数が1527 / req から500 / reqから減ったとの事です。すごい。
call capture
fewer times from form_for
ActionView:: Helpers::FormTagHelper#form_tag_in_block
メソッドをform_tag_with_body
メソッドにリネームして、引数をblock
からcontent
に修正しています。
元々form_tag_in_block
の中で、capture
メソッドでbodyの情報を取得していたのを、呼び出し側で対応するよう修正しています。capture
のcall回数が減らす為ですかね。
fix polymorphic? method and reuse it
ActiveRecord::Reflection::polymorphic?
メソッドの修正です。
options.key? :polymorphic
をoptions[:polymorphic]
に修正しています。各箇所のpolymorphicのチェック処理をpolymorphic?
メソッドを使用するように修正しています。
pg test, examples for default values and schema dumping of point types.
activerecord/test/cases/adapters/postgresql/geometric_test.rb
の修正です。
default value、schema dumpingに関するテストを追加しています。
pg, preserve point type when schema dumping.
PostgreSQLのConnectionAdapterの修正です。
typeにpoint
を追加しています。
@connection.create_table('postgresql_points') do |t| t.point :x t.point :y, default: [12.2, 13.3] t.point :z, default: "(14.4,15.5)" end
migratationファイルにも指定可能です。
test pg, we don't care about the internal state of column#default
.
PostgreSQLのConnectionAdapterのテストの修正です。
column#default
に関するテストを削除しています。
column#default
は内部の状態なので、テストする必要は無いとの判断らしいです。
test pg, move bit string type tests into bit_string_test.rb
.
PostgreSQLのConnectionAdapterのテストの修正です。
activerecord/test/cases/adapters/postgresql/bit_string_test.rb
を新規に作成してbit string typeのテストをそちらに移動しています。
Refactor determination of whether the field has changed
ConnectionAdaptersの修正です。
file変更時の取り扱いについてリファクタリングしています。
pg, preserve type when schema dumping bit and bit varying columns.
PostgreSQLのConnectionAdapterの修正です。
typeにbit
、bit_varying
を追加しています。
@connection.create_table('postgresql_bit_strings') do |t| t.bit :a_bit, default: "00000011", limit: 8 t.bit_varying :a_bit_varying, default: "0011" end
こんな感じで。
Respect limit for PG bit strings
PostgreSQLのConnectionAdapterの修正です。
上記コミットで追加されたbit
に関するのソースの微修正です。String -> Symbolに変更等を行っています。
Refactor quoting of binary data to not be based on the column type
ConnectionAdaptersの修正です。
binary dataのquote処理についてリファクタリングしています。
_quote
メソッドを新設し、そちらに処理をまとめています。