なるようになるブログ

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

rails commit log流し読み(2018/10/27)

2018/10/27分のコミットです。

CHANGELOGへの追加はありませんでした。


Ignore empty condition on #construct_relation_for_exists

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

FinderMethods#construct_relation_for_existsメソッドで引数のconditionsが空の場合、何もrelationに対するwhere!を実行しないよう修正しています。

exists?に空のHashを指定した場合(e.g. Topic.exists?({}))の結果が元々はtrueだったのが、Merge pull request #28705 from kamipo/extract_construct_relation_for_…の対応以降falseになってしまい、再度trueを返すようにする為に上記対応を行っています。


create_table with :primary_key option has no effect if id: false is given

Active Recordのテストの修正です。

create_tableする際に、意味の無いオプション指定(id: false + primary_key)を指定していたのを削除し、代わりにカラム定義の箇所でprimary_keyオプションを指定するよう修正しています。


exists? with string argument is not invalid type

activerecord/test/cases/finder_test.rbの修正です。

primary keyにString型が使用されているmodelに対して、exists?メソッドにStringの値を指定した場合に、結果が正しく取得出来る事を確認するテストを追加しています。