2014/05/27分のコミットです。
CHANGELOGにのったコミットは以下の通りです(詳細は本文参照)。
- Fix has_and_belongs_to_many public reflection.
- Add a public API to allow users to specify column types
- Fix redefine a has_and_belongs_to_many inside inherited class
Add missing test case for quoting behavior
DBAdapterのテストケースの追加です。
クォートされた値を引数に指定した場合のテストを追加しています。
テストを見て気付いたのですが、find
メソッドで文字列でも動作するんですね。
Todo.find("1-a") # SELECT "todos".* FROM "todos" WHERE "todos"."id" = ? LIMIT 1 [["id", 1]]
うーん。エラーになって欲しい気もする。
print generators on failed generate
railties/lib/rails/generators.rb
の修正です。
generate失敗時に出力するエラーメッセージが改善されています。前回revertされたのが、再度コミットされたようです。
# before rails g migrate add_click_to_issue_assignment # Could not find generator migrate. # after rails g migrate add_click_to_issue_assignment # Could not find generator 'migrate'. Please choose a generator below. # Rails: # assets # controller # generator # helper # integration_test # jbuilder # mailer # migration # model # resource # scaffold # scaffold_controller # task # # Coffee: # coffee:assets # # Jquery: # jquery:install # # Js: # js:assets # # TestUnit: # test_unit:generator # test_unit:plugin
便利。
Remove checks against column.type
in abstract adapter quoting
ConnectionAdaptersの修正です。
クォート処理を改善しているのは判るのですが、理由は良く分かりませんでした…。
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
の修正です。
不要なto_sym
メソッドを削除しています。
Refactor the type casting of booleans in MySQL
MySQLのConnectionAdapterの修正です。
unquoted_true
が1を、unquoted_false
が0を返すようメソッドを追加しています。MySQLのBoolean型って、TINYINT(1)と等価だった筈なので、その為でしょうか。
Correct Documentation for asset_tag_helpers
actionview/lib/action_view/helpers/asset_tag_helper.rb
のdocの修正です。
生成されるHTMLのパスが誤っていたのを修正しています。
update the recommended ruby version
railties/lib/rails/ruby_version_check.rb
の修正です。
Rubyの推奨バージョンが2.0
から2.1 or newer
に修正されています。
correct doc for (audio|video)_tag [ci skip]
actionview/lib/action_view/helpers/asset_tag_helper.rb
のdocの修正です。
audio_tag
、video_tag
で生成されるHTMLのサンプルが誤っていたのを修正しています。
Escape user input before showing in the page.
actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erb
の修正です。
ユーザがインプットした値のエスケープ処理が抜けてたのを追加しています。
ルーティングエラー時に表示される画面なので、本番環境で表示される事は無いはずなので、セキュリティ上は問題無い、という見解です。
Skip individual tests upon Dalli::RingError
actionpack/test/dispatch/session/mem_cache_store_test.rb
の修正です。
各テストケース毎にrescue Dalli::RingError
を追加して、エラーが起きた際に詳細情報表示するよう修正しています。
correct docs for (asset|image)_path [ci skip]
actionview/lib/action_view/helpers/asset_url_helper.rb
のdocの修正です。
asset_path
、image_path
メソッドで生成されるHTMLのサンプルが誤っていたのを修正しています。
Refactor the handling of arrays in where predicates
activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
の修正です。
配列の扱いについてリファクタリング。
Refactoring .reflections public method.
activerecord/lib/active_record/reflection.rb
の修正です。
reflections
メソッドをリファクタリングしています。
has_and_belongs_to_many
を使用していた場合に、内部的にはhas_many
として扱っていたので、reflections
メソッドで確認した場合にhas_many
と表示されてしまっていたとの事です。
今回のリファクタリングでhas_and_belongs_to_many
と表示されるよう修正しています。
[ci skip] Add benchmark your code section to contributing to ruby on rails guide.
rails guideのContributing to Ruby on Rails
の修正です。
ベンチマークのとり方についての説明を追加しています。
benchmark/ipsを使用した場合のサンプルですね。便利。
Extract types which don't require additional typecasting to a method
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
の修正です。
type cast処理が不要な型については、cast処理を行わないよう修正しています。
Allow empty arrays in where predicates
activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
の修正です。
where
メソッドで空配列を許容するよう修正しています。
Add a public API to allow users to specify column types
column typeにユーザが任意のクラスを指定出来るよう修正しています。
docから抜粋。
# db/schema.rb create_table :store_listings, force: true do |t| t.decimal :price_in_cents end # app/models/store_listing.rb class StoreListing < ActiveRecord::Base end store_listing = StoreListing.new(price_in_cents: '10.1') # before store_listing.price_in_cents # => BigDecimal.new(10.1) class StoreListing < ActiveRecord::Base property :price_in_cents, Type::Integer.new end # after store_listing.price_in_cents # => 10
独自クラスを指定する事も当然可能。
class MoneyType < ActiveRecord::Type::Integer def type_cast(value) if value.include?('$') price_in_dollars = value.gsub(/\$/, '').to_f price_in_dollars * 100 else value.to_i end end end class StoreListing < ActiveRecord::Base property :price_in_cents, MoneyType.new end
継承するAPIについてはActiveRecord::Properties::Type::Value
を参照。
なお、マージされた後にDHHが登場して、まだPRで議論が続いています。修正が入りそうな感じかなあ。
Replace double quotes with single quotes while adding an entry into Gemfile
railties/lib/rails/generators/actions.rb
の修正です。
Gemfileに記載される文字列について、ダブルクォートからシングルクォートに変換しています。
Add description of ActionMailer::TestHelper module [ci skip]
ActionMailer::TestHelper
の修正です。docを追加しています。
Use "Action Mailer" as canonical name in documentation [ci skip]
ActionMailer::TestHelper
の修正です。
直ぐ上のコミットで追加されたdocをActionMailer
-> Action Mailer
に修正しています。
Remove unnecessary branch from quoting in Mysql
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
の修正です。
不要なクォート処理を削除しています。
Pass through AM documentation re: 02d048d [ci skip]
actionmailer/lib/action_mailer/base.rb
のdocの修正です。
こちらでもActionMailer
-> Action Mailer
に修正しています。
Typo in AR CHANGELOG [ci skip]
activerecord/CHANGELOG.md
の修正です。
typoの修正。
Merge pull request #15301 from zzak/issue_15212
activerecord/lib/active_record/associations/preloader.rb
の修正です。
associationがロード済みの場合に、処理をスキップするよう修正しています。
activerecord/test/cases/associations/eager_test.rb
へのテストの追加です。
このコミットに対するテストですね。
ActiveRecordのテストの修正です。
preloadeのテストをactiverecord/test/cases/associations/eager_test.rb
に移動しています。
activerecord/test/cases/associations/eager_test.rb
の修正です。
do
が抜けてたのを追加しています。
Remove require 'active_support'
from individual modules
ActiveSupportのmoduleから、require "active_support"
を削除しています。
ActiveSupportのmoduleを使用したい場合、ユーザが最初にrequire "active_support"
するようにとの事です。rails guide参照。
Fix redefine a has_and_belongs_to_many inside inherited class
activerecord/lib/active_record/autosave_association.rb
の修正です。
同じhas_an_belongs_to_many
を複数回定義した場合に、エラーになるバグを修正しています。
継承関係がある場合に、継承先のクラスで同じhas_and_belongs_to_many
を定義した際に保存出来ない、というのがまずいのか。
Deprecate decimal columns being automatically treated as integers
activerecord/lib/active_record/properties.rb
の修正です。
現状、decimalについてはintegerとして取り扱うように内部的にはなっているのですが、将来これを辞めるらしく、deprecateのメッセージを出力するよう修正しています。