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が出ていたのを対応しています。