なるようになるブログ

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

rails commit log流し読み(2019/02/18)

2019/02/18分のコミットです。

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

activemodel/CHANGELOG.md


Fix eager loading polymorphic association with mixed table conditions

Active Recordの修正です。

polymorphic associationが別のtableをjoinするscopeを持っていた場合に、そのassocationをeager loadした際に、foreign_keyforeign_typeが別のテーブルの条件として扱われてしまう、というバグがあったのを修正しています。


Use placeholder for type_condition predicate

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

type_conditionでplaceholderを使うよう修正しています。


upgrades Zeitwerk to 1.2.0

activesupport/activesupport.gemspecの修正です。

Zeitwerkのバージョンを1.2.0に更新しています。


Fix type cast with values hash for Date type

Active Modelの修正です。

Date typeのcastメソッドにHashの値を指定した場合にNameErrorが発生してしまうバグがあったのを修正しています。

timezoneの処理に関するメソッドの定義漏れによるエラーで、timezoneに関する処理をhelper moduleに切り出して、それをDate typeでincludeするようにして対応しています。


Remove duplicated test_update_all_with_order_and_limit

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

重複しててあったupdate_all + order + limitのテストを削除しています。


Extract duplicated serialize methods into helpers

Active Modelの修正です。

各type classで内容が重複していたserializeメソッドをhelperに切り出しています。


Merge pull request #29651 from Sayanc93/return-correct-date

activemodel/lib/active_model/type/date.rbの修正です。

multiparameter date hashをcastする際に、 グレゴリオ暦の日付からユリウス暦の日付に変換しないように修正しています。yearの値が小さい場合に、dateの値がおかしくなってしまう為。

# before
ActiveModel::Type::Date.new.cast({ 1 => 1, 2 => 1, 3 => 1 })
# => Sat, 01 Jan 0001

# after
ActiveModel::Type::Date.new.cast({ 1 => 1, 2 => 1, 3 => 1 })
# => Mon, 03 Jan 0001

date_selectdiscard_year + include_blankを指定した場合yearが1になり、上記問題による影響を受ける為修正を行っています。