なるようになるブログ

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

rails commit log流し読み(2019/08/30)

2019/08/30分のコミットです。

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


No need to stringify event names (= method names) that always are Symbols

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

Subscriberクラスでevent名(メソッド名)をStringとして扱っていたのを、Symbolとして扱うよにして不要な変換を行わなわないよう修正しています。


Extend test_can_write_while_reading_from_replicas_if_explicit

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

test_can_write_while_reading_from_replicas_if_explicitconnected_to + prevent_writes: falseを指定した後のconnectionの状態についてもテストするよう修正しています。

rails commit log流し読み(2019/08/29)

2019/08/29分のコミットです。

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

activerecord/CHANGELOG.md


This is no longer a fact in Rails 3+

rails guideのActive Support Core Extensionsの修正です。

parameterizeメソッドについて説明している箇所に、戻り値はActiveSupport::Multibyte::Charsにラップされた値になっている旨説明があったのですが、これは古い挙動で現状は違う為、該当部分の説明を削除しています。


Constantize a constant array in a method

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

transliterateメソッドで処理出来るencodingの一覧を変数で保持していたのを、定数で保持するよう修正しています。


Fix docs to update ruby version in reference URLs [ci skip]

rails guideのActive Record and PostgreSQLの修正です。

Rubyのcoreライブラリについてのdocのリンクをhttps://ruby-doc.org/core-2.2.2からhttps://ruby-doc.org/stdlib-2.5.0に修正しています。Rails 6.0がサポートしているRubyのバージョンが2.5以上な為。


US_ASCII strings are always UTF_8 compatible

activesupport/lib/active_support/core_ext/string/multibyte.rbの修正です。

is_utf8?メソッドでencodingがEncoding::US_ASCIIの場合、不要なforce_encoding(Encoding::UTF_8)を実行しないよう修正しています。


Merge pull request #37065 from eileencodes/push-while_preventing_writes-into-connected_to

activerecord/lib/active_record/connection_handling.rbactiverecord/lib/active_record/middleware/database_selector/resolver.rbの修正です。

connected_toメソッドの中からwhile_preventing_writesを直接呼び出すよう修正しています。

while_preventing_writesメソッドに渡す引数もconnected_toメソッドから渡せるようになっており、これで書き込みの禁止 / 許可をミドルウェアではなくアプリで制御出来るようになっています。

ミドルウェアレベルだとアプリ側でconnected_toを使用された場合に競合状態になって正しく書き込み処理のハンドリングが出来ないケースがあった為。


Fix missing close code tick mark in AR changelog [ci skip]

activerecord/CHANGELOG.mdの修正です。

メソッド名に対するクォートが不足していたのを修正しています。


Remove mysql2 specific rescue in abstract adapter

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rbactiverecord/lib/active_record/connection_adapters/mysql2_adapter.rbの修正です。

AbstractMysqlAdapter#translate_exceptionメソッドでmysql2固有のエラーに関する処理があったのを、mysql2固有のエラーについてはMysql2Adapterクラスで行うよう修正しています。

rails commit log流し読み(2019/08/28)

2019/08/28分のコミットです。

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

activesupport/CHANGELOG.md


Disallow all non-numerics as Duration.build input, Fixes #37012

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

ActiveSupport::Duration.buildの引数にNumeric以外の値を指定した場合TypeErrorをraiseするよう修正しています。

元々Stringを指定してもDurationインスタンスを生成出来るようになっていたのですが、Stringを指定した場合のインスタンスNumericを指定した場合のインスタンスとの比較処理が正しく行えない、という問題がありました。

それは振る舞いとしてよくないよねという話になり、という事でそもそもNumeric以外の値は指定出来ないよう修正されました。


Changed controller name (Typo fix) in rails engines documentation [ci skip]

rails guideのGetting Started with Enginesの修正です。

Using a Class Provided by the Applicationの項のexampleコードのコントローラ名をタイポしていたのを修正しています。


Add doc about I18n support for :placeholder option [ci skip]

actionview/lib/action_view/helpers/form_tag_helper.rbのdocの修正です。

text_field_tagメソッドのdocに:placeholderオプションについての説明を追加しています。


Fix a document to update postgresql version for rails6 [ci skip]

rails guideのThe Rails Command Lineの修正です。

Rails with Databases and SCMの項にある、rails newで生成されるconfig/database.ymlの内容が実際の内容と異なっていたのを修正しています。


Clarify severe security issues maintenance policy [ci skip]

rails guideのMaintenance Policy for Ruby on Railsの修正です。

Severe Security Issuesの項の説明の言い回しを修正しています。


Update stale issue comment to mention 6-0-stable

.github/stale.ymlの修正です。

stale botがコメントする、まだissueが再現するかどうかを確認するブランチを5-2-stableから6-0-stableに修正しています。


Merge pull request #37047 from dvandersluis/37044-fix-exception-message

actionpack/lib/action_controller/metal/exceptions.rbactiverecord/lib/active_record/associations.rbの修正です。

MethodNotAllowedHasManyThroughSourceAssociationNotFoundError exceptionでエラーメッセージを構築する際に、to_sentenceメソッドでen localeを強制的に使用していたのを、使用しないよう修正しています。

en localeの設定が無い環境でエラー(I18n::InvalidLocale`)になってしまう為。

rails commit log流し読み(2019/08/27)

2019/08/27分のコミットです。

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

actionmailer/CHANGELOG.md

activesupport/CHANGELOG.md


Escape email addresses with name

actionmailer/lib/action_mailer/base.rbの修正です。

名前付きのemailを作成する為のemail_address_with_nameメソッドを追加しています・

email_address_with_name("sunny@example.org", "Sunny") #=> "Sunny <sunny@example.com>"

Add delete_multi method

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

cacheから複数データをまとめて削除する為のdelete_multiメソッドを追加しています。


Reduce Hash creation in FormHelper

actionview/lib/action_view/helpers/form_helper.rbの修正です。

FormHelper#objectify_optionsmergeメソッドを使用するのを避けて、Hashオブジェクトの生成を減らすようにしています。


No need to count an Array because Array knows its length

activesupport/lib/active_support/core_ext/string/output_safety.rbの修正です。

SafeBuffer#[]=メソッドで引数の数を数えるのにcountを使用していたのをlengthを使用するよう修正し、不要なループが実行されないよう修正していmす。


Skip tidying bytes for ascii_only strings

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

Unicode#tidy_bytesメソッドでStringがASCIIだけの場合不要な変換処理を行わないよう修正しています。


No need to dup && freeze an already frozen sql string

activerecord/lib/active_record/connection_adapters/abstract/database_statements.rbの修正です。

DatabaseStatements#to_sql_and_bindsメソッドでSQL Stringがfreezeな場合、不要なdup + freeze処理を実行しないよう修正しています。


Giving a Symbol here might be a very little bit efficient than giving a String

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

connection handlerを保持するスレッドローカル変数に使用するkeyをStringからSymbolに変更しています。keyは後の処理でSymbolに変更される為、最初からSymbolを使用した方が不要な変換が行われない為。


Fix rdoc of ActiveRecord::Associations::CollectionProxy#replace [ci skip]

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

ActiveRecord::Associations::CollectionProxy#replaceメソッドのdoc内のexampleコードで、括弧が不足している箇所があったのを修正しています。


Fix assertion in test_delete_multi

activesupport/test/cache/behaviors/cache_store_behavior.rbの修正です。

delete_multiメソッドのテストでチェックするkey名に誤りがあったのを修正しています。


Ignore SQLite3 database files generated by parallel testing

gitignoreの対象にparallel testingで生成するSQLite3のDBファイル(sqlite3- + 数字)を追加しています。

rails commit log流し読み(2019/08/26)

2019/08/26分のコミットです。

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


Merge pull request #28862 from georgemillo/show_detailed_exceptions

rails guideのConfiguring Rails Applicationsの修正です。

config.consider_all_requests_localについて説明している箇所に、より細かな制御が必要な場合、コントローラでshow_detailed_exceptions?を実装する必要がある旨説明を追加しています。


Always load validator class to verify it exists

activemodel/lib/active_model/validations/validates.rbの修正です。

optionの内容に関わらずvalidation classを必ずロードするよう修正しています。不正なvalidationが指定された場合に気付けるようにする(ロード時にエラーになるようにする)為。


Fix docs to replace http with https in activerecord [ci skip]

Active Recordのdocの修正です。

外部リンクへのURLをhttp -> httpsに修正しています。