なるようになるブログ

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

rails commit log流し読み(2015/01/20)

2015/01/20分のコミットです。

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

activerecord/CHANGELOG.md


Don't mutate bind values in Relation

activerecord/lib/active_record/relation.rbactiverecord/lib/active_record/relation/query_methods.rbの修正です。

where_unscopingメソッドで処理したbind_valuesの値をインスタンス変数に設定するよう修正し、Relation#initialize_copyでのbind valuesの設定処理を削除しています。


Whether a column exists or not doesn't affect whether we can use binds

activerecord/lib/active_record/relation/query_methods.rbの修正です、

create_bindsメソッドで行っていたcolumnがnilかどうかの判定処理を削除しています。bind処理において、特にnilかどうかは影響が無い為、との事。


Move create_binds over to the PredicateBuilder

activerecord/lib/active_record/relation/predicate_builder.rbactiverecord/lib/active_record/relation/query_methods.rbの修正です。

QueryMethods#create_bindsメソッドPredicateBuilder配下に移動しています。


Fix bind value copying from subqueried relations

activerecord/lib/active_record/relation/predicate_builder.rbactiverecord/lib/active_record/relation/query_methods.rbの修正です。

build_whereメソッドで行っていたrelationのbind処理をPredicateBuilder#create_binds内で行うよう修正しています。

元々の処理はattributesからRelation objectsを検索し、見つかったらbind valueして、それをmergeしていく、という処理だったのですが、これだとorderが無視されてしまっていた為、orderが反映されるよう、修正されたようです。


Merge pull request #18597 from kamipo/add-if-exists-to-drop-table

ActiveRecordのConnectionAdaptersの修正です。

drop_tableメソッドif_existsオプションを追加しています。

drop_table(:posts, if_exists: true) 
# => "DROP TABLE IF EXISTS posts" が実行される

存在しないtableに対してdrop_tableを行った際、if_exists: trueの場合何もせず、if_exists: falseの場合、exceptionがraiseされます。デフォルトはfalse


tests, use drop_table if_exists: true in our test suite.

ActiveRecordのテストの修正です。

先に追加されたif_existsオプションを使ってtableのdropをするよう修正しています。