なるようになるブログ

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

rails commit log流し読み(2021/04/13)

2021/04/13分のコミットです。

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

railties/CHANGELOG.md

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


Remove Rack::Runtime and deprecate referencing it

railtiesの修正です。

デフォルトのmiddleware stackから、Rack::Runtimeを削除しています。

runtime headerは、timing attacksを受ける可能性がある事、及びstreamingレスポンスでは正確な数字が返せない、という事から、デフォルトからは削除したとの事です。合わせて、Rack::Runtimeを参照した際にdeprecateメッセージを出す為のmiddleware(MiddlewareStack::FakeRuntime)を追加しています。


Don't define methods using the method modifier in the same line as the method

method modifier(ruby2_keywords)とmethodの定義を同じ行で行わないよう修正しています。style guideで同じ行で定義する事を推奨していない為。


Merge pull request #41933 from palkan/feat/upsert-all-returning-update-sql

Active Recordの修正です。

#upsert_allreturning statementにSQLを指定出来るよう修正しています。

Article.insert_all(
[
    { title: "Article 1", slug: "article-1", published: false },
    { title: "Article 2", slug: "article-2", published: false }
  ],
  returning: Arel.sql("id, (xmax = '0') as inserted, name as new_name")
)

合わせて、#upsert_allの重複の条件を指定するon_duplicateオプションにSQLを指定出来るよう修正しています。

Book.upsert_all(
  [{ id: 1, status: 1 }, { id: 2, status: 1 }],
  on_duplicate: Arel.sql("status = GREATEST(books.status, EXCLUDED.status)")
)

Merge pull request #41931 from MarcelEeken/deep-merge-changing-original-hash

activesupport/lib/active_support/core_ext/hash/deep_merge.rbの修正です。

Hash#deep_mergeにnestしたHashを指定した際に、nestした先の値がdupされない(元の値の参照が使われていた)バグがあったのを修正しています。

が、この対応によりvalueの変換結果が以前と変わってしまうケースがあった為、後ほどRevertされています。


Allow to opt-in to the new TimeWithZone.name and fix XmlMini serialization

Active Supportの修正です。

Deprecate ActiveSupport::TimeWithZone.nameでdeprecateにったActiveSupport::TimeWithZone.nameメソッドをconfig(config.active_support.remove_deprecated_time_with_zone_name)で削除出来るよう修正しています。


Merge pull request #41925 from jbampton/fix-grammar

rails guideのSecurity Policyの修正です。

Reporting a Vulnerabilityの項のグラマーの修正を行っています。


Merge pull request #41926 from jbampton/fix-favorite

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

favouritefavoriteに修正しています。


Merge pull request #41899 from sebastian-palma/add-for-docs

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

QueryMethods#fromのdocに、fromを複数指定した場合の対応方法についての説明を追加しています。


Merge pull request #41910 from jbampton/add-github-actions

.github/workflows/lint.ymlの修正です。

CIでmisspellを実行するよう設定を追加しています。


Merge pull request #41911 from Shopify/simplify-proxy-call

Active Model、Active Recordの修正です。

attribute methods を定義する際に明示的に引数を渡せるようにして、引数を受け取った際に不要なオブジェクトが生成されないよう修正しています。


Restore the Entry#bytesize comments removed in #41882

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

Refactor LocalCache to avoid calling Marshal.dump as muchで削除したEntry#bytesizeメソッドのdocを戻しています。


Fix HTML tag mismatches in Action Text README [ci skip]

rails guideのAction Text Overviewの修正です。

action-text-attachmentの出力例で閉じタグのタグ名が過っていたのを修正しています。


Make sure establish_connection with symbol work properly

activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rbactiverecord/lib/active_record/connection_adapters/pool_config.rbの修正です。

establish_connectionにSymbolを指定していた場合に、preventing_writes?を呼び出した際にエラーになってしまうバグがあったのを修正しています。


Fix grammar and clarity [ci skip]

rails guideのContributing to Ruby on Railsの修正です。

各箇所のグラマー、言い回しを修正しています。


docs: change user name to the more used username

docの修正です。

user nameusernameに修正しています。


Fix ActiveSupport::TimeZone#utc_to_local

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

utc_to_local_returns_utc_offset_timesがfalse、かつ、time instanceがfractional secondを保持していた場合に、ActiveSupport::TimeZone#utc_to_localの結果が正しい値にならないバグがあったのを修正しています。


Freeze ActiveSupport::Duration#parts hash

activesupport/lib/active_support/duration.rbactivesupport/lib/active_support/time_with_zone.rbの修正です。

ActiveSupport::Duration#partsをfreeze + 不要なwriterメソッドの削除を行っています。


Revert "Merge pull request #41931 from MarcelEeken/deep-merge-changing-original-hash"

Hash#deep_mergeにnestしたHashを指定した際にnestした先の値がdupされないバグがあったのを修正した、Merge pull request #41931 from MarcelEeken/deep-merge-changing-original-hashをRevertしています。breaking changeが発生してしまっていた為。


Fix spelling in EncryptionSchemesTest

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

テスト名のタイポを修正しています。


Fix spelling in Encryptor.encrypt docs [ci skip]

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

Encryptor.encryptメソッドのdoc内のタイポを修正しています。


Fix: assign previous encryption schemes via previous: config option.

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

ActiveRecord::Encryption.configureメソッドでinternal configを上書きが正しく出来ていないバグがあったのを修正しています。


Fix spelling of EnvelopeEncryptionPerformanceTest

activerecord/test/cases/encryption/performance/envelope_encryption_performance_test.rbの修正です。

クラス名のタイポを修正しています。


Fix spelling in AsynchronousQueryInsideTransactionError docs [ci skip]

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

AsynchronousQueryInsideTransactionErrorクラスのdoc内のタイポを修正しています。


Fix "warning: instance variable @previous_delivery_method not initialized"

actionmailer/test/test_helper_test.rbの修正です。

テストの後処理で参照するインスタンス名が誤っていたのを修正しています。


Merge pull request #41942 from caffkane/as-twz-dep-warn-correction

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

ActiveSupport::TimeWithZoneで出力deprecateメッセージ内のタイポを修正しています。


chore: fix spelling in controller/filters_test.rb

actionpack/test/controller/filters_test.rbの修正です。

クラス名のタイポを修正しています。


Merge pull request #41930 from Shopify/optimize-hstore-parser

activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rbの修正です。

Hstoreのpayloadsをparseするのに、StringScannerを使用するよう修正しています。処理高速化の為。


docs: lint Markdown for four rules

rails guideの修正です。

各guideについて、不要な空白の削除、フォーマットの修正等を行っています。


Fix spelling in FixtureResolverTest

actionview/test/template/testing/fixture_resolver_test.rbの修正です。

テスト内のタイポを修正しています。


Fix spelling in HasOneAssociationsTest

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

クラス名のタイポを修正しています。