なるようになるブログ

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

rails commit log流し読み(2019/10/21)

2019/10/21分のコミットです。

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


Remove unused require

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

使用していないrequireを削除しています。


Rewrite LazilyDefineAttributes so that it removes itself

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

AcceptanceValidator::LazilyDefineAttributes classで、必要なaccessorsを定義後、不要になったrespond_to_missing?method_missingメソッドを削除するよう修正しています。


Merge pull request #37503 from seejohnrun/replace-conn-spec-with-role

Active Recordの修正です。

ConnectionAdapters::ConnectionSpecification classとConnectionPool::Role classをRole classにマージしています。

schema cacheの管理をDatabaseConfigurationから移動出来るようにする為で、新しく作られたRole classでschema cacheの管理を行うよう修正も合わせて行っています。


Simplify LazilyDefineAttributes

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

LazilyDefineAttributesについて、処理に使用するaccessor、メソッドを減らすようリファクタリングしています。


Return db_config from resolve_config_for_connection

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

resolve_config_for_connectionメソッドの戻り値がconfiguration hash(の値の一部)だったのを、DatabaseConfig objectを返すよう修正しています。


Don't instantiate new role

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

不要なインスタンスの再作成処理があったのを削除しています。

rails commit log流し読み(2019/10/20)

2019/10/20分のコミットです。

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


Do not refer guides in edgeguides [ci skip]

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

別ガイドへのリンクにドメイン(https://guides.rubyonrails.org)まで含まれていたのを、相対リンクにするよう修正しています。edgeguidesを参照した際にguidesへのリンクになってしまうのを避ける為。


Make the method signature of association.build the same as klass.build and relation.build

Active Recordの修正です。

association.buildメソッドの引数がklass.buildrelation.buildメソッドと同じになるよう修正しています。

rails commit log流し読み(2019/10/19)

2019/10/19分のコミットです。

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

activesupport/CHANGELOG.md


Fix Messages::Metadata#fresh? to handle parse_json_times = true

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

ActiveSupport.parse_json_timesにtrueを指定している場合、ActiveSupport::Messages::Metadata#fresh?を呼び出すとエラーになってしまうバグがあったのを修正しています。


Follow-up 6e0aa1887d: So we do need the wrapper, doh

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

先のActiveSupport::Messages::Metadata#fresh?の修正で元の挙動(Messages::Metadata.newexpires_atにStringを渡した場合)が正しくd動作しなくなってしまっていたのを修正しています。


Merge branch 'enforce-that-actioncable-compiled-bundle-is-in-sync-with-source-code'

actioncable/test/javascript_package_test.rbの修正です。

Action Cableのcompiledファイルとソースコードに差異が無い事(ソース変更した際にcompileがされている事)を確認するテストを追加しています。


Fix new instance creation on association relation to respect unscope

activerecord/lib/active_record/association_relation.rbactiverecord/lib/active_record/associations/association.rbの修正です。

association経由でインスタンスの生成をする際に、生成するモデルに指定したunscopeが無視されてしまうバグがあったのを修正しています。

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

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

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


Remove tests that limit/offset without order which is non-deterministic result

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

orderなしでlimit / offsetを指定するテストを削除しています。他のテストで確認出来ている内容の為。


Fix random CI fail due to non-deterministic order

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

assertionで値を比較する際に、値をidでsortしてからチェックするよう修正しています。 sortを指定しないと結果が不定になる為。


Add methods to the public API of ActiveRecord::Inheritance

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

ActiveRecord::InheritanceSTI、Polymorphic associationのクラス名を取得する際に使用するpublic API(sti_class_forpolymorphic_class_for)を追加しています。

このpublic APIをオーバーライドすることで、STI / Polymorphic assertionのクラス名取得の挙動を拡張する、という事が出来るようになっています。例えば、STI / Polymorphic associationのクラス名を変更するような場合に変更前の名前での変換も出来るようにするように挙動を上書きする、ような事が出来ます。

rails commit log流し読み(2019/10/17)

2019/10/17分のコミットです。

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

activesupport/CHANGELOG.md


Merge pull request #37458 from byroot/db-role

Active Recordの修正です。

DatabaseConfigで管理するようになっていたconnection poolsを、ConnectionAdapters module配下の専用クラス(Role)で管理するよう修正しています。

DatabaseConfigは、configに関する情報だけを管理するようにする為。


Nodoc Role

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

先ほど追加したConnectionAdapters::Roleクラスに:nodoc:を指定してAPI docに表示されないようにしています。


Refactor to reduce complexity from O(n*2) to O(n)

activesupport/lib/active_support/core_ext/class/subclasses.rbの修正です。

Class#subclassesメソッドで継承関係のチェックにsuperclassメソッドを使用するようリファクタリングしています。


Merge branch 'keep_symbolic_link_for_credentials'

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

credentials.yml.encをsymbolic linkで指定した場合に、credentialを編集すると実ファイルになってしまっていたのを、symbolic linkを維持するよう修正しています。


Fix random CI failure due to non-deterministic sorting order

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

assertionで値を比較する際に、値をidでsortしてからチェックするよう修正しています。 sortを指定しないと結果が不定になる為。


Enumerator should be supported by ActiveSupport::SafeBuffer

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

Rails 6.0でActiveSupport::SafeBufferEnumeratorを指定した場合(e.g. "aaa".html_safe.gsub!(/a/).with_index { |m, i| i })にエラーになってしまうバグがあったのを修正しています。


Fix i18n of attributes with multi-digit indexes

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

Merge pull request #37447 from jonathankwok/i18n-error-lookup-for-indexed-attribute でattributeにindexを含む場合にtranslationのlookup処理が動作するよう対応したのですが、indexが複数桁(10以上)になった場合の考慮が不足していたのを対応しています。

rails commit log流し読み(2019/10/16)

2019/10/16分のコミットです。

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


Merge pull request #37429 from gmcgibbon/opt_into_has_many_inverse

Active Recordの修正です。

Add support for belongs_to to has_many inversing.でサポートしたhas_manyのinvere処理を有効化するかどうかをconfigで指定出来るよう修正しています。

既存のアプリの挙動を壊してしまう可能性がある(実際壊れたらしい)為。デフォルトはfalse(無効化)。


Merge pull request #37447 from jonathankwok/i18n-error-lookup-for-indexed-attribute

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

attributeにindexを含む場合(index_errorsオプションを有効化している場合)に、translationのlookup処理が正しく動作しなかった(index部分が邪魔になっていてtranslationが取得出来なかった)のを、indexを含む場合もtranslationを取得出来るよう修正しています。


Remove patch for old JRuby versions

activesupport/lib/active_support/core_ext/class/subclasses.rbの修正です。

Class#descendantsメソッドから古いJRuby(9.0.4.0以下)用の処理を削除しています。

JRuby 9.0.5.0 (Ruby 2.2コンパチ)以上では不要な処理であり、Ruby 2.5以上のみをサポートしてるRailsのmasterでは不要な為。


Merge pull request #37482 from pwim/use-enumerator-in-descendants

activesupport/lib/active_support/core_ext/class/subclasses.rbの修正です。

Class#descendantsメソッドで結果を返すのに不要な変数を使用しないようリファクタリングしています。

rails commit log流し読み(2019/10/15)

2019/10/15分のコミットです。

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

activerecord/CHANGELOG.md


Revert "Revert "Merge pull request #37296 from Shopify/db-config-pool""

Merge pull request #37443 from eileencodes/use-database-config-objects-in-railties-dbconsoleで誤ってRevertしてしまったRefactor ConnectionPool managementのRevert commitをRevertして再度マージするよう修正しています。


Adds a link to the Basic Authentication section [ci skip]

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

What to include in your Functional Testsの項のBasic Authenticationについて説明している箇所に、https://guides.rubyonrails.org/getting_started.html#basic-authentication へのリンクを追加しています。


Merge pull request #37465 from alpaca-tc/optimize_primary_keys

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

primary keyを取得するのにinformation_schema.key_column_usageを参照していたのをinformation_schema.statisticsを参照するよう修正しています。

MySQL 8.0でメタデータのストレージがdata dictionaryに変更になり、その影響でinformation_schema.key_column_usageへのアクセスが低速になった為。


[ci skip] Remove reference to legacy Rails 2.x command https://github.com/rails/rails/commit/8f554a76ba28db2ac2b6a1cd67c3afcfaa284390

raisl guideのRails Application Templatesの修正です。

yes?(question) or no?(question)の項のexampleコードで既に存在しないコマンドを使用していたのを、db:migrateを使用するよう修正しています。


Fix Action Mailbox ingress config example [ci skip]

actionmailbox/lib/rails/generators/installer.rbの修正です。

action_mailbox:installconfig/environments/production.rbに追加する内容に誤りがあった(ingressに指定出来ない値を指定していた)のを修正しています。


Update multi_json to the latest version

Gemfile.lockの修正です。

multi_json gemのバージョンを最新のバージョンに更新しています。Rubyのwarningが表示されるのを避ける為。


Add two cross links to methods in docs [skip ci]

actionpack/lib/action_controller/metal/redirecting.rbactiverecord/lib/active_record/persistence.rbのdocの修正です。

redirect_backdeleteメソッドのdoc内のメソッドの説明が、そのメソッドのdocへのリンクになるよう修正しています。