なるようになるブログ

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

rails commit log流し読み(2025/01/21)

2025/01/21分のコミットです。

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

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


Deprecate using insert_all/upsert_all with unpersisted records in associations.

activerecord/lib/active_record/associations/collection_proxy.rb

保存していないassociationのrecord経由でのinsert_all/upsert_allをdeprecatedにしています。Reset AR::Relation in bulk insert and upsert methodsの対応の影響で、保存していないassociationは失われてしまうようになっていたのですが、失われないことを期待している既存の処理がある可能性がある為、一旦保存していないassociationの挙動は前のバージョンと同じになるようにし、今後消えるようになる旨メッセージを出力するようにしています。


Will not cause insert_all to error [ci-skip]

activerecord/CHANGELOG.mdの出力です。

先の対応のCHANGELOGのエントリーで、該当の処理はエラーになる旨記載されいたのを削除しています。insert_allはエラーにならない為。


Update has_one example to use descending order [ci skip]

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

has_oneメソッドのdoc内のexampleコードで、associationにorderを指定する場合のexampleにdescを指定するよう修正しています。association名がlast_commentとなっており、最後のデータをとれるようにする為。


Use already-loaded relation contents in #sole

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

Use limit in #sole, not first.の対応の影響で、#soleメソッドがload済みのrelationがある場合にも必ずqueryが実行されるようになっていたのを、load済みのassociationがある場合はそちらが使用されるよう修正しています。


Merge pull request #54172 from matthaigh27/main

Active Record、Active Supportの修正です。

JSON.parseで使用するオプションをActiveRecord::Coder::JSONに指定出来るよう対応、及び、ActiveRecord::Coder::JSONインスタンスserializeメソッドの:coderオプションに渡せるよう修正しています。

serialize :config, coder: ActiveRecord::Coder::JSON.new(symbolize_names: true)

合わせて、ActiveSupport::JSON.decodeJSON.parseで使用するオプションを指定出来るよう修正しています。


AS::MessageVerifier#verify always accept both safe and unsafe encoding

activesupport/lib/active_support/message_verifier.rbの修正です。

ActiveSupport::MessageVerifier#verifyにURL-safe/URL-unsafeどちらのencoded messagesも指定出来るよう修正しています。Rails 7.2からencoding処理がBase64 encodingからURL-safe Base64 encodingに変わった影響で、元々問題無かったURL-ensafeなmessagesがdecodeでエラーになるようになってしまっていました。そのため、アップグレードをスムーズに行えるようにする為、verifyについてはURL-unsafeな値についても元と同様に処理を行えるよう修正しています。


Prefer assert_dom over assert_select.

docの修正です。

assert_selectを使用している箇所をassert_domを使用するよう修正、及び、assert_selectorを使うべき箇所ではassert_selectorに修正しています。assert_domは現在assert_selectのaliasなのですが、Capybaraにassert_selectorメソッドがある影響で混乱する事が多い為、assert_domを使用するよう修正しています。


Improve test_json_symbolize_names_returns_symbolized_names

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

assert_equalに指定する値をexpected, actualの順になるよう修正しています。


Fix serialize coder: JSON, type: Hash to wrap the coder in ColumnSerializer

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

先のserialize処理の修正の影響で、serialize :my_hash, type: Hash, coder: JSONのように指定した場合のデフォルトの挙動が変わってしまっていたのを修正しています。