2014/06/10分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
Do not try to set the foreign_key again on has_many through `activerecord/lib/active_record/associations/has_many_through_association.rbの修正です。
4.1.2.rc1で、has_many throughを使用している場合に、ActiveModel::MassAssignmentSecurity
が起きるケースがあったのを修正しています。
class Group < ActiveRecord::Base ... has_many :members, :through => :memberships, :source => :user end group.members << user
最後の、group.members << user
でエラーになるそうです。foreign_key
を複数回設定してしまってのが原因らしい。
Use an actual identity type in AR::Result#identity_type
activerecord/lib/active_record/result.rb
の修正です。
IDENTITY_TYPE
をClass.new { def type_cast(v); v; end }.new
からType::Value.new
に修正しています。
Rename type_cast
to type_cast_from_database
ActiveRecordの修正です。
type_cast
をtype_cast_from_database
に名前を変更しています。
うーん。type_cast
メソッドはprivateメソッドにして、外から触れないように対応を行っているのだが、よく解らず。type_cast
継承させて拡張させるんじゃなかったかなあ。
Timestamp values should be present on callbacks
record_timestamps
をコールバックで変更出来るようにしたこのコミットをrevertしています。
上記コミットのせいで、before_create
でcreated_at
がnilになってしまった為、一旦revertした模様。
因みに、実行順は以下のように変わっていたらしい。
Rails 4.1.1:
- Callbacks#create_record
- Timestamp#create_record
- My#before_create
Rails 4.1.2:
- Callbacks#create_record
- My#before_create
- Timestamp#create_record
Fix bug that make HashWithIndifferentAccess work differently of Hash
activesupport/lib/active_support/hash_with_indifferent_access.rb
の修正です。
HashWithIndifferentAccess
がHash
と異なる動きをするケースがあったのを修正しています。
# HashWithIndifferentAccess h = HashWithIndifferentAccess.new({ a: { b: 'b' } }) dup = h.dup dup[:a][:c] = 'c' h[:a][:c] # nil # Hash h = Hash.new({ a: { b: 'b' } }) dup = h.dup dup[:a][:c] = 'c' h[:a][:c] # 'c'
add has_one? method and reuse instead of checking macro
ActiveRecordの修正です。
macro == :has_one
チェック用にhas_one?
メソッドを作成し、macro == :has_one
していた箇所をhas_one?
メソッドに修正しています。
Abstract away use of HABTM macro
HABTMReflection
クラスを新規に作成し、has_and_belongs_to_many
を使用している場合、reflectionにはHABTMReflection
クラスを使用するよう修正しています。
reuse available collection? check instead of macro
ActiveRecordの修正です。
マクロをチェックする際、macro == :has_many
というチェック処理を行っていたのですが、collection?
メソッドでチェック出来るとの事で、macro == :has_many
をcollection?
に置き換えています。
Use HasAndBelongsToMany instead of HABTM
activerecord/lib/active_record/reflection.rb
の修正です。
先ほど追加されたHABTMReflection
クラスをHasAndBelongsToManyReflection
にリネームしています。クラス名は明確に、ですかね。
[ci skip] Add note about type modifiers that cannot be specified in command line.
rails guideのActive Record Migrations
の修正です。
null
とdefault
はコマンドラインでは指定する事が出来ない旨追記されています。
知らなかったのですが、polymorphic
はコマンドラインで指定出来るんですねえ。
bin/rails generate migration AddDetailsToProducts 'price:decimal{5,2}' supplier:references{polymorphic}
ActiveRecord::FinderMethods.find passes proc parameter #15382
activerecord/lib/active_record/relation/finder_methods.rb
の修正です。
ActiveRecord::FinderMethods.find
メソッドにブロックを渡した場合に、Enumerable#find
と同様にprocパラメータを扱えるようになりました。
Todo.all.find(-> { raise "should happen" }) { |e| e.id == -1 } # RuntimeError: should happen
こんなふうに書ける訳ですね。
remove depricated Validatior#setup
activemodel/lib/active_model/validator.rb
の修正です。
depricatedだったValidatior#setup
メソッドを削除しています。
[ci skip] Rename: Rails Database Migration to Active Record Migration.
rails guideの修正です。
guides/source/migrations.md
をguides/source/active_record_migrations.md
にリネームしています。
docs, refactor docs about column modifiers. [ci skip] [Matthew Draper & Yves Senn]
rails guideのActive Record Migrations
の修正です。
カラムの設定内容について、説明を修正しています。
先にあった修正の補足です。
test, fix typo, create_index
does not exist.
activerecord/test/cases/schema_dumper_test.rb
の修正です。
create_index
をadd_index
に修正しています。タイポですね。
actionview/lib/action_view/tasks/dependencies.rake
の修正です。
cache_digests:dependencies
、cache_digests:nested_dependencies
の2つのrake taskでActionView::Digestor.new
の呼び出しを修正しています。
ActionView::Digestor.new
の引数が変わっていたのに対応したとの事です。
Inline PG array type casting helper
PostgreSQLのConnectionAdapterの修正です。
PG arrayに関する処理をPostgreSQL::Cast
にまとめています。
Keep the types of virtual columns after yaml serialization
activerecord/lib/active_record/type/serialized.rb
の修正です。
yamlのserializationのした後でもtypeクラスの型を保持するよう修正しています。
PostgreSQLとMySQLのConnectionApapterでは型の変換処理が不要、との事。
activerecord/test/cases/adapters/postgresql/range_test.rb
の修正です。warningが出ていたのを対応しています。